summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2020-07-09 00:01:57 +0900
committerLorenzo Colitti <lorenzo@google.com>2020-07-08 15:19:44 +0000
commit82f4e345aef14aafec68cc40fbd8dc7dce50b852 (patch)
tree2d1be8780e7fcd4ada28d66dccb6834b1eb737cb
parent164a8c4e4e8ffb194bd7b60ed9d7d48c6be2a64d (diff)
downloadapf-82f4e345aef14aafec68cc40fbd8dc7dce50b852.tar.gz
Add test coverage for the --age parameter to apf_run.android-r-beta-3android-r-beta-2
Currently this is untested, and, as it happened, didn't work when all the other parameters (program, packet, data, --trace) were specified. Currently each testcase is a set of 3 or 4 files with the same basename and with extensions .program, .packet, .output, and optionally .data. For simplicity, add another optional file with extension .age. Instead of recreating more testdata, re-use the existing testcase one_ra_with_counters, adding three more variants of it, one with age 30 (drop), one with age 600 (drop) and one with age 601 (pass). Avoid adding identical files by using symlinks for the program, packet and data files, and only define new files for the output and age files. Test: atest apf_run_test Change-Id: Idab8be57b1f98bd0246d9ec31695becce43c0d05
-rwxr-xr-xapf_run_test.sh5
-rw-r--r--testdata/one_ra_with_counters_age_30.age1
l---------testdata/one_ra_with_counters_age_30.data1
-rw-r--r--testdata/one_ra_with_counters_age_30.output57
l---------testdata/one_ra_with_counters_age_30.packet1
l---------testdata/one_ra_with_counters_age_30.program1
-rw-r--r--testdata/one_ra_with_counters_age_600.age1
l---------testdata/one_ra_with_counters_age_600.data1
-rw-r--r--testdata/one_ra_with_counters_age_600.output57
l---------testdata/one_ra_with_counters_age_600.packet1
l---------testdata/one_ra_with_counters_age_600.program1
-rw-r--r--testdata/one_ra_with_counters_age_601.age1
l---------testdata/one_ra_with_counters_age_601.data1
-rw-r--r--testdata/one_ra_with_counters_age_601.output36
l---------testdata/one_ra_with_counters_age_601.packet1
l---------testdata/one_ra_with_counters_age_601.program1
16 files changed, 166 insertions, 1 deletions
diff --git a/apf_run_test.sh b/apf_run_test.sh
index b365e84..12bbfe0 100755
--- a/apf_run_test.sh
+++ b/apf_run_test.sh
@@ -8,7 +8,7 @@ testname=$(basename $(basename $0 .sh))
retcode=0
# Loop through testcases and run each one.
-# Each testcase is composed of a program, a packet, optionally the starting data, and the output.
+# Each testcase is composed of program, packet, output, and optionally, starting data and/or age.
for prog in testdata/*.program; do
testcase=$(basename $prog .program)
prog=$(cat testdata/$testcase.program)
@@ -19,6 +19,9 @@ for prog in testdata/*.program; do
if [[ -f testdata/$testcase.data ]]; then
args="$args --data $(cat testdata/$testcase.data)"
fi
+ if [[ -f testdata/$testcase.age ]]; then
+ args="$args --age $(cat testdata/$testcase.age)"
+ fi
if diff --color -u <(apf_run $args) <(cat $outputpath); then
echo $testname: $testcase: PASS
diff --git a/testdata/one_ra_with_counters_age_30.age b/testdata/one_ra_with_counters_age_30.age
new file mode 100644
index 0000000..64bb6b7
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_30.age
@@ -0,0 +1 @@
+30
diff --git a/testdata/one_ra_with_counters_age_30.data b/testdata/one_ra_with_counters_age_30.data
new file mode 120000
index 0000000..368e625
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_30.data
@@ -0,0 +1 @@
+one_ra_with_counters.data \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_30.output b/testdata/one_ra_with_counters_age_30.output
new file mode 100644
index 0000000..8797e74
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_30.output
@@ -0,0 +1,57 @@
+ R0 R1 PC Instruction
+-------------------------------------------------
+ 0 0 0: li r1, -4
+ 0 fffffffc 2: lddw r0, [r1+0]
+ 29 fffffffc 3: add r0, 1
+ 2a fffffffc 5: stdw r0, [r1+0]
+ 2a fffffffc 6: ldh r0, [12]
+ 86dd fffffffc 8: li r1, -104
+ 86dd ffffff98 10: jlt r0, 0x600, 503
+ 86dd ffffff98 15: li r1, -108
+ 86dd ffffff94 17: jeq r0, 0x88a2, 503
+ 86dd ffffff94 22: jeq r0, 0x88a4, 503
+ 86dd ffffff94 27: jeq r0, 0x88b8, 503
+ 86dd ffffff94 32: jeq r0, 0x88cd, 503
+ 86dd ffffff94 37: jeq r0, 0x88e3, 503
+ 86dd ffffff94 42: jne r0, 0x806, 115
+ 86dd ffffff94 115: jne r0, 0x800, 215
+ 86dd ffffff94 215: jeq r0, 0x86dd, 239
+ 86dd ffffff94 239: ldb r0, [20]
+ 3a ffffff94 241: jeq r0, 0x3a, 255
+ 3a ffffff94 255: ldb r0, [54]
+ 86 ffffff94 257: li r1, -84
+ 86 ffffffac 259: jeq r0, 0x85, 503
+ 86 ffffffac 262: jne r0, 0x88, 290
+ 86 ffffffac 290: ldm r0, m[14]
+ 96 ffffffac 292: jne r0, 0x96, 495
+ 96 ffffffac 295: ldm r0, m[15]
+ 1e ffffffac 297: jgt r0, 0x258, 495
+ 1e ffffffac 302: li r0, 0
+ 0 ffffffac 303: jnebs r0, 0xf, 495, 428e66343deb28a24b792e9086dd68
+ 0 ffffffac 321: li r0, 18
+ 12 ffffffac 323: jnebs r0, 0x26, 495, 00603afffe8000000000000002005efffe000265fe80000000000000408e66fffe343deb8600
+ 12 ffffffac 364: li r0, 58
+ 3a ffffffac 366: jnebs r0, 0x2, 495, 4000
+ 3a ffffffac 371: ldh r0, [60]
+ e10 ffffffac 373: jlt r0, 0x258, 495
+ e10 ffffffac 378: li r0, 62
+ 3e ffffffac 380: jnebs r0, 0x14, 495, 0000000000000000010100005e00026519050000
+ 3e ffffffac 403: ldw r0, [82]
+ e10 ffffffac 405: jlt r0, 0x258, 495
+ e10 ffffffac 410: li r0, 86
+ 56 ffffffac 412: jnebs r0, 0x24, 495, 2001486048600000000000000000884420014860486000000000000000008888030440c0
+ 56 ffffffac 451: ldw r0, [122]
+ 278d00 ffffffac 453: jlt r0, 0x258, 495
+ 278d00 ffffffac 458: ldw r0, [126]
+ 93a80 ffffffac 460: jlt r0, 0x258, 495
+ 93a80 ffffffac 465: li r0, 130
+ 82 ffffffac 468: jnebs r0, 0x14, 495, 000000002a0079e10abc0e000000000000000000
+ 82 ffffffac 491: li r1, -56
+ 82 ffffffc8 493: jmp 503
+ 82 ffffffc8 503: lddw r0, [r1+0]
+ 1b ffffffc8 504: add r0, 1
+ 1c ffffffc8 506: stdw r0, [r1+0]
+ 1c ffffffc8 507: jmp DROP
+ 1c ffffffc8 510: DROP
+Packet dropped
+Data: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a
diff --git a/testdata/one_ra_with_counters_age_30.packet b/testdata/one_ra_with_counters_age_30.packet
new file mode 120000
index 0000000..e32839c
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_30.packet
@@ -0,0 +1 @@
+one_ra_with_counters.packet \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_30.program b/testdata/one_ra_with_counters_age_30.program
new file mode 120000
index 0000000..2f0ad56
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_30.program
@@ -0,0 +1 @@
+one_ra_with_counters.program \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_600.age b/testdata/one_ra_with_counters_age_600.age
new file mode 100644
index 0000000..e9f960c
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_600.age
@@ -0,0 +1 @@
+600
diff --git a/testdata/one_ra_with_counters_age_600.data b/testdata/one_ra_with_counters_age_600.data
new file mode 120000
index 0000000..368e625
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_600.data
@@ -0,0 +1 @@
+one_ra_with_counters.data \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_600.output b/testdata/one_ra_with_counters_age_600.output
new file mode 100644
index 0000000..33c7d4a
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_600.output
@@ -0,0 +1,57 @@
+ R0 R1 PC Instruction
+-------------------------------------------------
+ 0 0 0: li r1, -4
+ 0 fffffffc 2: lddw r0, [r1+0]
+ 29 fffffffc 3: add r0, 1
+ 2a fffffffc 5: stdw r0, [r1+0]
+ 2a fffffffc 6: ldh r0, [12]
+ 86dd fffffffc 8: li r1, -104
+ 86dd ffffff98 10: jlt r0, 0x600, 503
+ 86dd ffffff98 15: li r1, -108
+ 86dd ffffff94 17: jeq r0, 0x88a2, 503
+ 86dd ffffff94 22: jeq r0, 0x88a4, 503
+ 86dd ffffff94 27: jeq r0, 0x88b8, 503
+ 86dd ffffff94 32: jeq r0, 0x88cd, 503
+ 86dd ffffff94 37: jeq r0, 0x88e3, 503
+ 86dd ffffff94 42: jne r0, 0x806, 115
+ 86dd ffffff94 115: jne r0, 0x800, 215
+ 86dd ffffff94 215: jeq r0, 0x86dd, 239
+ 86dd ffffff94 239: ldb r0, [20]
+ 3a ffffff94 241: jeq r0, 0x3a, 255
+ 3a ffffff94 255: ldb r0, [54]
+ 86 ffffff94 257: li r1, -84
+ 86 ffffffac 259: jeq r0, 0x85, 503
+ 86 ffffffac 262: jne r0, 0x88, 290
+ 86 ffffffac 290: ldm r0, m[14]
+ 96 ffffffac 292: jne r0, 0x96, 495
+ 96 ffffffac 295: ldm r0, m[15]
+ 258 ffffffac 297: jgt r0, 0x258, 495
+ 258 ffffffac 302: li r0, 0
+ 0 ffffffac 303: jnebs r0, 0xf, 495, 428e66343deb28a24b792e9086dd68
+ 0 ffffffac 321: li r0, 18
+ 12 ffffffac 323: jnebs r0, 0x26, 495, 00603afffe8000000000000002005efffe000265fe80000000000000408e66fffe343deb8600
+ 12 ffffffac 364: li r0, 58
+ 3a ffffffac 366: jnebs r0, 0x2, 495, 4000
+ 3a ffffffac 371: ldh r0, [60]
+ e10 ffffffac 373: jlt r0, 0x258, 495
+ e10 ffffffac 378: li r0, 62
+ 3e ffffffac 380: jnebs r0, 0x14, 495, 0000000000000000010100005e00026519050000
+ 3e ffffffac 403: ldw r0, [82]
+ e10 ffffffac 405: jlt r0, 0x258, 495
+ e10 ffffffac 410: li r0, 86
+ 56 ffffffac 412: jnebs r0, 0x24, 495, 2001486048600000000000000000884420014860486000000000000000008888030440c0
+ 56 ffffffac 451: ldw r0, [122]
+ 278d00 ffffffac 453: jlt r0, 0x258, 495
+ 278d00 ffffffac 458: ldw r0, [126]
+ 93a80 ffffffac 460: jlt r0, 0x258, 495
+ 93a80 ffffffac 465: li r0, 130
+ 82 ffffffac 468: jnebs r0, 0x14, 495, 000000002a0079e10abc0e000000000000000000
+ 82 ffffffac 491: li r1, -56
+ 82 ffffffc8 493: jmp 503
+ 82 ffffffc8 503: lddw r0, [r1+0]
+ 1b ffffffc8 504: add r0, 1
+ 1c ffffffc8 506: stdw r0, [r1+0]
+ 1c ffffffc8 507: jmp DROP
+ 1c ffffffc8 510: DROP
+Packet dropped
+Data: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a
diff --git a/testdata/one_ra_with_counters_age_600.packet b/testdata/one_ra_with_counters_age_600.packet
new file mode 120000
index 0000000..e32839c
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_600.packet
@@ -0,0 +1 @@
+one_ra_with_counters.packet \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_600.program b/testdata/one_ra_with_counters_age_600.program
new file mode 120000
index 0000000..2f0ad56
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_600.program
@@ -0,0 +1 @@
+one_ra_with_counters.program \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_601.age b/testdata/one_ra_with_counters_age_601.age
new file mode 100644
index 0000000..75a2e0d
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_601.age
@@ -0,0 +1 @@
+601
diff --git a/testdata/one_ra_with_counters_age_601.data b/testdata/one_ra_with_counters_age_601.data
new file mode 120000
index 0000000..368e625
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_601.data
@@ -0,0 +1 @@
+one_ra_with_counters.data \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_601.output b/testdata/one_ra_with_counters_age_601.output
new file mode 100644
index 0000000..4228eb5
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_601.output
@@ -0,0 +1,36 @@
+ R0 R1 PC Instruction
+-------------------------------------------------
+ 0 0 0: li r1, -4
+ 0 fffffffc 2: lddw r0, [r1+0]
+ 29 fffffffc 3: add r0, 1
+ 2a fffffffc 5: stdw r0, [r1+0]
+ 2a fffffffc 6: ldh r0, [12]
+ 86dd fffffffc 8: li r1, -104
+ 86dd ffffff98 10: jlt r0, 0x600, 503
+ 86dd ffffff98 15: li r1, -108
+ 86dd ffffff94 17: jeq r0, 0x88a2, 503
+ 86dd ffffff94 22: jeq r0, 0x88a4, 503
+ 86dd ffffff94 27: jeq r0, 0x88b8, 503
+ 86dd ffffff94 32: jeq r0, 0x88cd, 503
+ 86dd ffffff94 37: jeq r0, 0x88e3, 503
+ 86dd ffffff94 42: jne r0, 0x806, 115
+ 86dd ffffff94 115: jne r0, 0x800, 215
+ 86dd ffffff94 215: jeq r0, 0x86dd, 239
+ 86dd ffffff94 239: ldb r0, [20]
+ 3a ffffff94 241: jeq r0, 0x3a, 255
+ 3a ffffff94 255: ldb r0, [54]
+ 86 ffffff94 257: li r1, -84
+ 86 ffffffac 259: jeq r0, 0x85, 503
+ 86 ffffffac 262: jne r0, 0x88, 290
+ 86 ffffffac 290: ldm r0, m[14]
+ 96 ffffffac 292: jne r0, 0x96, 495
+ 96 ffffffac 295: ldm r0, m[15]
+ 259 ffffffac 297: jgt r0, 0x258, 495
+ 259 ffffffac 495: li r1, -28
+ 259 ffffffe4 497: lddw r0, [r1+0]
+ 0 ffffffe4 498: add r0, 1
+ 1 ffffffe4 500: stdw r0, [r1+0]
+ 1 ffffffe4 501: jmp PASS
+ 1 ffffffe4 509: PASS
+Packet passed
+Data: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000002a
diff --git a/testdata/one_ra_with_counters_age_601.packet b/testdata/one_ra_with_counters_age_601.packet
new file mode 120000
index 0000000..e32839c
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_601.packet
@@ -0,0 +1 @@
+one_ra_with_counters.packet \ No newline at end of file
diff --git a/testdata/one_ra_with_counters_age_601.program b/testdata/one_ra_with_counters_age_601.program
new file mode 120000
index 0000000..2f0ad56
--- /dev/null
+++ b/testdata/one_ra_with_counters_age_601.program
@@ -0,0 +1 @@
+one_ra_with_counters.program \ No newline at end of file