Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: tests/custom_desc/desc_test_host.c

Issue 12226119: Factor out duplicated GioMemoryFileSnapshotCtor() + NaClAppLoadFile() calls (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 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 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "native_client/src/shared/gio/gio.h"
10 #include "native_client/src/shared/platform/nacl_check.h" 9 #include "native_client/src/shared/platform/nacl_check.h"
11 #include "native_client/src/shared/platform/nacl_exit.h" 10 #include "native_client/src/shared/platform/nacl_exit.h"
12 #include "native_client/src/shared/platform/nacl_log.h" 11 #include "native_client/src/shared/platform/nacl_log.h"
13 #include "native_client/src/trusted/desc/nacl_desc_custom.h" 12 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
13 #include "native_client/src/trusted/service_runtime/load_file.h"
14 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" 14 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
15 #include "native_client/src/trusted/service_runtime/nacl_app.h" 15 #include "native_client/src/trusted/service_runtime/nacl_app.h"
16 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h"
17 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 16 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
18 17
19 18
20 static struct NaClDesc *MakeExampleDesc(void); 19 static struct NaClDesc *MakeExampleDesc(void);
21 20
22 static void *g_handle = (void *) 0x1234; 21 static void *g_handle = (void *) 0x1234;
23 static int g_object_count = 0; 22 static int g_object_count = 0;
24 static struct NaClApp *g_nap; 23 static struct NaClApp *g_nap;
25 static struct NaClDesc *g_expected_desc; 24 static struct NaClDesc *g_expected_desc;
26 25
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 funcs.Destroy = ExampleDescDestroy; 171 funcs.Destroy = ExampleDescDestroy;
173 funcs.SendMsg = ExampleDescSendMsg; 172 funcs.SendMsg = ExampleDescSendMsg;
174 funcs.RecvMsg = ExampleDescRecvMsg; 173 funcs.RecvMsg = ExampleDescRecvMsg;
175 g_object_count++; 174 g_object_count++;
176 return NaClDescMakeCustomDesc(g_handle, &funcs); 175 return NaClDescMakeCustomDesc(g_handle, &funcs);
177 } 176 }
178 177
179 178
180 int main(int argc, char **argv) { 179 int main(int argc, char **argv) {
181 struct NaClApp app; 180 struct NaClApp app;
182 struct GioMemoryFileSnapshot gio_file;
183 181
184 NaClHandleBootstrapArgs(&argc, &argv); 182 NaClHandleBootstrapArgs(&argc, &argv);
185 183
186 if (argc != 2) { 184 if (argc != 2) {
187 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n"); 185 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n");
188 } 186 }
189 187
190 NaClAllModulesInit(); 188 NaClAllModulesInit();
191 189
192 NaClFileNameForValgrind(argv[1]);
193 CHECK(GioMemoryFileSnapshotCtor(&gio_file, argv[1]));
194 CHECK(NaClAppCtor(&app)); 190 CHECK(NaClAppCtor(&app));
195 CHECK(NaClAppLoadFile((struct Gio *) &gio_file, &app) == LOAD_OK); 191 CHECK(NaClAppLoadFileFromFilename(&app, argv[1]) == LOAD_OK);
196 NaClAppInitialDescriptorHookup(&app); 192 NaClAppInitialDescriptorHookup(&app);
197 193
198 g_nap = &app; 194 g_nap = &app;
199 g_expected_desc = MakeExampleDesc(); 195 g_expected_desc = MakeExampleDesc();
200 NaClSetDesc(&app, 10, g_expected_desc); 196 NaClSetDesc(&app, 10, g_expected_desc);
201 197
202 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK); 198 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK);
203 CHECK(NaClCreateMainThread(&app, 0, NULL, NULL)); 199 CHECK(NaClCreateMainThread(&app, 0, NULL, NULL));
204 CHECK(NaClWaitForMainThreadToExit(&app) == 0); 200 CHECK(NaClWaitForMainThreadToExit(&app) == 0);
205 201
206 /* Check for leaks. */ 202 /* Check for leaks. */
207 CHECK(g_object_count == 0); 203 CHECK(g_object_count == 0);
208 204
209 /* 205 /*
210 * Avoid calling exit() because it runs process-global destructors 206 * Avoid calling exit() because it runs process-global destructors
211 * which might break code that is running in our unjoined threads. 207 * which might break code that is running in our unjoined threads.
212 */ 208 */
213 NaClExit(0); 209 NaClExit(0);
214 return 0; 210 return 0;
215 } 211 }
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/service_runtime.gyp ('k') | tests/faulted_thread_queue/faultqueue_test_host.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698