#include <stdio.h>
#include "native_client/src/include/nacl_string.h"
#include "native_client/src/trusted/plugin/nexe_arch.h"
#include "native_client/src/trusted/plugin/dylib_unittest.h"
bool TestGetNexeArch(DylibHandle dl_handle, const nacl::string& expected_isa) {
typedef const char* (*GetSandboxISAFunc)();
GetSandboxISAFunc get_sandbox_isa_sym = reinterpret_cast<GetSandboxISAFunc>(
GetSymbolHandle(dl_handle, "NaClPluginGetSandboxISA"));
if (get_sandbox_isa_sym == NULL)
return false;
nacl::string sandbox_isa(get_sandbox_isa_sym());
if (sandbox_isa != expected_isa) {
fprintf(stderr, "TestGetNexeArch ERROR: expeced ISA %s, got %s\n",
expected_isa.c_str(), sandbox_isa.c_str());
return false;
}
return true;
}
int main(int argc, char** argv) {
DylibHandle dl_handle = NULL;
if (3 != argc) {
fprintf(stderr, "Usage: %s <plugin_name> <ISA_string>\n", argv[0]);
return 1;
}
dl_handle = DylibOpen(argv[1]);
if (NULL == dl_handle) {
fprintf(stderr, "Couldn't open: %s\n", argv[1]);
return 1;
}
bool success = TestGetNexeArch(dl_handle, argv[2]);
if (!DylibClose(dl_handle)) {
fprintf(stderr, "Couldn't close: %s\n", argv[1]);
return 1;
}
if (success) {
printf("PASS\n");
return 0;
} else {
printf("FAIL\n");
return 1;
}
}