Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/test/nacl/nacl_browsertest_uma.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 "content/public/test/browser_test_utils.h"
8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 9 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
9 #include "ppapi/c/private/ppb_nacl_private.h" 10 #include "ppapi/c/private/ppb_nacl_private.h"
10 11
11 namespace { 12 namespace {
12 13
13 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { 14 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, {
15 base::HistogramTester histograms;
14 // Load a NaCl module to generate UMA data. 16 // Load a NaCl module to generate UMA data.
15 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); 17 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html"));
16 18
17 // Make sure histograms from child processes have been accumulated in the 19 // Make sure histograms from child processes have been accumulated in the
18 // browser brocess. 20 // browser brocess.
19 UMAHistogramHelper histograms; 21 content::FetchHistogramsFromChildProcesses();
20 histograms.Fetch();
21 22
22 // Did the plugin report success? 23 // Did the plugin report success?
23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", 24 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin",
24 PP_NACL_ERROR_LOAD_SUCCESS, 1); 25 PP_NACL_ERROR_LOAD_SUCCESS, 1);
25 26
26 // Did the sel_ldr report success? 27 // Did the sel_ldr report success?
27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", 28 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr",
28 LOAD_OK, 1); 29 LOAD_OK, 1);
29 30
30 // Check validation cache usage: 31 // Check validation cache usage:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 class NaClBrowserTestNewlibVcacheExtension: 82 class NaClBrowserTestNewlibVcacheExtension:
82 public NaClBrowserTestNewlibExtension { 83 public NaClBrowserTestNewlibExtension {
83 public: 84 public:
84 virtual base::FilePath::StringType Variant() OVERRIDE { 85 virtual base::FilePath::StringType Variant() OVERRIDE {
85 return FILE_PATH_LITERAL("extension_vcache_test/newlib"); 86 return FILE_PATH_LITERAL("extension_vcache_test/newlib");
86 } 87 }
87 }; 88 };
88 89
89 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibVcacheExtension, 90 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibVcacheExtension,
90 ValidationCacheOfMainNexe) { 91 ValidationCacheOfMainNexe) {
92 base::HistogramTester histograms;
91 // Hardcoded extension AppID that corresponds to the hardcoded 93 // Hardcoded extension AppID that corresponds to the hardcoded
92 // public key in the manifest.json file. We need to load the extension 94 // public key in the manifest.json file. We need to load the extension
93 // nexe from the same origin, so we can't just try to load the extension 95 // nexe from the same origin, so we can't just try to load the extension
94 // nexe as a mime-type handler from a non-extension URL. 96 // nexe as a mime-type handler from a non-extension URL.
95 base::FilePath::StringType full_url = 97 base::FilePath::StringType full_url =
96 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") 98 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/")
97 FILE_PATH_LITERAL("extension_validation_cache.html"); 99 FILE_PATH_LITERAL("extension_validation_cache.html");
98 RunNaClIntegrationTest(full_url, true); 100 RunNaClIntegrationTest(full_url, true);
99 101
100 // Make sure histograms from child processes have been accumulated in the 102 // Make sure histograms from child processes have been accumulated in the
101 // browser process. 103 // browser brocess.
102 UMAHistogramHelper histograms; 104 content::FetchHistogramsFromChildProcesses();
103 histograms.Fetch();
104 // Should have received 2 validation queries (one for IRT and one for NEXE), 105 // Should have received 2 validation queries (one for IRT and one for NEXE),
105 // and responded with a miss. 106 // and responded with a miss.
106 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", 107 histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
107 nacl::NaClBrowser::CACHE_MISS, 2); 108 nacl::NaClBrowser::CACHE_MISS, 2);
108 // TOTAL should then be 2 queries so far. 109 // TOTAL should then be 2 queries so far.
109 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2); 110 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2);
110 // Should have received a cache setting afterwards for IRT and nexe. 111 // Should have received a cache setting afterwards for IRT and nexe.
111 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", 112 histograms.ExpectBucketCount("NaCl.ValidationCache.Set",
112 nacl::NaClBrowser::CACHE_HIT, 2); 113 nacl::NaClBrowser::CACHE_HIT, 2);
113 114
114 // Load it again to hit the cache. 115 // Load it again to hit the cache.
115 RunNaClIntegrationTest(full_url, true); 116 RunNaClIntegrationTest(full_url, true);
116 histograms.Fetch(); 117 content::FetchHistogramsFromChildProcesses();
117 // Should have received 2 more validation queries later (IRT and NEXE), 118 // Should have received 2 more validation queries later (IRT and NEXE),
118 // and responded with a hit. 119 // and responded with a hit.
119 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", 120 histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
120 nacl::NaClBrowser::CACHE_HIT, 2); 121 nacl::NaClBrowser::CACHE_HIT, 2);
121 // TOTAL should then be 4 queries now. 122 // TOTAL should then be 4 queries now.
122 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); 123 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4);
123 // Still only 2 settings. 124 // Still only 2 settings.
124 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); 125 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2);
125 } 126 }
126 127
127 class NaClBrowserTestGLibcVcacheExtension: 128 class NaClBrowserTestGLibcVcacheExtension:
128 public NaClBrowserTestGLibcExtension { 129 public NaClBrowserTestGLibcExtension {
129 public: 130 public:
130 virtual base::FilePath::StringType Variant() OVERRIDE { 131 virtual base::FilePath::StringType Variant() OVERRIDE {
131 return FILE_PATH_LITERAL("extension_vcache_test/glibc"); 132 return FILE_PATH_LITERAL("extension_vcache_test/glibc");
132 } 133 }
133 }; 134 };
134 135
135 IN_PROC_BROWSER_TEST_F(NaClBrowserTestGLibcVcacheExtension, 136 IN_PROC_BROWSER_TEST_F(NaClBrowserTestGLibcVcacheExtension,
136 ValidationCacheOfMainNexe) { 137 ValidationCacheOfMainNexe) {
138 // Make sure histograms from child processes have been accumulated in the
139 // browser process.
140 base::HistogramTester histograms;
137 // Hardcoded extension AppID that corresponds to the hardcoded 141 // Hardcoded extension AppID that corresponds to the hardcoded
138 // public key in the manifest.json file. We need to load the extension 142 // public key in the manifest.json file. We need to load the extension
139 // nexe from the same origin, so we can't just try to load the extension 143 // nexe from the same origin, so we can't just try to load the extension
140 // nexe as a mime-type handler from a non-extension URL. 144 // nexe as a mime-type handler from a non-extension URL.
141 base::FilePath::StringType full_url = 145 base::FilePath::StringType full_url =
142 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") 146 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/")
143 FILE_PATH_LITERAL("extension_validation_cache.html"); 147 FILE_PATH_LITERAL("extension_validation_cache.html");
144 RunNaClIntegrationTest(full_url, true); 148 RunNaClIntegrationTest(full_url, true);
145 149
146 // Make sure histograms from child processes have been accumulated in the
147 // browser process.
148 UMAHistogramHelper histograms;
149 histograms.Fetch();
150 // Should have received 9 validation queries, which respond with misses: 150 // Should have received 9 validation queries, which respond with misses:
151 // - the IRT 151 // - the IRT
152 // - ld.so (the initial nexe) 152 // - ld.so (the initial nexe)
153 // - main.nexe 153 // - main.nexe
154 // - libppapi_cpp.so 154 // - libppapi_cpp.so
155 // - libpthread.so.9b15f6a6 155 // - libpthread.so.9b15f6a6
156 // - libstdc++.so.6 156 // - libstdc++.so.6
157 // - libgcc_s.so.1 157 // - libgcc_s.so.1
158 // - libc.so.9b15f6a6 158 // - libc.so.9b15f6a6
159 // - libm.so.9b15f6a6 159 // - libm.so.9b15f6a6
160 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", 160 histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
161 nacl::NaClBrowser::CACHE_MISS, 9); 161 nacl::NaClBrowser::CACHE_MISS, 9);
162 // TOTAL should then be 9 queries so far. 162 // TOTAL should then be 9 queries so far.
163 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 9); 163 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 9);
164 // Should have received a cache setting afterwards for IRT and nexe. 164 // Should have received a cache setting afterwards for IRT and nexe.
165 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", 165 histograms.ExpectBucketCount("NaCl.ValidationCache.Set",
166 nacl::NaClBrowser::CACHE_HIT, 9); 166 nacl::NaClBrowser::CACHE_HIT, 9);
167 167
168 // Load it again to hit the cache. 168 // Load it again to hit the cache.
169 RunNaClIntegrationTest(full_url, true); 169 RunNaClIntegrationTest(full_url, true);
170 histograms.Fetch();
171 // Should have received 9 more validation queries and responded with hits. 170 // Should have received 9 more validation queries and responded with hits.
172 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", 171 histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
173 nacl::NaClBrowser::CACHE_HIT, 9); 172 nacl::NaClBrowser::CACHE_HIT, 9);
174 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 18); 173 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 18);
175 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 9); 174 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 9);
176 } 175 }
177 176
178 // Test that validation for the 2 PNaCl translator nexes can be cached. 177 // Test that validation for the 2 PNaCl translator nexes can be cached.
179 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, 178 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
180 ValidationCacheOfTranslatorNexes) { 179 ValidationCacheOfTranslatorNexes) {
180 base::HistogramTester histograms;
181 // Run a load test w/ one pexe cache identity. 181 // Run a load test w/ one pexe cache identity.
182 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); 182 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0"));
183 183
184 UMAHistogramHelper histograms; 184 content::FetchHistogramsFromChildProcesses();
185 histograms.Fetch();
186 // Should have received 3 validation queries: 185 // Should have received 3 validation queries:
187 // - One for IRT for actual application 186 // - One for IRT for actual application
188 // - Two for two translator nexes 187 // - Two for two translator nexes
189 // The translators don't currently use the IRT, so there is no IRT cache 188 // The translators don't currently use the IRT, so there is no IRT cache
190 // query for those two loads. The PNaCl main nexe comes from a 189 // query for those two loads. The PNaCl main nexe comes from a
191 // delete-on-close temp file, so it doesn't have a stable identity 190 // delete-on-close temp file, so it doesn't have a stable identity
192 // for validation caching. All three query results should be misses. 191 // for validation caching. All three query results should be misses.
193 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", 192 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query",
194 nacl::NaClBrowser::CACHE_MISS, 3); 193 nacl::NaClBrowser::CACHE_MISS, 3);
195 // Should have received a cache setting afterwards for IRT and translators. 194 // Should have received a cache setting afterwards for IRT and translators.
(...skipping 14 matching lines...) Expand all
210 // No extra cache settings. 209 // No extra cache settings.
211 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", 210 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set",
212 nacl::NaClBrowser::CACHE_HIT, 3); 211 nacl::NaClBrowser::CACHE_HIT, 3);
213 } 212 }
214 213
215 214
216 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) 215 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.)
217 // Test validation failures and crashes. 216 // Test validation failures and crashes.
218 217
219 } // namespace 218 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/base/uma_histogram_helper.cc ('k') | components/suggestions/blacklist_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698