OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #include <stdio.h> | |
8 | |
9 #include "native_client/src/include/portability.h" | |
10 #include "native_client/src/include/nacl_macros.h" | |
11 | |
12 #include "native_client/src/shared/platform/nacl_check.h" | |
13 #include "native_client/src/shared/platform/nacl_exit.h" | |
14 #include "native_client/src/shared/platform/nacl_log.h" | |
15 #include "native_client/src/shared/platform/platform_init.h" | |
16 | |
17 #include "native_client/src/trusted/platform/nacl_process.h" | |
18 | |
19 int main(int argc, char **argv) { | |
20 struct NaClProcess proc; | |
21 char *args[] = { argv[0], "-e", "0", NULL }; | |
22 int exit_code = -1; | |
23 int opt; | |
24 | |
25 while (EOF != (opt = getopt(argc, argv, "e:"))) { | |
26 switch (opt) { | |
27 case 'e': | |
28 exit_code = strtoul(optarg, (char **) NULL, 0); | |
29 default: | |
30 fprintf(stderr, | |
31 "Usage: nacl_process_test [args]\n" | |
32 " -e N program exit code\n"); | |
33 goto cleanup0; | |
34 } | |
35 } | |
36 | |
37 if (-1 != exit_code) { | |
38 goto cleanup0; | |
39 } | |
40 | |
41 NaClPlatformInit(); | |
42 | |
43 if (NaClProcessLaunch(&proc, args, NULL, 0) < 0) { | |
44 fprintf(stderr, | |
45 "nacl_process_test: could not launch process %s\n", | |
46 argv[0]); | |
47 goto cleanup1; | |
48 } | |
49 | |
50 if (!NaClProcessWaitForExitCode(&proc, &exit_code)) { | |
51 fprintf(stderr, | |
52 "nacl_process_test: failed waiting for process exit code\n"); | |
53 } | |
54 | |
55 if (0 == exit_code) { | |
56 printf("SUCCESS\n"); | |
57 } | |
58 | |
59 cleanup1: | |
60 NaClPlatformFini(); | |
Mark Seaborn
2012/08/24 00:22:42
You don't really need to call this before exiting.
| |
61 cleanup0: | |
62 return exit_code; | |
63 } | |
OLD | NEW |