Chromium Code Reviews| Index: chrome/test/data/nacl/irt_exception/irt_exception_test.cc |
| diff --git a/chrome/test/data/nacl/irt_exception/irt_exception_test.cc b/chrome/test/data/nacl/irt_exception/irt_exception_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e037d8c760a00b3e9929a4fd8ab5eb22fc0240fc |
| --- /dev/null |
| +++ b/chrome/test/data/nacl/irt_exception/irt_exception_test.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <setjmp.h> |
| +#include <unistd.h> |
|
Mark Seaborn
2014/04/24 23:39:28
Nit: I *think* you don't use anything from unistd.
Junichi Uekawa
2014/04/25 01:06:10
I think we I should have included stdio.h instead
|
| + |
| +#include "native_client/src/include/nacl/nacl_exception.h" |
| +#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h" |
| + |
| +namespace { |
| + |
| +jmp_buf g_jmp_buf; |
| + |
| +void MyNaClExceptionHandler(struct NaClExceptionContext* context) { |
| + printf("--- MyNaClExceptionHandler\n"); |
| + longjmp(g_jmp_buf, 1); |
| +} |
| + |
| +void CrashViaSignalHandler() { |
| + printf("--- CrashViaSignalHandler\n"); |
| + |
| + int retval = nacl_exception_set_handler(MyNaClExceptionHandler); |
| + if (retval != 0) { |
| + printf("Unexpected return value from nacl_exception_set_handler: %d\n", |
| + retval); |
| + TEST_FAILED; |
| + return; |
| + } |
| + |
| + if (setjmp(g_jmp_buf)) { |
| + printf("Returned via longjmp\n"); |
| + TEST_PASSED; |
| + return; |
| + } |
| + printf("Going to crash\n"); |
| + __builtin_trap(); |
| +} |
| + |
| +} // namespace |
| + |
| +void SetupTests() { |
| + RegisterTest("CrashViaSignalHandler", CrashViaSignalHandler); |
| +} |
| + |
| +void SetupPluginInterfaces() {} |