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

Side by Side Diff: tests/faulted_thread_queue/faultqueue_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
« no previous file with comments | « tests/custom_desc/desc_test_host.c ('k') | tests/minnacl/minimal_test_host.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "native_client/src/include/nacl_assert.h" 7 #include "native_client/src/include/nacl_assert.h"
8 #include "native_client/src/include/nacl_macros.h" 8 #include "native_client/src/include/nacl_macros.h"
9 #include "native_client/src/include/portability_io.h" 9 #include "native_client/src/include/portability_io.h"
10 #include "native_client/src/shared/gio/gio.h"
11 #include "native_client/src/shared/platform/nacl_check.h" 10 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "native_client/src/shared/platform/nacl_exit.h" 11 #include "native_client/src/shared/platform/nacl_exit.h"
13 #include "native_client/src/shared/platform/nacl_log.h" 12 #include "native_client/src/shared/platform/nacl_log.h"
14 #include "native_client/src/shared/platform/nacl_sync_checked.h" 13 #include "native_client/src/shared/platform/nacl_sync_checked.h"
15 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h" 14 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
16 #include "native_client/src/trusted/service_runtime/include/bits/mman.h" 15 #include "native_client/src/trusted/service_runtime/include/bits/mman.h"
16 #include "native_client/src/trusted/service_runtime/load_file.h"
17 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" 17 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
18 #include "native_client/src/trusted/service_runtime/nacl_app.h" 18 #include "native_client/src/trusted/service_runtime/nacl_app.h"
19 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" 19 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
20 #include "native_client/src/trusted/service_runtime/nacl_copy.h" 20 #include "native_client/src/trusted/service_runtime/nacl_copy.h"
21 #include "native_client/src/trusted/service_runtime/nacl_signal.h" 21 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
22 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" 22 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h"
23 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h"
24 #include "native_client/src/trusted/service_runtime/osx/mach_exception_handler.h " 23 #include "native_client/src/trusted/service_runtime/osx/mach_exception_handler.h "
25 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 24 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
26 #include "native_client/src/trusted/service_runtime/thread_suspension.h" 25 #include "native_client/src/trusted/service_runtime/thread_suspension.h"
27 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler. h" 26 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler. h"
28 #include "native_client/tests/common/register_set.h" 27 #include "native_client/tests/common/register_set.h"
29 28
30 29
31 /* 30 /*
32 * This test program checks that we get notification of a fault that 31 * This test program checks that we get notification of a fault that
33 * happens in untrusted code in faultqueue_test_guest.c. 32 * happens in untrusted code in faultqueue_test_guest.c.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 regs.prog_ctr += kBreakInstructionSize; 269 regs.prog_ctr += kBreakInstructionSize;
271 NaClAppThreadSetSuspendedRegisters(natp, &regs); 270 NaClAppThreadSetSuspendedRegisters(natp, &regs);
272 ASSERT_EQ(NaClAppThreadUnblockIfFaulted(natp, &signal), 1); 271 ASSERT_EQ(NaClAppThreadUnblockIfFaulted(natp, &signal), 1);
273 NaClUntrustedThreadsResumeAll(nap); 272 NaClUntrustedThreadsResumeAll(nap);
274 CHECK(NaClWaitForMainThreadToExit(nap) == 0); 273 CHECK(NaClWaitForMainThreadToExit(nap) == 0);
275 } 274 }
276 275
277 int main(int argc, char **argv) { 276 int main(int argc, char **argv) {
278 struct NaClApp app; 277 struct NaClApp app;
279 struct NaClApp *nap = &app; 278 struct NaClApp *nap = &app;
280 struct GioMemoryFileSnapshot gio_file;
281 279
282 NaClDebugExceptionHandlerStandaloneHandleArgs(argc, argv); 280 NaClDebugExceptionHandlerStandaloneHandleArgs(argc, argv);
283 NaClHandleBootstrapArgs(&argc, &argv); 281 NaClHandleBootstrapArgs(&argc, &argv);
284 282
285 /* Turn off buffering to aid debugging. */ 283 /* Turn off buffering to aid debugging. */
286 setvbuf(stdout, NULL, _IONBF, 0); 284 setvbuf(stdout, NULL, _IONBF, 0);
287 setvbuf(stderr, NULL, _IONBF, 0); 285 setvbuf(stderr, NULL, _IONBF, 0);
288 286
289 NaClAllModulesInit(); 287 NaClAllModulesInit();
290 288
291 if (argc != 2) { 289 if (argc != 2) {
292 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n"); 290 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n");
293 } 291 }
294 292
295 NaClFileNameForValgrind(argv[1]);
296 CHECK(GioMemoryFileSnapshotCtor(&gio_file, argv[1]));
297 CHECK(NaClAppCtor(nap)); 293 CHECK(NaClAppCtor(nap));
298 CHECK(NaClAppLoadFile((struct Gio *) &gio_file, nap) == LOAD_OK); 294 CHECK(NaClAppLoadFileFromFilename(nap, argv[1]) == LOAD_OK);
299 NaClAppInitialDescriptorHookup(nap); 295 NaClAppInitialDescriptorHookup(nap);
300 CHECK(NaClAppPrepareToLaunch(nap) == LOAD_OK); 296 CHECK(NaClAppPrepareToLaunch(nap) == LOAD_OK);
301 297
302 #if NACL_LINUX 298 #if NACL_LINUX
303 NaClSignalHandlerInit(); 299 NaClSignalHandlerInit();
304 #elif NACL_OSX 300 #elif NACL_OSX
305 CHECK(NaClInterceptMachExceptions()); 301 CHECK(NaClInterceptMachExceptions());
306 #elif NACL_WINDOWS 302 #elif NACL_WINDOWS
307 nap->attach_debug_exception_handler_func = 303 nap->attach_debug_exception_handler_func =
308 NaClDebugExceptionHandlerStandaloneAttach; 304 NaClDebugExceptionHandlerStandaloneAttach;
309 #else 305 #else
310 # error Unknown host OS 306 # error Unknown host OS
311 #endif 307 #endif
312 CHECK(NaClFaultedThreadQueueEnable(nap)); 308 CHECK(NaClFaultedThreadQueueEnable(nap));
313 309
314 printf("Running TestReceivingFault...\n"); 310 printf("Running TestReceivingFault...\n");
315 TestReceivingFault(nap); 311 TestReceivingFault(nap);
316 312
317 printf("Running TestGettingRegistersInMacSwitchRemainingRegs...\n"); 313 printf("Running TestGettingRegistersInMacSwitchRemainingRegs...\n");
318 TestGettingRegistersInMacSwitchRemainingRegs(nap); 314 TestGettingRegistersInMacSwitchRemainingRegs(nap);
319 315
320 /* 316 /*
321 * Avoid calling exit() because it runs process-global destructors 317 * Avoid calling exit() because it runs process-global destructors
322 * which might break code that is running in our unjoined threads. 318 * which might break code that is running in our unjoined threads.
323 */ 319 */
324 NaClExit(0); 320 NaClExit(0);
325 } 321 }
OLDNEW
« no previous file with comments | « tests/custom_desc/desc_test_host.c ('k') | tests/minnacl/minimal_test_host.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698