Index: src/trusted/platform/nacl_process_test.c |
diff --git a/src/trusted/platform/nacl_process_test.c b/src/trusted/platform/nacl_process_test.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aaaf115a36cb46a7be761312e5dbf60755f8d3f8 |
--- /dev/null |
+++ b/src/trusted/platform/nacl_process_test.c |
@@ -0,0 +1,63 @@ |
+/* |
+ * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include <stdio.h> |
+ |
+#include "native_client/src/include/portability.h" |
+#include "native_client/src/include/nacl_macros.h" |
+ |
+#include "native_client/src/shared/platform/nacl_check.h" |
+#include "native_client/src/shared/platform/nacl_exit.h" |
+#include "native_client/src/shared/platform/nacl_log.h" |
+#include "native_client/src/shared/platform/platform_init.h" |
+ |
+#include "native_client/src/trusted/platform/nacl_process.h" |
+ |
+int main(int argc, char **argv) { |
+ struct NaClProcess proc; |
+ char *args[] = { argv[0], "-e", "0", NULL }; |
+ int exit_code = -1; |
+ int opt; |
+ |
+ while (EOF != (opt = getopt(argc, argv, "e:"))) { |
+ switch (opt) { |
+ case 'e': |
+ exit_code = strtoul(optarg, (char **) NULL, 0); |
+ default: |
+ fprintf(stderr, |
+ "Usage: nacl_process_test [args]\n" |
+ " -e N program exit code\n"); |
+ goto cleanup0; |
+ } |
+ } |
+ |
+ if (-1 != exit_code) { |
+ goto cleanup0; |
+ } |
+ |
+ NaClPlatformInit(); |
+ |
+ if (NaClProcessLaunch(&proc, args, NULL, 0) < 0) { |
+ fprintf(stderr, |
+ "nacl_process_test: could not launch process %s\n", |
+ argv[0]); |
+ goto cleanup1; |
+ } |
+ |
+ if (!NaClProcessWaitForExitCode(&proc, &exit_code)) { |
+ fprintf(stderr, |
+ "nacl_process_test: failed waiting for process exit code\n"); |
+ } |
+ |
+ if (0 == exit_code) { |
+ printf("SUCCESS\n"); |
+ } |
+ |
+ cleanup1: |
+ NaClPlatformFini(); |
Mark Seaborn
2012/08/24 00:22:42
You don't really need to call this before exiting.
|
+ cleanup0: |
+ return exit_code; |
+} |