• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "chrome/test/base/uma_histogram_helper.h"
6 #include "chrome/test/nacl/nacl_browsertest_util.h"
7 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
8 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h"
9 
10 namespace {
11 
12 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, {
13   // Load a NaCl module to generate UMA data.
14   RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html"));
15 
16   // Make sure histograms from child processes have been accumulated in the
17   // browser brocess.
18   UMAHistogramHelper histograms;
19   histograms.Fetch();
20 
21   // Did the plugin report success?
22   histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin",
23                                 plugin::ERROR_LOAD_SUCCESS, 1);
24 
25   // Did the sel_ldr report success?
26   histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr",
27                                 LOAD_OK, 1);
28 
29   // Make sure we have other important histograms.
30   if (!IsAPnaclTest()) {
31     histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1);
32     histograms.ExpectTotalCount("NaCl.Perf.StartupTime.Total", 1);
33     histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1);
34     histograms.ExpectTotalCount("NaCl.Perf.Size.Nexe", 1);
35   } else {
36     histograms.ExpectTotalCount("NaCl.Options.PNaCl.OptLevel", 1);
37     histograms.ExpectTotalCount("NaCl.Perf.Size.Manifest", 1);
38     histograms.ExpectTotalCount("NaCl.Perf.Size.Pexe", 1);
39     histograms.ExpectTotalCount("NaCl.Perf.Size.PNaClTranslatedNexe", 1);
40     histograms.ExpectTotalCount("NaCl.Perf.Size.PexeNexeSizePct", 1);
41     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadCompiler", 1);
42     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LoadLinker", 1);
43     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileTime", 1);
44     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.CompileKBPerSec", 1);
45     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.LinkTime", 1);
46     histograms.ExpectTotalCount(
47         "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", 1);
48     histograms.ExpectTotalCount("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", 1);
49     histograms.ExpectTotalCount(
50         "NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", 1);
51     histograms.ExpectTotalCount("NaCl.Perf.PNaClCache.IsHit", 1);
52   }
53 })
54 
55 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.)
56 // Test validation failures and crashes.
57 
58 }  // namespace anonymous
59