Skip to content

Commit 075a720

Browse files
committed
Add negative test case for cstest_py
1 parent cee9214 commit 075a720

File tree

7 files changed

+128
-3
lines changed

7 files changed

+128
-3
lines changed

suite/run_tests.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@
1818
f"cstest_py {root_dir}/tests/features/",
1919
]
2020

21-
for test in tests:
21+
expected_to_fail = [
22+
f"cstest_py {root_dir}/tests/negative/",
23+
]
24+
25+
for test in expected_to_fail:
2226
logger.info(f'Running {test}')
2327
logger.info("#######################")
24-
subprocess.run(test.split(" "), check=True)
25-
logger.info("-----------------------")
28+
try:
29+
subprocess.run(test.split(" "), check=True)
30+
logger.error("Test was expected to fail.")
31+
exit(-1)
32+
except Exception as e:
33+
logger.info("-----------------------")

tests/negative/should_fail_I.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
test_cases:
2+
-
3+
input:
4+
bytes: [ 0x00 ]
5+
arch: "sparc"
6+
options: [ CS_OPT_DETAIL, CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g2"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1
18+
-
19+
type: SPARC_OP_REG
20+
reg: g2

tests/negative/should_fail_II.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
test_cases:
2+
-
3+
input:
4+
bytes: [ 0x00, 0xa0, 0x40, 0x02 ]
5+
arch: "sparc"
6+
options: [ CS_OPT_DETAIL, CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g3"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1
18+
-
19+
type: SPARC_OP_REG
20+
reg: g2
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
test_cases:
2+
-
3+
input:
4+
bytes: [ 0x00, 0xa0, 0x40, 0x02 ]
5+
arch: "sparc"
6+
options: [ CS_OPT_DETAIL, CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g2"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1

tests/negative/should_fail_IV.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
test_cases:
2+
-
3+
input:
4+
bytes: [ 0x00, 0xa0, 0x40, 0x02 ]
5+
arch: "not_existant"
6+
options: [ CS_OPT_DETAIL, CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g2"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1
18+
-
19+
type: SPARC_OP_REG
20+
reg: g2

tests/negative/should_fail_V.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
test_cases:
2+
-
3+
input:
4+
bytes: [ 0x00, 0xa0, 0x40, 0x02 ]
5+
arch: "sparc"
6+
options: [ CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g2"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1
18+
-
19+
type: SPARC_OP_REG
20+
reg: g2

tests/negative/should_fail_VI.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
test_cases:
2+
-
3+
input
4+
bytes: [ 0x00 ]
5+
arch: "sparc"
6+
options: [ CS_OPT_DETAIL, CS_MODE_BIG_ENDIAN ]
7+
address: 0x1000
8+
expected:
9+
insns:
10+
-
11+
asm_text: "cmp %g1, %g2"
12+
details:
13+
sparc:
14+
operands:
15+
-
16+
type: SPARC_OP_REG
17+
reg: g1
18+
-
19+
type: SPARC_OP_REG
20+
reg: g2

0 commit comments

Comments
 (0)