1 // Copyright 2013 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 // Test that we handle crashes on threads other than main.
11 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
16 void* CrashOffMainThreadFunction(void* thread_arg
) {
17 printf("--- CrashOffMainThreadFunction\n");
18 usleep(1000); // Try to wait until PPP_Messaging::HandleMessage returns.
23 // Depending on how the detached thread is scheduled, this will either crash
24 // during PPP_Messaging::HandleMessage or after it and before the next PPP call.
25 // If a crash occurs within a PPP call, it returns an RPC error.
26 // If a crash occurs between PPP calls, the next call will return an RPC error.
27 void CrashOffMainThread() {
28 printf("--- CrashOffMainThread\n");
30 pthread_create(&tid
, NULL
/*attr*/, CrashOffMainThreadFunction
, NULL
);
34 // This will allow us to ping the nexe to detect a crash that occured
35 // while the main thread was waiting for the next PPP call.
37 LOG_TO_BROWSER("ping received");
43 RegisterTest("CrashOffMainThread", CrashOffMainThread
);
44 RegisterTest("Ping", Ping
);
47 void SetupPluginInterfaces() {