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 "components/nacl/browser/nacl_browser.h" |
8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
9 #include "ppapi/c/private/ppb_nacl_private.h" | 9 #include "ppapi/c/private/ppb_nacl_private.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Did the plugin report success? | 22 // Did the plugin report success? |
23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", | 23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", |
24 PP_NACL_ERROR_LOAD_SUCCESS, 1); | 24 PP_NACL_ERROR_LOAD_SUCCESS, 1); |
25 | 25 |
26 // Did the sel_ldr report success? | 26 // Did the sel_ldr report success? |
27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", | 27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", |
28 LOAD_OK, 1); | 28 LOAD_OK, 1); |
29 | 29 |
30 // Check validation cache usage: | 30 // Check validation cache usage: |
31 // For the open-web, only the IRT is considered a "safe" and | 31 if (IsAPnaclTest()) { |
32 // identity-cachable file. The nexes and .so files are not. | 32 // Should have received 3 validation queries: |
33 // Should have one cache query for the IRT. | 33 // - One for IRT for actual application |
34 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 34 // - Two for two translator nexes |
35 nacl::NaClBrowser::CACHE_MISS, 1); | 35 // The translators don't currently use the IRT, so there is no IRT cache |
36 // TOTAL should then be 1 query so far. | 36 // query for those two loads. The PNaCl main nexe comes from a |
37 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 1); | 37 // delete-on-close temp file, so it doesn't have a stable identity |
38 // Should have received a cache setting afterwards for IRT. | 38 // for validation caching. All three query results should be misses. |
39 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 1); | 39 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", |
| 40 nacl::NaClBrowser::CACHE_MISS, 3); |
| 41 // Should have received a cache setting afterwards for IRT and translators. |
| 42 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
| 43 nacl::NaClBrowser::CACHE_HIT, 3); |
| 44 } else { |
| 45 // For the open-web, only the IRT is considered a "safe" and |
| 46 // identity-cachable file. The nexes and .so files are not. |
| 47 // Should have one cache query for the IRT. |
| 48 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", |
| 49 nacl::NaClBrowser::CACHE_MISS, 1); |
| 50 // Should have received a cache setting afterwards for IRT and translators. |
| 51 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
| 52 nacl::NaClBrowser::CACHE_HIT, 1); |
| 53 } |
40 | 54 |
41 // Make sure we have other important histograms. | 55 // Make sure we have other important histograms. |
42 if (!IsAPnaclTest()) { | 56 if (!IsAPnaclTest()) { |
43 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1); | 57 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1); |
44 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.Total", 1); | 58 histograms.ExpectTotalCount("NaCl.Perf.StartupTime.Total", 1); |
45 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); | 59 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); |
46 histograms.ExpectTotalCount("NaCl.Perf.Size.Nexe", 1); | 60 histograms.ExpectTotalCount("NaCl.Perf.Size.Nexe", 1); |
47 } else { | 61 } else { |
48 histograms.ExpectTotalCount("NaCl.Options.PNaCl.OptLevel", 1); | 62 histograms.ExpectTotalCount("NaCl.Options.PNaCl.OptLevel", 1); |
49 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); | 63 histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Should have received 2 more validation queries later (IRT and NEXE), | 117 // Should have received 2 more validation queries later (IRT and NEXE), |
104 // and responded with a hit. | 118 // and responded with a hit. |
105 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 119 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
106 nacl::NaClBrowser::CACHE_HIT, 2); | 120 nacl::NaClBrowser::CACHE_HIT, 2); |
107 // TOTAL should then be 4 queries now. | 121 // TOTAL should then be 4 queries now. |
108 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); | 122 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); |
109 // Still only 2 settings. | 123 // Still only 2 settings. |
110 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); | 124 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); |
111 } | 125 } |
112 | 126 |
| 127 // Test that validation for the 2 PNaCl translator nexes can be cached. |
| 128 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
| 129 ValidationCacheOfTranslatorNexes) { |
| 130 // Run a load test w/ one pexe cache identity. |
| 131 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); |
| 132 |
| 133 UMAHistogramHelper histograms; |
| 134 histograms.Fetch(); |
| 135 // Should have received 3 validation queries: |
| 136 // - One for IRT for actual application |
| 137 // - Two for two translator nexes |
| 138 // The translators don't currently use the IRT, so there is no IRT cache |
| 139 // query for those two loads. The PNaCl main nexe comes from a |
| 140 // delete-on-close temp file, so it doesn't have a stable identity |
| 141 // for validation caching. All three query results should be misses. |
| 142 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", |
| 143 nacl::NaClBrowser::CACHE_MISS, 3); |
| 144 // Should have received a cache setting afterwards for IRT and translators. |
| 145 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
| 146 nacl::NaClBrowser::CACHE_HIT, 3); |
| 147 |
| 148 // Load the same pexe, but with a different cache identity. |
| 149 // This means that translation will actually be redone, |
| 150 // forcing the translators to be loaded a second time (but now with |
| 151 // cache hits!) |
| 152 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_2")); |
| 153 |
| 154 // Should now have 3 more queries on top of the previous ones. |
| 155 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 6); |
| 156 // With the 3 extra queries being cache hits. |
| 157 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
| 158 nacl::NaClBrowser::CACHE_HIT, 3); |
| 159 // No extra cache settings. |
| 160 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
| 161 nacl::NaClBrowser::CACHE_HIT, 3); |
| 162 } |
| 163 |
| 164 |
113 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) | 165 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) |
114 // Test validation failures and crashes. | 166 // Test validation failures and crashes. |
115 | 167 |
116 } // namespace | 168 } // namespace |
OLD | NEW |