OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/histogram_tester.h" | 5 #include "base/test/histogram_tester.h" |
6 #include "chrome/test/nacl/nacl_browsertest_util.h" | 6 #include "chrome/test/nacl/nacl_browsertest_util.h" |
7 #include "components/nacl/browser/nacl_browser.h" | 7 #include "components/nacl/browser/nacl_browser.h" |
8 #include "components/nacl/renderer/platform_info.h" | 8 #include "components/nacl/renderer/platform_info.h" |
9 #include "components/nacl/renderer/ppb_nacl_private.h" | 9 #include "components/nacl/renderer/ppb_nacl_private.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::HistogramTester histograms; | 189 base::HistogramTester histograms; |
190 // Hardcoded extension AppID that corresponds to the hardcoded | 190 // Hardcoded extension AppID that corresponds to the hardcoded |
191 // public key in the manifest.json file. We need to load the extension | 191 // public key in the manifest.json file. We need to load the extension |
192 // nexe from the same origin, so we can't just try to load the extension | 192 // nexe from the same origin, so we can't just try to load the extension |
193 // nexe as a mime-type handler from a non-extension URL. | 193 // nexe as a mime-type handler from a non-extension URL. |
194 base::FilePath::StringType full_url = | 194 base::FilePath::StringType full_url = |
195 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") | 195 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") |
196 FILE_PATH_LITERAL("extension_validation_cache.html"); | 196 FILE_PATH_LITERAL("extension_validation_cache.html"); |
197 RunNaClIntegrationTest(full_url, true); | 197 RunNaClIntegrationTest(full_url, true); |
198 | 198 |
199 // Should have received 9 validation queries, which respond with misses: | 199 // Should have received 9 (or 10 on arm) validation queries, which respond |
| 200 // with misses: |
200 // - the IRT | 201 // - the IRT |
201 // - ld.so (the initial nexe) | 202 // - ld.so (the initial nexe) |
| 203 // - elf_loader.nexe (arm only) |
202 // - main.nexe | 204 // - main.nexe |
203 // - libppapi_cpp.so | 205 // - libppapi_cpp.so |
204 // - libpthread.so.9b15f6a6 | 206 // - libpthread.so.9b15f6a6 |
205 // - libstdc++.so.6 | 207 // - libstdc++.so.6 |
206 // - libgcc_s.so.1 | 208 // - libgcc_s.so.1 |
207 // - libc.so.9b15f6a6 | 209 // - libc.so.9b15f6a6 |
208 // - libm.so.9b15f6a6 | 210 // - libm.so.9b15f6a6 |
| 211 #if defined(ARCH_CPU_ARM_FAMILY) |
| 212 const int num_expected_binaries = 10; |
| 213 #else |
| 214 const int num_expected_binaries = 9; |
| 215 #endif |
| 216 |
209 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 217 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
210 nacl::NaClBrowser::CACHE_MISS, 9); | 218 nacl::NaClBrowser::CACHE_MISS, |
211 // TOTAL should then be 9 queries so far. | 219 num_expected_binaries); |
212 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 9); | 220 // TOTAL should then be N queries so far. |
| 221 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", |
| 222 num_expected_binaries); |
213 // Should have received a cache setting afterwards for IRT and nexe. | 223 // Should have received a cache setting afterwards for IRT and nexe. |
214 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", | 224 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", |
215 nacl::NaClBrowser::CACHE_HIT, 9); | 225 nacl::NaClBrowser::CACHE_HIT, |
| 226 num_expected_binaries); |
216 | 227 |
217 // Load it again to hit the cache. | 228 // Load it again to hit the cache. |
218 RunNaClIntegrationTest(full_url, true); | 229 RunNaClIntegrationTest(full_url, true); |
219 // Should have received 9 more validation queries and responded with hits. | 230 // Should have received N more validation queries and responded with hits. |
220 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 231 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
221 nacl::NaClBrowser::CACHE_HIT, 9); | 232 nacl::NaClBrowser::CACHE_HIT, |
222 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 18); | 233 num_expected_binaries); |
223 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 9); | 234 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", |
| 235 2 * num_expected_binaries); |
| 236 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", |
| 237 num_expected_binaries); |
224 } | 238 } |
225 | 239 |
226 // Test that validation for the 2 PNaCl translator nexes can be cached. | 240 // Test that validation for the 2 PNaCl translator nexes can be cached. |
227 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, | 241 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
228 ValidationCacheOfTranslatorNexes) { | 242 ValidationCacheOfTranslatorNexes) { |
229 base::HistogramTester histograms; | 243 base::HistogramTester histograms; |
230 // Run a load test w/ one pexe cache identity. | 244 // Run a load test w/ one pexe cache identity. |
231 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); | 245 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); |
232 | 246 |
233 content::FetchHistogramsFromChildProcesses(); | 247 content::FetchHistogramsFromChildProcesses(); |
(...skipping 24 matching lines...) Expand all Loading... |
258 // No extra cache settings. | 272 // No extra cache settings. |
259 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", | 273 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
260 nacl::NaClBrowser::CACHE_HIT, 3); | 274 nacl::NaClBrowser::CACHE_HIT, 3); |
261 } | 275 } |
262 | 276 |
263 | 277 |
264 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) | 278 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) |
265 // Test validation failures and crashes. | 279 // Test validation failures and crashes. |
266 | 280 |
267 } // namespace | 281 } // namespace |
OLD | NEW |