diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 14:35:15 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:58 +0200 |
commit | 01824569b33d713039bf6c5c0bfa9554dab5c5bf (patch) | |
tree | 8ebe6271f0d088e0f40814db4f5e81001355752a /tests/test_core.py | |
parent | 9f4687ed3d419ace23c9598bf2bd9ffd26fb855b (diff) |
Use do_run_from_file() for test_getopt
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index 0f84c51f..a55f51a5 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2542,52 +2542,10 @@ The current type of b is: 9 def test_getopt(self): if self.emcc_args is None: return self.skip('needs emcc for libc') - src = ''' - #pragma clang diagnostic ignored "-Winvalid-pp-token" - #include <unistd.h> - #include <stdlib.h> - #include <stdio.h> - - int - main(int argc, char *argv[]) - { - int flags, opt; - int nsecs, tfnd; - - nsecs = 0; - tfnd = 0; - flags = 0; - while ((opt = getopt(argc, argv, "nt:")) != -1) { - switch (opt) { - case 'n': - flags = 1; - break; - case 't': - nsecs = atoi(optarg); - tfnd = 1; - break; - default: /* '?' */ - fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\\n", - argv[0]); - exit(EXIT_FAILURE); - } - } - - printf("flags=%d; tfnd=%d; optind=%d\\n", flags, tfnd, optind); - - if (optind >= argc) { - fprintf(stderr, "Expected argument after options\\n"); - exit(EXIT_FAILURE); - } - - printf("name argument = %s\\n", argv[optind]); - - /* Other code omitted */ + test_path = path_from_root('tests', 'core', 'test_getopt') + src, output = (test_path + s for s in ('.in', '.out')) - exit(EXIT_SUCCESS); - } - ''' - self.do_run(src, 'flags=1; tfnd=1; optind=4\nname argument = foobar', args=['-t', '12', '-n', 'foobar']) + self.do_run_from_file(src, output, args=['-t', '12', '-n', 'foobar']) def test_getopt_long(self): if self.emcc_args is None: return self.skip('needs emcc for libc') |