summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2019-10-15 22:10:17 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-10-15 22:10:17 -0700
commit42383d6a21085ad54014c1d7fea3205b8e93a8ca (patch)
tree56654ecdcd6af3aa11dd9b4dfc3407f0a0d72bbd
parent687dc350f895b92b65aba8eaf86f10672a996dfd (diff)
parentad57e39f077da995f9b9315280a94ae66c50c314 (diff)
downloadapf-42383d6a21085ad54014c1d7fea3205b8e93a8ca.tar.gz
Add some tests for apf_run. am: 26dafcd858 am: 37e5280ee8
am: ad57e39f07 Change-Id: Ic83594bf763945c0f0f616bc9c0acb83605fc87a
-rw-r--r--Android.bp15
-rwxr-xr-xapf_run_test.sh32
-rw-r--r--apf_run_test.xml25
-rw-r--r--testdata/large_ra_without_counters.output26
-rw-r--r--testdata/large_ra_without_counters.packet1
-rw-r--r--testdata/large_ra_without_counters.program1
-rw-r--r--testdata/one_ra_with_counters.data1
-rw-r--r--testdata/one_ra_with_counters.output57
-rw-r--r--testdata/one_ra_with_counters.packet1
-rw-r--r--testdata/one_ra_with_counters.program1
10 files changed, 160 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index c326428..5df80dd 100644
--- a/Android.bp
+++ b/Android.bp
@@ -52,3 +52,18 @@ cc_binary_host {
},
},
}
+
+sh_test_host {
+ name: "apf_run_test",
+ src: "apf_run_test.sh",
+ filename: "apf_run_test.sh",
+ test_suites: ["general-tests"],
+ test_config: "apf_run_test.xml",
+ required: [":apf_run"],
+ data: ["testdata/*"],
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
diff --git a/apf_run_test.sh b/apf_run_test.sh
new file mode 100755
index 0000000..b365e84
--- /dev/null
+++ b/apf_run_test.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Find out where we are and what we're called.
+cd $(dirname $0)
+testname=$(basename $(basename $0 .sh))
+
+# All's well that ends well.
+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.
+for prog in testdata/*.program; do
+ testcase=$(basename $prog .program)
+ prog=$(cat testdata/$testcase.program)
+ pkt=$(cat testdata/$testcase.packet)
+ outputpath=testdata/$testcase.output
+
+ args="--trace --program $prog --packet $pkt"
+ if [[ -f testdata/$testcase.data ]]; then
+ args="$args --data $(cat testdata/$testcase.data)"
+ fi
+
+ if diff --color -u <(apf_run $args) <(cat $outputpath); then
+ echo $testname: $testcase: PASS
+ else
+ echo $testname: $testcase: FAIL
+ retcode=1
+ fi
+done
+
+# Report pass/fail to the test runner.
+exit $retcode
diff --git a/apf_run_test.xml b/apf_run_test.xml
new file mode 100644
index 0000000..689d5a6
--- /dev/null
+++ b/apf_run_test.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Config for running APF tools tests through atest">
+ <option name="test-suite-tag" value="apf_run_test" />
+ <!-- This test requires a device, so it's not annotated with a null-device -->
+ <test class="com.android.tradefed.testtype.binary.ExecutableHostTest" >
+ <option name="binary" value="apf_run_test.sh" />
+ <!-- Script assumes a relative path with the tests/ folders -->
+ <option name="relative-path-execution" value="true" />
+ <option name="per-binary-timeout" value="30s" />
+ </test>
+</configuration>
diff --git a/testdata/large_ra_without_counters.output b/testdata/large_ra_without_counters.output
new file mode 100644
index 0000000..e5faeb8
--- /dev/null
+++ b/testdata/large_ra_without_counters.output
@@ -0,0 +1,26 @@
+ R0 R1 PC Instruction
+-------------------------------------------------
+ 0 0 0: ldh r0, [12]
+ 2 86dd 2: jlt r0, 0x600, DROP
+ 7 86dd 7: jne r0, 0x806, 64
+ 40 86dd 64: jne r0, 0x800, 141
+ 8d 86dd 141: jeq r0, 0x86dd, 161
+ a1 86dd 161: ldb r0, [20]
+ a3 3a 163: jeq r0, 0x3a, 176
+ b0 3a 176: ldb r0, [54]
+ b2 86 178: jeq r0, 0x85, DROP
+ b7 86 183: jne r0, 0x88, 210
+ d2 86 210: ldm r0, m[14]
+ d4 ee 212: jne r0, 0x46, 297
+ 129 ee 297: ldm r0, m[14]
+ 12b ee 299: jne r0, 0x66, 433
+ 1b1 ee 433: ldm r0, m[14]
+ 1b3 ee 435: jne r0, 0x6e, 571
+ 23b ee 571: ldm r0, m[14]
+ 23d ee 573: jne r0, 0x5e, 687
+ 2af ee 687: ldm r0, m[14]
+ 2b1 ee 689: jne r0, 0x5e, 808
+ 328 ee 808: ldm r0, m[14]
+ 32a ee 810: jne r0, 0x4e, PASS
+ 38c ee 908: PASS
+Packet passed
diff --git a/testdata/large_ra_without_counters.packet b/testdata/large_ra_without_counters.packet
new file mode 100644
index 0000000..ee06334
--- /dev/null
+++ b/testdata/large_ra_without_counters.packet
@@ -0,0 +1 @@
+00000000000000000000000086dd6001234500ee3afffe80000000000000000000001234abcdff020000000000000000000000000001860000004000070800007530000003e818036018000004b00064ff9b0000000000000000000000001905000000001c2020010db800010000000000000000000120010db8000100000000000000000002180203180000083420000000000000001801001800000960030440c0000002580000012c0000000020010db8000a0000000000000000000018024018000005dc20010db8000c000d030440c0000151800000a8c000000000fd950d1e001200000000000000000000
diff --git a/testdata/large_ra_without_counters.program b/testdata/large_ra_without_counters.program
new file mode 100644
index 0000000..b278059
--- /dev/null
+++ b/testdata/large_ra_without_counters.program
@@ -0,0 +1 @@
+120c940386060084003408066a0ea40373000600010800060412147a180184036900021a1c7c0363000068a403560006ffffffffffff1a267c0350000074034c84004808000a17821d1112149c00161fffab0d2a10820f446a3239a203060102030405067403250a1e52f07c031d00e01a1e7e00000312ffffffff68a403050006ffffffffffff7403037402ff7c000f86dd68a402ee0006ffffffffffff7402ec0a147a0a3a0a267c02e000ff7402dc0a367c02d600858218886a26a20310ff0200000000000000000000000000017402bbaa0e825246aa0f8a4da668a23a0f00000000000000000000000086dd606a12a20f2600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa208020000123c9203a6740264aa0e828366aa0f8a7e1068a26b0f00000000000000000000000086dd606a12a2402600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa239020000123c9234106a46a22b04030440c01a4a9226101a4e9221106a52a21804000000006a56a2031020010db80000000000000000000000007401dcaa0e82856eaa0f8a803268a26d0f00000000000000000000000086dd606a12a2422600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa23b020000123c9236326a46a22d04190500001a4a9228326a4ea203202001486048600000000000000000888820014860486000000000000000008844740152aa0e826f5eaa0f8a6aa668a2570f00000000000000000000000086dd606a12a22c2600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa225020000123c9220a66a46a21704190300006a4ea20210262000fe00000000000000000000000972deaa0e82745eaa0f8a6f4268a25c0f00000000000000000000000086dd606a12a2312600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa22a020000123c9225426a46a21c04180360181a4a9217426a4ea202100064ff9b0000000000000000000000007265aa0e825f4eaa0f8a5aa668a2470f00000000000000000000000086dd606a12a21c2600003a0000000000000000000000000000000000ff02000000000000000000000000000186006a3aa215020000123c9210a66a46a207041f0100001a4a9202a67201
diff --git a/testdata/one_ra_with_counters.data b/testdata/one_ra_with_counters.data
new file mode 100644
index 0000000..e0e2853
--- /dev/null
+++ b/testdata/one_ra_with_counters.data
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029
diff --git a/testdata/one_ra_with_counters.output b/testdata/one_ra_with_counters.output
new file mode 100644
index 0000000..76f24a1
--- /dev/null
+++ b/testdata/one_ra_with_counters.output
@@ -0,0 +1,57 @@
+ R0 R1 PC Instruction
+-------------------------------------------------
+ 0 0 0: li r1, -4
+ 2 0 2: lddw r0, [r1+0]
+ 3 29 3: add r0, 1
+ 5 2a 5: stdw r0, [r1+0]
+ 6 2a 6: ldh r0, [12]
+ 8 86dd 8: li r1, -104
+ a 86dd 10: jlt r0, 0x600, 503
+ f 86dd 15: li r1, -108
+ 11 86dd 17: jeq r0, 0x88a2, 503
+ 16 86dd 22: jeq r0, 0x88a4, 503
+ 1b 86dd 27: jeq r0, 0x88b8, 503
+ 20 86dd 32: jeq r0, 0x88cd, 503
+ 25 86dd 37: jeq r0, 0x88e3, 503
+ 2a 86dd 42: jne r0, 0x806, 115
+ 73 86dd 115: jne r0, 0x800, 215
+ d7 86dd 215: jeq r0, 0x86dd, 239
+ ef 86dd 239: ldb r0, [20]
+ f1 3a 241: jeq r0, 0x3a, 255
+ ff 3a 255: ldb r0, [54]
+ 101 86 257: li r1, -84
+ 103 86 259: jeq r0, 0x85, 503
+ 106 86 262: jne r0, 0x88, 290
+ 122 86 290: ldm r0, m[14]
+ 124 96 292: jne r0, 0x96, 495
+ 127 96 295: ldm r0, m[15]
+ 129 0 297: jgt r0, 0x258, 495
+ 12e 0 302: li r0, 0
+ 12f 0 303: jnebs r0, 0xf, 495, 428e66343deb28a24b792e9086dd68
+ 141 0 321: li r0, 18
+ 143 12 323: jnebs r0, 0x26, 495, 00603afffe8000000000000002005efffe000265fe80000000000000408e66fffe343deb8600
+ 16c 12 364: li r0, 58
+ 16e 3a 366: jnebs r0, 0x2, 495, 4000
+ 173 3a 371: ldh r0, [60]
+ 175 e10 373: jlt r0, 0x258, 495
+ 17a e10 378: li r0, 62
+ 17c 3e 380: jnebs r0, 0x14, 495, 0000000000000000010100005e00026519050000
+ 193 3e 403: ldw r0, [82]
+ 195 e10 405: jlt r0, 0x258, 495
+ 19a e10 410: li r0, 86
+ 19c 56 412: jnebs r0, 0x24, 495, 2001486048600000000000000000884420014860486000000000000000008888030440c0
+ 1c3 56 451: ldw r0, [122]
+ 1c5 278d00 453: jlt r0, 0x258, 495
+ 1ca 278d00 458: ldw r0, [126]
+ 1cc 93a80 460: jlt r0, 0x258, 495
+ 1d1 93a80 465: li r0, 130
+ 1d4 82 468: jnebs r0, 0x14, 495, 000000002a0079e10abc0e000000000000000000
+ 1eb 82 491: li r1, -56
+ 1ed 82 493: jmp 503
+ 1f7 82 503: lddw r0, [r1+0]
+ 1f8 1b 504: add r0, 1
+ 1fa 1c 506: stdw r0, [r1+0]
+ 1fb 1c 507: jmp DROP
+ 1fe 1c 510: DROP
+Packet dropped
+Data: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a
diff --git a/testdata/one_ra_with_counters.packet b/testdata/one_ra_with_counters.packet
new file mode 100644
index 0000000..861d8e9
--- /dev/null
+++ b/testdata/one_ra_with_counters.packet
@@ -0,0 +1 @@
+428e66343deb28a24b792e9086dd6800000000603afffe8000000000000002005efffe000265fe80000000000000408e66fffe343deb8600266140000e100000000000000000010100005e0002651905000000000e102001486048600000000000000000884420014860486000000000000000008888030440c000278d0000093a80000000002a0079e10abc0e000000000000000000
diff --git a/testdata/one_ra_with_counters.program b/testdata/one_ra_with_counters.program
new file mode 100644
index 0000000..4a1895f
--- /dev/null
+++ b/testdata/one_ra_with_counters.program
@@ -0,0 +1 @@
+6bfcb03a01b8120c6b989401e806006b947c01e188a27c01dc88a47c01d788b87c01d288cd7c01cd88e384004408066a0e6bdca401b3000600010800060412147a1e016bd88401a700021a1c6b907c01a40000686bd4a401900006ffffffffffff6a266bc0a4018900046447aee46bf874017e84005f08000a17821f1112149c00181fffab0d2a108211446a3239a20506428e66343deb6bf47401550a1e52f06bb07c015000e06bb81a1e7e00000143ffffffff6bb47e000001386447bfff6be868a401240006ffffffffffff6bbc7401256bf074011a7c001386dd686bd0a401070006ffffffffffff6bcc7401080a147a0b3a6b9c0a267afcff6be072f20a366bac7af1858219886a26a20410ff0200000000000000000000000000016ba872d5aa0e82c896aa0f8c00c1025868a2ae0f428e66343deb28a24b792e9086dd686a12a2832600603afffe8000000000000002005efffe000265fe80000000000000408e66fffe343deb86006a3aa27c024000123c94007502586a3ea25c140000000000000000010100005e000265190500001a5294005502586a56a22c242001486048600000000000000000884420014860486000000000000000008888030440c01a7a94002502581a7e94001e02586c0082a20414000000002a0079e10abc0e0000000000000000006bc872086be4b03a01b87206b03a01b87201