• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TEST_CTS_HEAPPROFD_TEST_HELPER_H_
18 #define TEST_CTS_HEAPPROFD_TEST_HELPER_H_
19 
20 #include <cinttypes>
21 #include <string>
22 #include <vector>
23 
24 #include "protos/perfetto/trace/trace_packet.gen.h"
25 
26 namespace perfetto {
27 
28 // Heapprofd CTS test utils shared by tests covering native malloc and ART's
29 // java allocator (which reports samples using the heapprofd NDK custom
30 // allocator API).
31 
32 std::string RandomSessionName();
33 
34 std::vector<protos::gen::TracePacket> ProfileRuntime(
35     const std::string& app_name,
36     const std::string& activity,
37     uint64_t sampling_interval,
38     const std::vector<std::string>& heap_names);
39 
40 std::vector<protos::gen::TracePacket> ProfileStartup(
41     const std::string& app_name,
42     const std::string& activity,
43     uint64_t sampling_interval,
44     const std::vector<std::string>& heap_names,
45     const bool enable_extra_guardrails = false);
46 
47 void AssertExpectedMallocsPresent(
48     uint64_t expected_individual_alloc_sz,
49     const std::vector<protos::gen::TracePacket>& packets);
50 
51 void AssertHasSampledAllocs(
52     const std::vector<protos::gen::TracePacket>& packets);
53 
54 void AssertNoProfileContents(
55     const std::vector<protos::gen::TracePacket>& packets);
56 
57 }  // namespace perfetto
58 
59 #endif  // TEST_CTS_HEAPPROFD_TEST_HELPER_H_
60