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 "chrome/test/base/uma_histogram_helper.h" | 5 #include "chrome/test/base/uma_histogram_helper.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 "native_client/src/trusted/service_runtime/nacl_error_code.h" | 8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
8 #include "ppapi/c/private/ppb_nacl_private.h" | 9 #include "ppapi/c/private/ppb_nacl_private.h" |
9 | 10 |
10 namespace { | 11 namespace { |
11 | 12 |
12 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { | 13 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { |
13 // Load a NaCl module to generate UMA data. | 14 // Load a NaCl module to generate UMA data. |
14 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); | 15 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); |
15 | 16 |
16 // Make sure histograms from child processes have been accumulated in the | 17 // Make sure histograms from child processes have been accumulated in the |
17 // browser brocess. | 18 // browser brocess. |
18 UMAHistogramHelper histograms; | 19 UMAHistogramHelper histograms; |
19 histograms.Fetch(); | 20 histograms.Fetch(); |
20 | 21 |
21 // Did the plugin report success? | 22 // Did the plugin report success? |
22 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", | 23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", |
23 PP_NACL_ERROR_LOAD_SUCCESS, 1); | 24 PP_NACL_ERROR_LOAD_SUCCESS, 1); |
24 | 25 |
25 // Did the sel_ldr report success? | 26 // Did the sel_ldr report success? |
26 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", | 27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", |
27 LOAD_OK, 1); | 28 LOAD_OK, 1); |
28 | 29 |
| 30 // Check validation cache usage: |
| 31 // For the open-web, only the IRT is considered a "safe" and |
| 32 // identity-cachable file. The nexes and .so files are not. |
| 33 // Should have one cache query for the IRT. |
| 34 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
| 35 nacl::NaClBrowser::CACHE_MISS, 1); |
| 36 // TOTAL should then be 1 query so far. |
| 37 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 1); |
| 38 // Should have received a cache setting afterwards for IRT. |
| 39 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 1); |
| 40 |
29 // Make sure we have other important histograms. | 41 // Make sure we have other important histograms. |
30 if (!IsAPnaclTest()) { | 42 if (!IsAPnaclTest()) { |
31 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1); | 43 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1); |
32 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.Total", 1); | 44 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.Total", 1); |
33 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); | 45 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); |
34 histograms.ExpectTotalCount("NaCl.Perf.Size.Nexe", 1); | 46 histograms.ExpectTotalCount("NaCl.Perf.Size.Nexe", 1); |
35 } else { | 47 } else { |
36 histograms.ExpectTotalCount("NaCl.Options.PNaCl.OptLevel", 1); | 48 histograms.ExpectTotalCount("NaCl.Options.PNaCl.OptLevel", 1); |
37 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); | 49 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); |
38 histograms.ExpectTotalCount("NaCl.Perf.Size.Pexe", 1); | 50 histograms.ExpectTotalCount("NaCl.Perf.Size.Pexe", 1); |
39 histograms.ExpectTotalCount("NaCl.Perf.Size.PNaClTranslatedNexe", 1); | 51 histograms.ExpectTotalCount("NaCl.Perf.Size.PNaClTranslatedNexe", 1); |
40 histograms.ExpectTotalCount("NaCl.Perf.Size.PexeNexeSizePct", 1); | 52 histograms.ExpectTotalCount("NaCl.Perf.Size.PexeNexeSizePct", 1); |
41 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadCompiler", 1); | 53 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadCompiler", 1); |
42 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadLinker", 1); | 54 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadLinker", 1); |
43 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileTime", 1); | 55 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileTime", 1); |
44 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileKBPerSec", 1); | 56 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileKBPerSec", 1); |
45 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LinkTime", 1); | 57 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LinkTime", 1); |
46 histograms.ExpectTotalCount( | 58 histograms.ExpectTotalCount( |
47 "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", 1); | 59 "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", 1); |
48 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", 1); | 60 histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", 1); |
49 histograms.ExpectTotalCount( | 61 histograms.ExpectTotalCount( |
50 "NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", 1); | 62 "NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", 1); |
51 histograms.ExpectTotalCount("NaCl.Perf.PNaClCache.IsHit", 1); | 63 histograms.ExpectTotalCount("NaCl.Perf.PNaClCache.IsHit", 1); |
52 } | 64 } |
53 }) | 65 }) |
54 | 66 |
| 67 class NaClBrowserTestVcacheExtension: |
| 68 public NaClBrowserTestNewlibExtension { |
| 69 public: |
| 70 virtual base::FilePath::StringType Variant() OVERRIDE { |
| 71 return FILE_PATH_LITERAL("extension_vcache_test/newlib"); |
| 72 } |
| 73 }; |
| 74 |
| 75 IN_PROC_BROWSER_TEST_F(NaClBrowserTestVcacheExtension, |
| 76 ValidationCacheOfMainNexe) { |
| 77 // Hardcoded extension AppID that corresponds to the hardcoded |
| 78 // public key in the manifest.json file. We need to load the extension |
| 79 // nexe from the same origin, so we can't just try to load the extension |
| 80 // nexe as a mime-type handler from a non-extension URL. |
| 81 base::FilePath::StringType full_url = |
| 82 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") |
| 83 FILE_PATH_LITERAL("extension_validation_cache.html"); |
| 84 RunNaClIntegrationTest(full_url, true); |
| 85 |
| 86 // Make sure histograms from child processes have been accumulated in the |
| 87 // browser brocess. |
| 88 UMAHistogramHelper histograms; |
| 89 histograms.Fetch(); |
| 90 // Should have received 2 validation queries (one for IRT and one for NEXE), |
| 91 // and responded with a miss. |
| 92 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
| 93 nacl::NaClBrowser::CACHE_MISS, 2); |
| 94 // TOTAL should then be 2 queries so far. |
| 95 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2); |
| 96 // Should have received a cache setting afterwards for IRT and nexe. |
| 97 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", |
| 98 nacl::NaClBrowser::CACHE_HIT, 2); |
| 99 |
| 100 // Load it again to hit the cache. |
| 101 RunNaClIntegrationTest(full_url, true); |
| 102 histograms.Fetch(); |
| 103 // Should have received 2 more validation queries later (IRT and NEXE), |
| 104 // and responded with a hit. |
| 105 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
| 106 nacl::NaClBrowser::CACHE_HIT, 2); |
| 107 // TOTAL should then be 4 queries now. |
| 108 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); |
| 109 // Still only 2 settings. |
| 110 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); |
| 111 } |
| 112 |
55 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) | 113 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) |
56 // Test validation failures and crashes. | 114 // Test validation failures and crashes. |
57 | 115 |
58 } // namespace | 116 } // namespace |
OLD | NEW |