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 68% |
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..68fb7fadb06c2327d3f903e0019bf2f1aa68c935 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,16 +5,15 @@ |
*/ |
/* |
- * Post-message based test for testing crash detection. |
+ * Post-message based test for simple rpc based access to sysconf result. |
*/ |
-#include <string> |
jvoung (off chromium)
2013/04/17 17:07:18
Why not #include <string> if you are still using s
bsy
2013/04/17 20:55:21
string is included on line 15
jvoung (off chromium)
2013/04/18 01:43:18
Isn't line 15 <cstring> instead of <string> ?
bsy
2013/04/18 03:25:06
you're right. moved to be after C headers.
|
#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> |
@@ -23,36 +22,13 @@ |
#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,17 +50,14 @@ 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) } |
}; |
if (message_data.is_string()) { |
std::string op_name(message_data.AsString()); |
+ std::string reply; |
jvoung (off chromium)
2013/04/17 17:07:18
Is this reply variable actually used, or is "sb" t
bsy
2013/04/17 20:55:21
Done.
|
size_t len; |
fprintf(stderr, "Searching for handler for request \"%s\".\n", |
@@ -128,7 +101,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(); |
} |