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

Unified Diff: ppapi/native_client/tests/ppapi_browser/crash/ppapi_crash_off_main_thread.cc

Issue 7741036: NaCl PPAPI Proxy: wrap up with crash detection. Clean-up handling code to skip remote shutdown ca... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/tests/ppapi_browser/crash/ppapi_crash_off_main_thread.cc
===================================================================
--- ppapi/native_client/tests/ppapi_browser/crash/ppapi_crash_off_main_thread.cc (revision 0)
+++ ppapi/native_client/tests/ppapi_browser/crash/ppapi_crash_off_main_thread.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Native Client Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Test that we handle crashes on threads other than main.
+
+#include <pthread.h>
+#include <stdio.h>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "native_client/tests/ppapi_test_lib/test_interface.h"
+
+namespace {
+
+void* CrashOffMainThreadFunction(void* thread_arg) {
+ printf("--- CrashOffMainThreadFunction\n");
+ usleep(1000); // Try to wait until PPP_Messaging::HandleMessage returns.
+ CRASH;
+ return NULL;
+}
+
+// Depending on how the detached thread is scheduled, this will either crash
+// during PPP_Messaging::HandleMessage or after it and before the next PPP call.
+// If a crash occurs within a PPP call, it returns an RPC error.
+// If a crash occurs between PPP calls, the next call will return an RPC error.
+void CrashOffMainThread() {
+ printf("--- CrashOffMainThread\n");
+ pthread_t tid;
+ pthread_create(&tid, NULL /*attr*/, CrashOffMainThreadFunction, NULL);
+ pthread_detach(tid);
+}
+
+// This will allow us to ping the nexe to detect a crash that occured
+// while the main thread was waiting for the next PPP call.
+void Ping() {
+ LOG_TO_BROWSER("ping received");
+}
+
+} // namespace
+
+void SetupTests() {
+ RegisterTest("CrashOffMainThread", CrashOffMainThread);
+ RegisterTest("Ping", Ping);
+}
+
+void SetupPluginInterfaces() {
+ // none
+}

Powered by Google App Engine
This is Rietveld 408576698