aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 15:10:23 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:59 +0200
commit4b92d25e002a3035d19fe54c240938843b0679b6 (patch)
tree421242a52f7991929a6a16982739e59e0c9780d0 /tests
parentaa11da7eff43adb57f935763f22c10abdff5279d (diff)
Use do_run_from_file() for test_vsnprintf
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_vsnprintf.in44
-rw-r--r--tests/core/test_vsnprintf.out7
-rw-r--r--tests/test_core.py54
3 files changed, 54 insertions, 51 deletions
diff --git a/tests/core/test_vsnprintf.in b/tests/core/test_vsnprintf.in
new file mode 100644
index 00000000..938729b6
--- /dev/null
+++ b/tests/core/test_vsnprintf.in
@@ -0,0 +1,44 @@
+
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+
+ void printy(const char *f, ...)
+ {
+ char buffer[256];
+ va_list args;
+ va_start(args, f);
+ vsnprintf(buffer, 256, f, args);
+ puts(buffer);
+ va_end(args);
+ }
+
+ int main(int argc, char **argv) {
+ int64_t x = argc - 1;
+ int64_t y = argc - 1 + 0x400000;
+ if (x % 3 == 2) y *= 2;
+
+ printy("0x%llx_0x%llx", x, y);
+ printy("0x%llx_0x%llx", x, x);
+ printy("0x%llx_0x%llx", y, x);
+ printy("0x%llx_0x%llx", y, y);
+
+ {
+ uint64_t A = 0x800000;
+ uint64_t B = 0x800000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x800;
+ uint64_t B = 0x12340000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x000009182746756;
+ uint64_t B = 0x192837465631ACBDULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_vsnprintf.out b/tests/core/test_vsnprintf.out
new file mode 100644
index 00000000..ef8a3f7e
--- /dev/null
+++ b/tests/core/test_vsnprintf.out
@@ -0,0 +1,7 @@
+0x0_0x400000
+0x0_0x0
+0x400000_0x0
+0x400000_0x400000
+0x800000_0x800000000000
+0x800_0x12340000000000
+0x9182746756_0x192837465631acbd
diff --git a/tests/test_core.py b/tests/test_core.py
index 5f5e7645..5b8976b7 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3602,58 +3602,10 @@ ok
def test_vsnprintf(self):
if self.emcc_args is None: return self.skip('needs i64 math')
- src = r'''
- #include <stdio.h>
- #include <stdarg.h>
- #include <stdint.h>
-
- void printy(const char *f, ...)
- {
- char buffer[256];
- va_list args;
- va_start(args, f);
- vsnprintf(buffer, 256, f, args);
- puts(buffer);
- va_end(args);
- }
-
- int main(int argc, char **argv) {
- int64_t x = argc - 1;
- int64_t y = argc - 1 + 0x400000;
- if (x % 3 == 2) y *= 2;
-
- printy("0x%llx_0x%llx", x, y);
- printy("0x%llx_0x%llx", x, x);
- printy("0x%llx_0x%llx", y, x);
- printy("0x%llx_0x%llx", y, y);
-
- {
- uint64_t A = 0x800000;
- uint64_t B = 0x800000000000ULL;
- printy("0x%llx_0x%llx", A, B);
- }
- {
- uint64_t A = 0x800;
- uint64_t B = 0x12340000000000ULL;
- printy("0x%llx_0x%llx", A, B);
- }
- {
- uint64_t A = 0x000009182746756;
- uint64_t B = 0x192837465631ACBDULL;
- printy("0x%llx_0x%llx", A, B);
- }
+ test_path = path_from_root('tests', 'core', 'test_vsnprintf')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''0x0_0x400000
-0x0_0x0
-0x400000_0x0
-0x400000_0x400000
-0x800000_0x800000000000
-0x800_0x12340000000000
-0x9182746756_0x192837465631acbd
-''')
+ self.do_run_from_file(src, output)
def test_printf_more(self):
src = r'''