OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * NaCl testing shell | 8 * NaCl testing shell |
9 */ | 9 */ |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 static char* application_name = NULL; | 54 static char* application_name = NULL; |
55 int i; | 55 int i; |
56 size_t n; | 56 size_t n; |
57 int sel_ldr_argc; | 57 int sel_ldr_argc; |
58 char** tmp_ldr_argv; | 58 char** tmp_ldr_argv; |
59 const char** sel_ldr_argv; | 59 const char** sel_ldr_argv; |
60 int module_argc; | 60 int module_argc; |
61 const char** module_argv; | 61 const char** module_argv; |
62 static const char* kFixedArgs[] = { "-X", "5" }; | 62 static const char* kFixedArgs[] = { "-X", "5" }; |
63 int pass_debug = 0; | 63 int pass_debug = 0; |
64 | 64 int pass_pq_disable = 0; |
65 | 65 |
66 /* Descriptor transfer requires the following. */ | 66 /* Descriptor transfer requires the following. */ |
67 NaClNrdAllModulesInit(); | 67 NaClNrdAllModulesInit(); |
68 | 68 |
69 /* command line parsing */ | 69 /* command line parsing */ |
70 while ((opt = getopt(argc, argv, "df:Qv")) != -1) { | 70 while ((opt = getopt(argc, argv, "df:Qv")) != -1) { |
71 switch (opt) { | 71 switch (opt) { |
72 case 'd': | 72 case 'd': |
73 pass_debug = 1; | 73 pass_debug = 1; |
74 break; | 74 break; |
75 case 'f': | 75 case 'f': |
76 application_name = optarg; | 76 application_name = optarg; |
77 break; | 77 break; |
78 case 'v': | 78 case 'v': |
79 NaClLogIncrVerbosity(); | 79 NaClLogIncrVerbosity(); |
80 break; | 80 break; |
81 case 'Q': | 81 case 'Q': |
82 /* TODO(cbiffle): disable platform qualification, once it's used here */ | 82 /* TODO(cbiffle): pass this in the sel_ldr flags portion of the |
| 83 sel_universal commandline options. I.e., fix scons invocations |
| 84 etc. so that we don't need this special case here */ |
| 85 pass_pq_disable = 1; |
83 break; | 86 break; |
84 default: | 87 default: |
85 fputs(kUsage, stderr); | 88 fputs(kUsage, stderr); |
86 return -1; | 89 return -1; |
87 } | 90 } |
88 } | 91 } |
89 | 92 |
90 if (NULL == application_name) { | 93 if (NULL == application_name) { |
91 fprintf(stderr, "-f nacl_file must be specified\n"); | 94 fprintf(stderr, "-f nacl_file must be specified\n"); |
92 return 1; | 95 return 1; |
(...skipping 25 matching lines...) Expand all Loading... |
118 } else { | 121 } else { |
119 /* application arguments come last. */ | 122 /* application arguments come last. */ |
120 ++module_argc; | 123 ++module_argc; |
121 } | 124 } |
122 } | 125 } |
123 | 126 |
124 /* | 127 /* |
125 * Prepend the fixed arguments to the command line. | 128 * Prepend the fixed arguments to the command line. |
126 */ | 129 */ |
127 sel_ldr_argv = | 130 sel_ldr_argv = |
128 (const char**) malloc((pass_debug + sel_ldr_argc | 131 (const char**) malloc((pass_debug + pass_pq_disable + sel_ldr_argc |
129 + NACL_ARRAY_SIZE(kFixedArgs)) * | 132 + NACL_ARRAY_SIZE(kFixedArgs)) * |
130 sizeof(*sel_ldr_argv)); | 133 sizeof(*sel_ldr_argv)); |
131 for (n = 0; n < NACL_ARRAY_SIZE(kFixedArgs); ++n) { | 134 for (n = 0; n < NACL_ARRAY_SIZE(kFixedArgs); ++n) { |
132 sel_ldr_argv[n] = kFixedArgs[n]; | 135 sel_ldr_argv[n] = kFixedArgs[n]; |
133 } | 136 } |
134 for (i = 0; i < sel_ldr_argc; ++i) { | 137 for (i = 0; i < sel_ldr_argc; ++i) { |
135 sel_ldr_argv[i + NACL_ARRAY_SIZE(kFixedArgs)] = tmp_ldr_argv[i]; | 138 sel_ldr_argv[i + NACL_ARRAY_SIZE(kFixedArgs)] = tmp_ldr_argv[i]; |
136 } | 139 } |
137 if (pass_debug) { | 140 if (pass_debug) { |
138 sel_ldr_argv[sel_ldr_argc + NACL_ARRAY_SIZE(kFixedArgs)] = "-d"; | 141 sel_ldr_argv[sel_ldr_argc + NACL_ARRAY_SIZE(kFixedArgs)] = "-d"; |
139 } | 142 } |
| 143 if (pass_pq_disable) { |
| 144 sel_ldr_argv[sel_ldr_argc + NACL_ARRAY_SIZE(kFixedArgs) + pass_debug] = |
| 145 "-Q"; |
| 146 } |
140 | 147 |
141 /* | 148 /* |
142 * Start sel_ldr with the given application and arguments. | 149 * Start sel_ldr with the given application and arguments. |
143 */ | 150 */ |
144 launcher = NaClSelLdrStart(application_name, | 151 launcher = NaClSelLdrStart(application_name, |
145 5, | 152 5, |
146 (pass_debug + sel_ldr_argc | 153 (pass_debug + pass_pq_disable + sel_ldr_argc |
147 + NACL_ARRAY_SIZE(kFixedArgs)), | 154 + NACL_ARRAY_SIZE(kFixedArgs)), |
148 (const char**) sel_ldr_argv, | 155 (const char**) sel_ldr_argv, |
149 module_argc, | 156 module_argc, |
150 (const char**) module_argv); | 157 (const char**) module_argv); |
151 | 158 |
152 /* | 159 /* |
153 * Open the communication channels to the service runtime. | 160 * Open the communication channels to the service runtime. |
154 */ | 161 */ |
155 if (!NaClSelLdrOpenSrpcChannels(launcher, &command_channel, &channel)) { | 162 if (!NaClSelLdrOpenSrpcChannels(launcher, &command_channel, &channel)) { |
156 fprintf(stderr, "Open failed\n"); | 163 fprintf(stderr, "Open failed\n"); |
(...skipping 12 matching lines...) Expand all Loading... |
169 NaClSrpcDtor(&channel); | 176 NaClSrpcDtor(&channel); |
170 | 177 |
171 /* | 178 /* |
172 * And shut it down. | 179 * And shut it down. |
173 */ | 180 */ |
174 NaClSelLdrShutdown(launcher); | 181 NaClSelLdrShutdown(launcher); |
175 | 182 |
176 NaClNrdAllModulesFini(); | 183 NaClNrdAllModulesFini(); |
177 return 0; | 184 return 0; |
178 } | 185 } |
OLD | NEW |