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

Side by Side Diff: tests/signal_handler_single_step/regs_step_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/minnacl/minimal_test_host.c ('k') | tests/signal_handler_single_step/step_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 <signal.h> 7 #include <signal.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "native_client/src/include/nacl_assert.h" 10 #include "native_client/src/include/nacl_assert.h"
11 #include "native_client/src/include/portability_io.h" 11 #include "native_client/src/include/portability_io.h"
12 #include "native_client/src/shared/gio/gio.h"
13 #include "native_client/src/shared/platform/nacl_check.h" 12 #include "native_client/src/shared/platform/nacl_check.h"
14 #include "native_client/src/shared/platform/nacl_exit.h" 13 #include "native_client/src/shared/platform/nacl_exit.h"
15 #include "native_client/src/shared/platform/nacl_log.h" 14 #include "native_client/src/shared/platform/nacl_log.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"
17 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h " 16 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h "
17 #include "native_client/src/trusted/service_runtime/load_file.h"
18 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" 18 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
19 #include "native_client/src/trusted/service_runtime/nacl_app.h" 19 #include "native_client/src/trusted/service_runtime/nacl_app.h"
20 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" 20 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
21 #include "native_client/src/trusted/service_runtime/nacl_copy.h" 21 #include "native_client/src/trusted/service_runtime/nacl_copy.h"
22 #include "native_client/src/trusted/service_runtime/nacl_signal.h" 22 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
23 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" 23 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h"
24 #include "native_client/src/trusted/service_runtime/nacl_syscall_handlers.h" 24 #include "native_client/src/trusted/service_runtime/nacl_syscall_handlers.h"
25 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h"
26 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 25 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
27 #include "native_client/src/trusted/service_runtime/thread_suspension_unwind.h" 26 #include "native_client/src/trusted/service_runtime/thread_suspension_unwind.h"
28 #include "native_client/tests/common/register_set.h" 27 #include "native_client/tests/common/register_set.h"
29 #include "native_client/tests/signal_handler_single_step/step_test_common.h" 28 #include "native_client/tests/signal_handler_single_step/step_test_common.h"
30 29
31 30
32 /* 31 /*
33 * This test case checks that NaCl thread suspension reports the 32 * This test case checks that NaCl thread suspension reports the
34 * correct untrusted register values for a thread at all points during 33 * correct untrusted register values for a thread at all points during
35 * the context switches between trusted and untrusted code for 34 * the context switches between trusted and untrusted code for
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SignalSafeWrite(str, strlen(str)); 148 SignalSafeWrite(str, strlen(str));
150 SignalSafeLogStringLiteral("\n"); 149 SignalSafeLogStringLiteral("\n");
151 150
152 RegsAssertEqual(&context, expected_regs); 151 RegsAssertEqual(&context, expected_regs);
153 } 152 }
154 return NACL_SIGNAL_RETURN; 153 return NACL_SIGNAL_RETURN;
155 } 154 }
156 155
157 int main(int argc, char **argv) { 156 int main(int argc, char **argv) {
158 struct NaClApp app; 157 struct NaClApp app;
159 struct GioMemoryFileSnapshot gio_file;
160 uint32_t mmap_addr; 158 uint32_t mmap_addr;
161 char arg_string[32]; 159 char arg_string[32];
162 char *args[] = {"prog_name", arg_string}; 160 char *args[] = {"prog_name", arg_string};
163 161
164 NaClAllModulesInit(); 162 NaClAllModulesInit();
165 163
166 if (argc != 2) { 164 if (argc != 2) {
167 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n"); 165 NaClLog(LOG_FATAL, "Expected 1 argument: executable filename\n");
168 } 166 }
169 167
170 NaClAddSyscall(NACL_sys_test_syscall_1, TestSyscall); 168 NaClAddSyscall(NACL_sys_test_syscall_1, TestSyscall);
171 169
172 NaClFileNameForValgrind(argv[1]);
173 CHECK(GioMemoryFileSnapshotCtor(&gio_file, argv[1]));
174 CHECK(NaClAppCtor(&app)); 170 CHECK(NaClAppCtor(&app));
175 CHECK(NaClAppLoadFile((struct Gio *) &gio_file, &app) == LOAD_OK); 171 CHECK(NaClAppLoadFileFromFilename(&app, argv[1]) == LOAD_OK);
176 NaClAppInitialDescriptorHookup(&app); 172 NaClAppInitialDescriptorHookup(&app);
177 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK); 173 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK);
178 174
179 NaClSignalHandlerInit(); 175 NaClSignalHandlerInit();
180 NaClSignalHandlerAdd(TrapSignalHandler); 176 NaClSignalHandlerAdd(TrapSignalHandler);
181 177
182 /* 178 /*
183 * Allocate some space in untrusted address space. We pass the 179 * Allocate some space in untrusted address space. We pass the
184 * address to the guest program so that it can write a register 180 * address to the guest program so that it can write a register
185 * snapshot for us to compare against. 181 * snapshot for us to compare against.
(...skipping 11 matching lines...) Expand all
197 CHECK(!g_in_untrusted_code); 193 CHECK(!g_in_untrusted_code);
198 ASSERT_EQ(g_context_switch_count, (kNumberOfCallsToTest - 1) * 2); 194 ASSERT_EQ(g_context_switch_count, (kNumberOfCallsToTest - 1) * 2);
199 195
200 /* 196 /*
201 * Avoid calling exit() because it runs process-global destructors 197 * Avoid calling exit() because it runs process-global destructors
202 * which might break code that is running in our unjoined threads. 198 * which might break code that is running in our unjoined threads.
203 */ 199 */
204 NaClExit(0); 200 NaClExit(0);
205 return 0; 201 return 0;
206 } 202 }
OLDNEW
« no previous file with comments | « tests/minnacl/minimal_test_host.c ('k') | tests/signal_handler_single_step/step_test_host.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698