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

Unified Diff: chrome/test/data/nacl/sysconf_nprocessors_onln/sysconf_nprocessors_onln_test.cc

Issue 14238013: Set up NaClChromeMainArgs number_of_cores member so apps can size threadpools appropriately (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR fb Created 7 years, 8 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: chrome/test/data/nacl/sysconf_nprocessors_onln/sysconf_nprocessors_onln_test.cc
diff --git a/chrome/test/data/nacl/exit_status/pm_exit_status_test.cc b/chrome/test/data/nacl/sysconf_nprocessors_onln/sysconf_nprocessors_onln_test.cc
similarity index 69%
copy from chrome/test/data/nacl/exit_status/pm_exit_status_test.cc
copy to chrome/test/data/nacl/sysconf_nprocessors_onln/sysconf_nprocessors_onln_test.cc
index d1289cf060f55021a9d4af5f4c064f8697cd4594..86785ae9c543849087f5637a03ce2621c2e11f2b 100644
--- a/chrome/test/data/nacl/exit_status/pm_exit_status_test.cc
+++ b/chrome/test/data/nacl/sysconf_nprocessors_onln/sysconf_nprocessors_onln_test.cc
@@ -5,54 +5,32 @@
*/
/*
- * Post-message based test for testing crash detection.
+ * Post-message based test for simple rpc based access to sysconf result.
*/
-#include <string>
#include <assert.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <inttypes.h>
-#include <sys/fcntl.h>
#include <string.h>
+#include <sys/fcntl.h>
#include <unistd.h>
#include <sys/nacl_syscalls.h>
+#include <string>
+
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
-void Initialize(const pp::Var& message_data, std::string* out) {
- *out = "hello world";
-}
-
-void RunExit0(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(0);
-}
-
-void RunExit7(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(7);
-}
-
-void RunExit254(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(254);
-}
+void NumProcessors(const pp::Var& message_data, std::string* sb) {
+ int num_cores;
+ char string_rep[16];
-void RunExitNeg2(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(-2);
+ num_cores = sysconf(_SC_NPROCESSORS_ONLN);
+ snprintf(string_rep, sizeof string_rep, "%d", num_cores);
+ *sb = string_rep;
}
struct PostMessageHandlerDesc {
@@ -74,11 +52,7 @@ class MyInstance : public pp::Instance {
// reply string -- essentially treating this as a string-based RPC.
void MyInstance::HandleMessage(const pp::Var& message_data) {
static struct PostMessageHandlerDesc kMsgHandlers[] = {
- { "init", Initialize },
- { "exit0", RunExit0 },
- { "exit7", RunExit7 },
- { "exit254", RunExit254 },
- { "exitneg2", RunExitNeg2 },
+ { "nprocessors", NumProcessors },
{ reinterpret_cast<char const *>(NULL),
reinterpret_cast<void (*)(const pp::Var&, std::string*)>(NULL) }
};
@@ -128,7 +102,6 @@ namespace pp {
// Factory function for your specialization of the Module object.
Module* CreateModule() {
- printf("hello world from CreateModule\n"); fflush(NULL);
return new MyModule();
}

Powered by Google App Engine
This is Rietveld 408576698