diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 16:48:50 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:36:01 +0200 |
commit | 66db5a1d3ed9055ff58a2d249c18b55f7fd677df (patch) | |
tree | bd842905a6c7bd52390973761c4ddf6d23069a66 /tests | |
parent | 70884fb056b4d862fc0038cdcb4a742e5d13aa94 (diff) |
Use do_run_from_file() for test_atomic
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_atomic.in | 20 | ||||
-rw-r--r-- | tests/core/test_atomic.out | 5 | ||||
-rw-r--r-- | tests/test_core.py | 24 |
3 files changed, 28 insertions, 21 deletions
diff --git a/tests/core/test_atomic.in b/tests/core/test_atomic.in new file mode 100644 index 00000000..d0950551 --- /dev/null +++ b/tests/core/test_atomic.in @@ -0,0 +1,20 @@ + + #include <stdio.h> + int main() { + int x = 10; + int y = __sync_add_and_fetch(&x, 5); + printf("*%d,%d*\n", x, y); + x = 10; + y = __sync_fetch_and_add(&x, 5); + printf("*%d,%d*\n", x, y); + x = 10; + y = __sync_lock_test_and_set(&x, 6); + printf("*%d,%d*\n", x, y); + x = 10; + y = __sync_bool_compare_and_swap(&x, 9, 7); + printf("*%d,%d*\n", x, y); + y = __sync_bool_compare_and_swap(&x, 10, 7); + printf("*%d,%d*\n", x, y); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_atomic.out b/tests/core/test_atomic.out new file mode 100644 index 00000000..ed11bce0 --- /dev/null +++ b/tests/core/test_atomic.out @@ -0,0 +1,5 @@ +*15,15* +*15,10* +*6,10* +*10,0* +*7,1*
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 01bacca7..cb319500 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -4226,28 +4226,10 @@ PORT: 3979 self.do_run_from_file(src, output) def test_atomic(self): - src = ''' - #include <stdio.h> - int main() { - int x = 10; - int y = __sync_add_and_fetch(&x, 5); - printf("*%d,%d*\\n", x, y); - x = 10; - y = __sync_fetch_and_add(&x, 5); - printf("*%d,%d*\\n", x, y); - x = 10; - y = __sync_lock_test_and_set(&x, 6); - printf("*%d,%d*\\n", x, y); - x = 10; - y = __sync_bool_compare_and_swap(&x, 9, 7); - printf("*%d,%d*\\n", x, y); - y = __sync_bool_compare_and_swap(&x, 10, 7); - printf("*%d,%d*\\n", x, y); - return 0; - } - ''' + test_path = path_from_root('tests', 'core', 'test_atomic') + src, output = (test_path + s for s in ('.in', '.out')) - self.do_run(src, '*15,15*\n*15,10*\n*6,10*\n*10,0*\n*7,1*') + self.do_run_from_file(src, output) def test_phiundef(self): src = r''' |