Home | History | Annotate | Download | only in nacl
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include <stdio.h>
      6 #if defined(OS_POSIX)
      7 #include <unistd.h>
      8 #elif defined(OS_WIN)
      9 #include <windows.h>
     10 #endif
     11 
     12 #define TELEMETRY 1
     13 
     14 #include "chrome/test/nacl/nacl_browsertest_util.h"
     15 
     16 namespace {
     17 
     18 // These tests fail on Linux ASAN bots: <http://crbug.com/161709>.
     19 #if defined(OS_LINUX) && defined(ADDRESS_SANITIZER)
     20 #define MAYBE_SimpleLoad DISABLED_SimpleLoad
     21 #define MAYBE_ExitStatus0 DISABLED_ExitStatus0
     22 #define MAYBE_ExitStatus254 DISABLED_ExitStatus254
     23 #define MAYBE_ExitStatusNeg2 DISABLED_ExitStatusNeg2
     24 #define MAYBE_PPAPICore DISABLED_PPAPICore
     25 #define MAYBE_ProgressEvents DISABLED_ProgressEvents
     26 #define MAYBE_PnaclMimeType DISABLED_PnaclMimeType
     27 #define MAYBE_CrossOriginCORS DISABLED_CrossOriginCORS
     28 #define MAYBE_CrossOriginFail DISABLED_CrossOriginFail
     29 #define MAYBE_SameOriginCookie DISABLED_SameOriginCookie
     30 #define MAYBE_CORSNoCookie DISABLED_CORSNoCookie
     31 #define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln
     32 #else
     33 #define MAYBE_SimpleLoad SimpleLoad
     34 #define MAYBE_ExitStatus0 ExitStatus0
     35 #define MAYBE_ExitStatus254 ExitStatus254
     36 #define MAYBE_ExitStatusNeg2 ExitStatusNeg2
     37 #define MAYBE_PPAPICore PPAPICore
     38 #define MAYBE_ProgressEvents ProgressEvents
     39 #define MAYBE_PnaclMimeType PnaclMimeType
     40 #define MAYBE_CrossOriginCORS CrossOriginCORS
     41 #define MAYBE_CrossOriginFail CrossOriginFail
     42 #define MAYBE_SameOriginCookie SameOriginCookie
     43 #define MAYBE_CORSNoCookie CORSNoCookie
     44 # if defined(OS_WIN)
     45 #  define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln
     46 # else
     47 #  define MAYBE_SysconfNprocessorsOnln SysconfNprocessorsOnln
     48 # endif
     49 #endif
     50 
     51 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_SimpleLoad, {
     52   RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html"));
     53 })
     54 
     55 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclWithOldCache,
     56                        MAYBE_PNACL(SimpleLoad)) {
     57   RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html"));
     58 }
     59 
     60 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclWithOldCache,
     61                        MAYBE_PNACL(PnaclErrorHandling)) {
     62   RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html"));
     63 }
     64 
     65 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_ExitStatus0, {
     66   RunNaClIntegrationTest(FILE_PATH_LITERAL(
     67       "pm_exit_status_test.html?trigger=exit0&expected_exit=0"));
     68 })
     69 
     70 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_ExitStatus254, {
     71   RunNaClIntegrationTest(FILE_PATH_LITERAL(
     72       "pm_exit_status_test.html?trigger=exit254&expected_exit=254"));
     73 })
     74 
     75 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_ExitStatusNeg2, {
     76   RunNaClIntegrationTest(FILE_PATH_LITERAL(
     77       "pm_exit_status_test.html?trigger=exitneg2&expected_exit=254"));
     78 })
     79 
     80 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_PPAPICore, {
     81   RunNaClIntegrationTest(FILE_PATH_LITERAL("ppapi_ppb_core.html"));
     82 })
     83 
     84 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_ProgressEvents, {
     85   RunNaClIntegrationTest(FILE_PATH_LITERAL("ppapi_progress_events.html"));
     86 })
     87 
     88 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_PnaclMimeType, {
     89   RunLoadTest(FILE_PATH_LITERAL("pnacl_mime_type.html"));
     90 })
     91 
     92 // Some versions of Visual Studio does not like preprocessor
     93 // conditionals inside the argument of a macro, so we put the
     94 // conditionals on a helper function.  We are already in an anonymous
     95 // namespace, so the name of the helper is not visible in external
     96 // scope.
     97 #if defined(OS_POSIX)
     98 base::FilePath::StringType NumberOfCoresAsFilePathString() {
     99   char string_rep[23];
    100   long nprocessors = sysconf(_SC_NPROCESSORS_ONLN);
    101 #if TELEMETRY
    102   fprintf(stderr, "browser says nprocessors = %ld\n", nprocessors);
    103   fflush(NULL);
    104 #endif
    105   snprintf(string_rep, sizeof string_rep, "%ld", nprocessors);
    106   return string_rep;
    107 }
    108 #elif defined(OS_WIN)
    109 base::FilePath::StringType NumberOfCoresAsFilePathString() {
    110   wchar_t string_rep[23];
    111   SYSTEM_INFO system_info;
    112   GetSystemInfo(&system_info);
    113 #if TELEMETRY
    114   fprintf(stderr, "browser says nprocessors = %d\n",
    115           system_info.dwNumberOfProcessors);
    116   fflush(NULL);
    117 #endif
    118   _snwprintf_s(string_rep, sizeof string_rep / sizeof string_rep[0], _TRUNCATE,
    119                L"%u", system_info.dwNumberOfProcessors);
    120   return string_rep;
    121 }
    122 #endif
    123 
    124 #if TELEMETRY
    125 static void PathTelemetry(base::FilePath::StringType const &path) {
    126 # if defined(OS_WIN)
    127     fwprintf(stderr, L"path = %s\n", path.c_str());
    128 # else
    129     fprintf(stderr, "path = %s\n", path.c_str());
    130 # endif
    131     fflush(NULL);
    132 }
    133 #else
    134 static void PathTelemetry(base::FilePath::StringType const &path) {
    135   (void) path;
    136 }
    137 #endif
    138 
    139 NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_SysconfNprocessorsOnln, {
    140     base::FilePath::StringType path =
    141       FILE_PATH_LITERAL("sysconf_nprocessors_onln_test.html?cpu_count=");
    142     path = path + NumberOfCoresAsFilePathString();
    143     PathTelemetry(path);
    144     RunNaClIntegrationTest(path);
    145 })
    146 
    147 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, MAYBE_CrossOriginCORS) {
    148   RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors.html"));
    149 }
    150 
    151 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, MAYBE_CrossOriginFail) {
    152   RunLoadTest(FILE_PATH_LITERAL("cross_origin/fail.html"));
    153 }
    154 
    155 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, MAYBE_SameOriginCookie) {
    156   RunLoadTest(FILE_PATH_LITERAL("cross_origin/same_origin_cookie.html"));
    157 }
    158 
    159 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, MAYBE_CORSNoCookie) {
    160   RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors_no_cookie.html"));
    161 }
    162 
    163 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    164                        MAYBE_PNACL(PnaclErrorHandling)) {
    165   RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html"));
    166 }
    167 
    168 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    169                        MAYBE_PNACL(PnaclNMFOptionsO0)) {
    170   RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0"));
    171 }
    172 
    173 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    174                        MAYBE_PNACL(PnaclNMFOptionsO2)) {
    175   RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_2"));
    176 }
    177 
    178 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    179                        MAYBE_PNACL(PnaclNMFOptionsOlarge)) {
    180   RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_large"));
    181 }
    182 
    183 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    184                        MAYBE_PNACL(PnaclDyncodeSyscallDisabled)) {
    185   RunNaClIntegrationTest(FILE_PATH_LITERAL(
    186       "pnacl_dyncode_syscall_disabled.html"));
    187 }
    188 
    189 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
    190                        MAYBE_PNACL(PnaclExceptionHandlingDisabled)) {
    191   RunNaClIntegrationTest(FILE_PATH_LITERAL(
    192       "pnacl_exception_handling_disabled.html"));
    193 }
    194 
    195 }  // namespace
    196