OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 // Unit tests for ppGoogleNaClPlugin | |
6 | |
7 #include <stdio.h> | |
8 | |
9 #include "native_client/src/include/nacl_string.h" | |
10 #include "native_client/src/trusted/plugin/nexe_arch.h" | |
11 #include "native_client/src/trusted/plugin/dylib_unittest.h" | |
12 | |
13 // Verify that the ISA string returned by the plugin is the correct one for | |
14 // this platform. | |
15 bool TestGetNexeArch(DylibHandle dl_handle, const nacl::string& expected_isa) { | |
16 typedef const char* (*GetSandboxISAFunc)(); | |
17 GetSandboxISAFunc get_sandbox_isa_sym = reinterpret_cast<GetSandboxISAFunc>( | |
18 GetSymbolHandle(dl_handle, "NaClPluginGetSandboxISA")); | |
19 if (get_sandbox_isa_sym == NULL) | |
20 return false; | |
21 nacl::string sandbox_isa(get_sandbox_isa_sym()); | |
22 if (sandbox_isa != expected_isa) { | |
23 fprintf(stderr, "TestGetNexeArch ERROR: expeced ISA %s, got %s\n", | |
24 expected_isa.c_str(), sandbox_isa.c_str()); | |
25 return false; | |
26 } | |
27 return true; | |
28 } | |
29 | |
30 int main(int argc, char** argv) { | |
31 DylibHandle dl_handle = NULL; | |
32 | |
33 if (3 != argc) { | |
34 fprintf(stderr, "Usage: %s <plugin_name> <ISA_string>\n", argv[0]); | |
35 return 1; | |
36 } | |
37 // Test opening the dynamic library | |
38 dl_handle = DylibOpen(argv[1]); | |
39 if (NULL == dl_handle) { | |
40 fprintf(stderr, "Couldn't open: %s\n", argv[1]); | |
41 return 1; | |
42 } | |
43 | |
44 // Exercise some bare minimum functionality for PPAPI plugins. | |
45 bool success = TestGetNexeArch(dl_handle, argv[2]); | |
46 | |
47 // Test closing the dynamic library | |
48 if (!DylibClose(dl_handle)) { | |
49 fprintf(stderr, "Couldn't close: %s\n", argv[1]); | |
50 return 1; | |
51 } | |
52 | |
53 if (success) { | |
54 printf("PASS\n"); | |
55 return 0; | |
56 } else { | |
57 printf("FAIL\n"); | |
58 return 1; | |
59 } | |
60 } | |
OLD | NEW |