Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / nacl / irt_exception / irt_exception_test.cc
blobd333421a0cc1c7cf252e4fc84de42fdfea04f29f
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <setjmp.h>
6 #include <stdio.h>
8 #include "native_client/src/include/nacl/nacl_exception.h"
9 #include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
11 namespace {
13 jmp_buf g_jmp_buf;
15 void MyNaClExceptionHandler(struct NaClExceptionContext* context) {
16 printf("--- MyNaClExceptionHandler\n");
17 longjmp(g_jmp_buf, 1);
20 void CrashViaSignalHandler() {
21 printf("--- CrashViaSignalHandler\n");
23 int retval = nacl_exception_set_handler(MyNaClExceptionHandler);
24 if (retval != 0) {
25 printf("Unexpected return value from nacl_exception_set_handler: %d\n",
26 retval);
27 TEST_FAILED;
28 return;
31 if (setjmp(g_jmp_buf)) {
32 printf("Returned via longjmp\n");
33 TEST_PASSED;
34 return;
36 printf("Going to crash\n");
37 __builtin_trap();
40 } // namespace
42 void SetupTests() {
43 RegisterTest("CrashViaSignalHandler", CrashViaSignalHandler);
46 void SetupPluginInterfaces() {}