|
7 | 7 | import org.junit.Test;
|
8 | 8 | import org.junit.runner.RunWith;
|
9 | 9 |
|
10 |
| -import java.io.IOException; |
11 | 10 | import java.util.ArrayList;
|
12 | 11 |
|
13 | 12 | import static org.junit.Assert.assertEquals;
|
14 |
| -import static org.junit.Assert.fail; |
15 | 13 |
|
16 | 14 | @RunWith(DeviceJUnit4ClassRunner.class)
|
17 | 15 | public class MemtagTest extends BaseHostJUnit4Test {
|
18 |
| - |
19 | 16 | private static final String TEST_BINARY = "/data/local/tmp/memtag_test";
|
20 | 17 |
|
21 |
| - enum Result { |
22 |
| - SUCCESS(0, ""), |
23 |
| - // it's expected that the device is configured to use asymm MTE tag checking mode |
24 |
| - ASYNC_MTE_ERROR(139, "SEGV_CODE 8"), |
25 |
| - SYNC_MTE_ERROR(139, "SEGV_CODE 9"), |
26 |
| - ; |
27 |
| - |
28 |
| - public final int exitCode; |
29 |
| - public final String stderr; |
30 |
| - |
31 |
| - Result(int exitCode, String stderr) { |
32 |
| - this.exitCode = exitCode; |
33 |
| - this.stderr = stderr; |
34 |
| - } |
35 |
| - } |
36 |
| - |
37 |
| - private static final int SEGV_EXIT_CODE = 139; |
38 |
| - |
39 |
| - private void runTest(String name, Result expectedResult) throws DeviceNotAvailableException { |
| 18 | + private void runTest(String name) throws DeviceNotAvailableException { |
40 | 19 | var args = new ArrayList<String>();
|
41 | 20 | args.add(TEST_BINARY);
|
42 | 21 | args.add(name);
|
43 | 22 | String cmdLine = String.join(" ", args);
|
44 | 23 |
|
45 | 24 | var result = getDevice().executeShellV2Command(cmdLine);
|
46 | 25 |
|
47 |
| - assertEquals("process exit code", expectedResult.exitCode, result.getExitCode().intValue()); |
48 |
| - assertEquals("stderr", expectedResult.stderr, result.getStderr()); |
| 26 | + assertEquals("stderr", "", result.getStderr()); |
| 27 | + assertEquals("process exit code", 0, result.getExitCode().intValue()); |
49 | 28 | }
|
50 | 29 |
|
51 | 30 | @Test
|
52 | 31 | public void tag_distinctness() throws DeviceNotAvailableException {
|
53 |
| - runTest("tag_distinctness", Result.SUCCESS); |
| 32 | + runTest("tag_distinctness"); |
54 | 33 | }
|
55 | 34 |
|
56 | 35 | @Test
|
57 | 36 | public void read_after_free() throws DeviceNotAvailableException {
|
58 |
| - runTest("read_after_free", Result.SYNC_MTE_ERROR); |
| 37 | + runTest("read_after_free"); |
59 | 38 | }
|
60 | 39 |
|
61 | 40 | @Test
|
62 | 41 | public void write_after_free() throws DeviceNotAvailableException {
|
63 |
| - runTest("write_after_free", Result.ASYNC_MTE_ERROR); |
| 42 | + runTest("write_after_free"); |
64 | 43 | }
|
65 | 44 |
|
66 | 45 | @Test
|
67 | 46 | public void underflow_read() throws DeviceNotAvailableException {
|
68 |
| - runTest("underflow_read", Result.SYNC_MTE_ERROR); |
| 47 | + runTest("underflow_read"); |
69 | 48 | }
|
70 | 49 |
|
71 | 50 | @Test
|
72 | 51 | public void underflow_write() throws DeviceNotAvailableException {
|
73 |
| - runTest("underflow_write", Result.ASYNC_MTE_ERROR); |
| 52 | + runTest("underflow_write"); |
74 | 53 | }
|
75 | 54 |
|
76 | 55 | @Test
|
77 | 56 | public void overflow_read() throws DeviceNotAvailableException {
|
78 |
| - runTest("overflow_read", Result.SYNC_MTE_ERROR); |
| 57 | + runTest("overflow_read"); |
79 | 58 | }
|
80 | 59 |
|
81 | 60 | @Test
|
82 | 61 | public void overflow_write() throws DeviceNotAvailableException {
|
83 |
| - runTest("overflow_write", Result.ASYNC_MTE_ERROR); |
| 62 | + runTest("overflow_write"); |
84 | 63 | }
|
85 | 64 |
|
86 | 65 | @Test
|
87 | 66 | public void untagged_read() throws DeviceNotAvailableException {
|
88 |
| - runTest("untagged_read", Result.SYNC_MTE_ERROR); |
| 67 | + runTest("untagged_read"); |
89 | 68 | }
|
90 | 69 |
|
91 | 70 | @Test
|
92 | 71 | public void untagged_write() throws DeviceNotAvailableException {
|
93 |
| - runTest("untagged_write", Result.ASYNC_MTE_ERROR); |
| 72 | + runTest("untagged_write"); |
94 | 73 | }
|
95 | 74 | }
|
0 commit comments