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

Unified Diff: chrome/test/data/nacl/manifest_file/irt_manifest_file_test.cc

Issue 303683005: Add failure case for manifest file testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/manifest_file/irt_manifest_file_test.cc
diff --git a/chrome/test/data/nacl/manifest_file/irt_manifest_file_test.cc b/chrome/test/data/nacl/manifest_file/irt_manifest_file_test.cc
index fae14b31d8e72b1f816df85114dd42ee4ad3e7d2..ab1f352d1d4d2c55e1c74914ab518ecab17ac549 100644
--- a/chrome/test/data/nacl/manifest_file/irt_manifest_file_test.cc
+++ b/chrome/test/data/nacl/manifest_file/irt_manifest_file_test.cc
@@ -11,8 +11,9 @@
#include <stdio.h>
#include <string.h>
-#include <string>
#include <sstream>
+#include <string>
+#include <vector>
#include "native_client/src/untrusted/irt/irt.h"
#include "native_client/src/untrusted/nacl/nacl_irt.h"
@@ -20,30 +21,30 @@
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/var_array.h"
#include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h"
-std::string str;
-void load_manifest(TYPE_nacl_irt_query *query_func) {
+std::vector<std::string> result;
+
+std::string LoadManifestSuccess(TYPE_nacl_irt_query *query_func) {
struct nacl_irt_resource_open nacl_irt_resource_open;
if (sizeof(nacl_irt_resource_open) !=
(*query_func)(
NACL_IRT_RESOURCE_OPEN_v0_1,
&nacl_irt_resource_open,
sizeof(nacl_irt_resource_open))) {
- str = "irt manifest api not found";
- return;
+ return "irt manifest api not found";
}
int desc;
int error;
error = nacl_irt_resource_open.open_resource("test_file", &desc);
if (0 != error) {
- str = "Can't open file";
printf("Can't open file, error=%d", error);
- return;
+ return "Can't open file";
}
- str = "File Contents:\n";
+ std::string str = "File Contents:\n";
char buffer[4096];
int len;
@@ -81,7 +82,43 @@ void load_manifest(TYPE_nacl_irt_query *query_func) {
str += buffer;
}
printf("file loaded: %s\n", str.c_str());
- return;
+ return str;
+}
+
+std::string LoadManifestNonExistentEntry(
+ TYPE_nacl_irt_query *query_func) {
+ struct nacl_irt_resource_open nacl_irt_resource_open;
+ if (sizeof(nacl_irt_resource_open) !=
+ (*query_func)(
+ NACL_IRT_RESOURCE_OPEN_v0_1,
+ &nacl_irt_resource_open,
+ sizeof(nacl_irt_resource_open))) {
+ return "irt manifest api not found";
+ }
+
+ int desc;
+ int error = nacl_irt_resource_open.open_resource("non_existent_entry", &desc);
+ char buf[80];
+ snprintf(buf, sizeof(buf), "open_resource() result: %d", error);
Mark Seaborn 2014/05/29 16:55:48 Rather than always formatting the numeric errno me
hidehiko 2014/05/30 04:49:58 Done.
+ return std::string(buf);
+}
+
+std::string LoadManifestNonExistentFile(
+ TYPE_nacl_irt_query *query_func) {
+ struct nacl_irt_resource_open nacl_irt_resource_open;
+ if (sizeof(nacl_irt_resource_open) !=
+ (*query_func)(
+ NACL_IRT_RESOURCE_OPEN_v0_1,
+ &nacl_irt_resource_open,
+ sizeof(nacl_irt_resource_open))) {
+ return "irt manifest api not found";
+ }
+
+ int desc;
+ int error = nacl_irt_resource_open.open_resource("dummy_test_file", &desc);
+ char buf[80];
+ snprintf(buf, sizeof(buf), "open_resource() result: %d", error);
Mark Seaborn 2014/05/29 16:55:48 Same here
hidehiko 2014/05/30 04:49:58 Done.
+ return std::string(buf);
}
class TestInstance : public pp::Instance {
@@ -95,7 +132,10 @@ class TestInstance : public pp::Instance {
if (var_message.AsString() != "hello") {
return;
}
- pp::Var reply = pp::Var(str);
+ pp::VarArray reply = pp::VarArray();
+ for (size_t i = 0; i < result.size(); ++i) {
+ reply.Set(i, pp::Var(result[i]));
+ }
PostMessage(reply);
}
};
@@ -117,7 +157,8 @@ Module* CreateModule() {
}
int main() {
- load_manifest(&__nacl_irt_query);
+ result.push_back(LoadManifestSuccess(&__nacl_irt_query));
+ result.push_back(LoadManifestNonExistentEntry(&__nacl_irt_query));
+ result.push_back(LoadManifestNonExistentFile(&__nacl_irt_query));
return PpapiPluginMain();
}
-

Powered by Google App Engine
This is Rietveld 408576698