aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2016-09-05 20:55:13 -0700
committerMax Filippov <jcmvbkbc@gmail.com>2017-01-15 13:01:56 -0800
commit72b3b8f24a4ada7f6e97fe5cd83e04f94b1f25e0 (patch)
tree1383ebd14ef342323d411c4b6486273ddbb4a3ca /tests
parent122d302053062af886c2272f1049017cbfdba7b3 (diff)
target/xtensa: tests: fix timer tests
Don't expect that CCOUNT increments are equal to the number of executed instructions. Verify that timer interrupt does not fire before the programmed CCOMPARE value and does fire after. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/tcg/xtensa/test_timer.S61
1 files changed, 33 insertions, 28 deletions
diff --git a/tests/tcg/xtensa/test_timer.S b/tests/tcg/xtensa/test_timer.S
index f8c6f7423a..9e6012d7fd 100644
--- a/tests/tcg/xtensa/test_timer.S
+++ b/tests/tcg/xtensa/test_timer.S
@@ -1,12 +1,22 @@
#include "macros.inc"
+#define CCOUNT_SHIFT 4
+#define WAIT_LOOPS 20
+
+.macro make_ccount_delta target, delta
+ rsr \delta, ccount
+ rsr \target, ccount
+ sub \delta, \target, \delta
+ slli \delta, \delta, CCOUNT_SHIFT
+ add \target, \target, \delta
+.endm
+
test_suite timer
test ccount
rsr a3, ccount
rsr a4, ccount
- sub a3, a4, a3
- assert eqi, a3, 1
+ assert ne, a3, a4
test_end
test ccompare
@@ -18,18 +28,18 @@ test ccompare
wsr a2, ccompare1
wsr a2, ccompare2
- movi a3, 20
- rsr a2, ccount
- addi a2, a2, 20
+ make_ccount_delta a2, a15
wsr a2, ccompare0
- rsr a2, interrupt
- assert eqi, a2, 0
- loop a3, 1f
- rsr a3, interrupt
- bnez a3, 2f
1:
- test_fail
+ rsr a3, interrupt
+ rsr a4, ccount
+ rsr a5, interrupt
+ sub a4, a4, a2
+ bgez a4, 2f
+ assert eqi, a3, 0
+ j 1b
2:
+ assert nei, a5, 0
test_end
test ccompare0_interrupt
@@ -42,9 +52,8 @@ test ccompare0_interrupt
wsr a2, ccompare1
wsr a2, ccompare2
- movi a3, 20
- rsr a2, ccount
- addi a2, a2, 20
+ movi a3, WAIT_LOOPS
+ make_ccount_delta a2, a15
wsr a2, ccompare0
rsync
rsr a2, interrupt
@@ -72,9 +81,8 @@ test ccompare1_interrupt
wsr a2, ccompare0
wsr a2, ccompare2
- movi a3, 20
- rsr a2, ccount
- addi a2, a2, 20
+ movi a3, WAIT_LOOPS
+ make_ccount_delta a2, a15
wsr a2, ccompare1
rsync
rsr a2, interrupt
@@ -99,9 +107,8 @@ test ccompare2_interrupt
wsr a2, ccompare0
wsr a2, ccompare1
- movi a3, 20
- rsr a2, ccount
- addi a2, a2, 20
+ movi a3, WAIT_LOOPS
+ make_ccount_delta a2, a15
wsr a2, ccompare2
rsync
rsr a2, interrupt
@@ -125,11 +132,10 @@ test ccompare_interrupt_masked
movi a2, 0
wsr a2, ccompare2
- movi a3, 40
- rsr a2, ccount
- addi a2, a2, 20
+ movi a3, 2 * WAIT_LOOPS
+ make_ccount_delta a2, a15
wsr a2, ccompare1
- addi a2, a2, 20
+ add a2, a2, a15
wsr a2, ccompare0
rsync
rsr a2, interrupt
@@ -156,11 +162,10 @@ test ccompare_interrupt_masked_waiti
movi a2, 0
wsr a2, ccompare2
- movi a3, 40
- rsr a2, ccount
- addi a2, a2, 20
+ movi a3, 2 * WAIT_LOOPS
+ make_ccount_delta a2, a15
wsr a2, ccompare1
- addi a2, a2, 20
+ add a2, a2, a15
wsr a2, ccompare0
rsync
rsr a2, interrupt