• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #include "perfetto-tracing-only.h"
15 
16 #include <gtest/gtest.h>
17 
18 namespace virtualdeviceperfetto {
19 
TEST(PerfettoTracingOnly,Basic)20 TEST(PerfettoTracingOnly, Basic) {
21     setTraceConfig([](VirtualDeviceTraceConfig& config) {
22         config.hostFilename = "test1.trace";
23         config.guestFilename = nullptr;
24     });
25 
26     const bool* tracingDisabledPtr;
27     initialize(&tracingDisabledPtr);
28 
29     EXPECT_TRUE(*tracingDisabledPtr);
30 
31     enableTracing();
32     for (uint32_t i = 0; i < 4000; ++i) {
33         traceCounter("counter1", 1);
34         beginTrace("test trace 1");
35         traceCounter("counter1", 2);
36           beginTrace("test trace 1.1");
37         traceCounter("counter1", 3);
38           endTrace();
39         traceCounter("counter1", 4);
40         endTrace();
41         beginTrace("test trace 2");
42         endTrace();
43     }
44     disableTracing();
45 
46     setTraceConfig([](VirtualDeviceTraceConfig& config) {
47         config.hostFilename = "test2.trace";
48         config.guestFilename = nullptr;
49     });
50 
51     enableTracing();
52     for (uint32_t i = 0; i < 40; ++i) {
53         traceCounter("counter1", 1);
54         beginTrace("test trace 1");
55         traceCounter("counter1", 2);
56           beginTrace("test trace 1.1");
57         traceCounter("counter1", 3);
58           endTrace();
59         traceCounter("counter1", 4);
60         endTrace();
61         beginTrace("test trace 2");
62         endTrace();
63     }
64     disableTracing();
65 }
66 
67 } // namespace virtualdeviceperfetto
68