Chromium Code Reviews| Index: tests/exception_test/exception_test.c |
| diff --git a/tests/exception_test/exception_test.c b/tests/exception_test/exception_test.c |
| index b00d3a40a7e51a235b88777619ec269947818276..48ef20a887fa782192de6066eef752f692c0fc6d 100644 |
| --- a/tests/exception_test/exception_test.c |
| +++ b/tests/exception_test/exception_test.c |
| @@ -13,6 +13,10 @@ |
| #include <stdlib.h> |
| #include <string.h> |
| +#if !TESTS_USE_IRT && NONSFI_MODE |
| +#include "native_client/src/nonsfi/linux/irt_exception_handling.h" |
| +#endif |
| + |
| #include "native_client/src/include/elf_constants.h" |
| #include "native_client/src/include/nacl/nacl_exception.h" |
| #include "native_client/src/trusted/service_runtime/include/sys/nacl_syscalls.h" |
| @@ -182,8 +186,16 @@ void exception_handler_wrapped(struct NaClSignalContext *entry_regs) { |
| assert(frame_base % STACK_ALIGNMENT == 0); |
| char *frame_top = (char *) (frame_base + kArgSizeOnStack + |
| sizeof(struct CombinedContext)); |
| - /* Check that no more than the stack alignment size is wasted. */ |
| - assert(stack_top - STACK_ALIGNMENT < frame_top); |
| + if (NONSFI_MODE) { |
| + /* |
| + * Non-SFI mode exception stack will have ucontext_t and |
| + * siginfo_t, which would be anywhere from 400 bytes to 1.5k |
| + */ |
| + assert(stack_top - 1500 < frame_top); |
| + } else { |
| + /* Check that no more than the stack alignment size is wasted. */ |
| + assert(stack_top - STACK_ALIGNMENT < frame_top); |
| + } |
| assert(frame_top <= stack_top); |
| #if defined(__x86_64__) |
| @@ -200,12 +212,15 @@ void test_exception_stack_with_size(char *stack, size_t stack_size) { |
| printf("failed to set exception handler\n"); |
| exit(4); |
| } |
| +#if !NONSFI_MODE |
| + /* TODO(uekawa): Implement set_stack for Non-SFI mode. */ |
| if (0 != nacl_exception_set_stack(stack, stack_size)) { |
| printf("failed to set alt stack\n"); |
| exit(5); |
| } |
| g_registered_stack = stack; |
| g_registered_stack_size = stack_size; |
| +#endif |
| char crash_stack[0x1000]; |
| RegsFillTestValues(&g_regs_at_crash, /* seed= */ 0); |
| @@ -314,7 +329,7 @@ void test_catching_various_exception_types(void) { |
| exit(1); |
| } |
| -#if defined(__i386__) || defined(__x86_64__) |
| +#if !NONSFI_MODE && (defined(__i386__) || defined(__x86_64__)) |
| printf("Testing hlt...\n"); |
| if (!setjmp(g_jmp_buf)) { |
| __asm__("hlt"); |
| @@ -340,7 +355,7 @@ void test_catching_various_exception_types(void) { |
| } |
| -#if defined(__i386__) || defined(__x86_64__) |
| +#if !NONSFI_MODE && (defined(__i386__) || defined(__x86_64__)) |
| int get_x86_direction_flag(void); |
| @@ -396,15 +411,21 @@ void run_test(const char *test_name, void (*test_func)(void)) { |
| int TestMain(void) { |
| RUN_TEST(test_exceptions_minimally); |
| - RUN_TEST(test_exception_stack_alignments); |
| - RUN_TEST(test_getting_previous_handler); |
| - RUN_TEST(test_invalid_handlers); |
| + if (!NONSFI_MODE) { |
| + /* TODO(uekawa): Implement set_stack for Non-SFI mode. */ |
| + RUN_TEST(test_exception_stack_alignments); |
| + /* NACL_SYSCALL not supported on nonsfi mode */ |
| + RUN_TEST(test_getting_previous_handler); |
| + /* Those handlers are not invalid in NonSFI NaCl. */ |
| + RUN_TEST(test_invalid_handlers); |
| + } |
| /* pthread_join() is broken under qemu-arm. */ |
| if (getenv("UNDER_QEMU_ARM") == NULL) |
| RUN_TEST(test_exceptions_on_non_main_thread); |
| RUN_TEST(test_catching_various_exception_types); |
| -#if defined(__i386__) || defined(__x86_64__) |
| +#if !NONSFI_MODE && (defined(__i386__) || defined(__x86_64__)) |
| + /* TODO(uekawa): Implement for Non-SFI mode. */ |
| RUN_TEST(test_get_x86_direction_flag); |
| RUN_TEST(test_unsetting_x86_direction_flag); |
| #endif |
| @@ -414,5 +435,12 @@ int TestMain(void) { |
| } |
| int main(void) { |
| +#if !TESTS_USE_IRT && NONSFI_MODE |
| + /* |
| + * In Non-SFI mode Non-IRT loading version does not initialize |
| + * signal handler. |
| + */ |
| + nonsfi_initialize_signal_handler(); |
|
Junichi Uekawa
2014/09/29 07:32:30
I couldn't find a reasonable place to do initializ
|
| +#endif |
| return RunTests(TestMain); |
| } |