xref: /aosp_15_r20/external/perfetto/test/integrationtest_main.cc (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2024 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 #include "test/integrationtest_initializer.h"
18 
19 #include "perfetto/base/logging.h"
20 #include "test/gtest_and_gmock.h"
21 
22 namespace perfetto::integration_tests {
23 
24 static void (*heapprofd_end_to_end_test_initializer)(void) = nullptr;
RegisterHeapprofdEndToEndTestInitializer(void (* fn)(void))25 int RegisterHeapprofdEndToEndTestInitializer(void (*fn)(void)) {
26   PERFETTO_CHECK(heapprofd_end_to_end_test_initializer == nullptr);
27   heapprofd_end_to_end_test_initializer = fn;
28   return 0;
29 }
30 
31 static void (*api_integration_test_initializer)(void) = nullptr;
RegisterApiIntegrationTestInitializer(void (* fn)(void))32 int RegisterApiIntegrationTestInitializer(void (*fn)(void)) {
33   PERFETTO_CHECK(api_integration_test_initializer == nullptr);
34   api_integration_test_initializer = fn;
35   return 0;
36 }
37 
38 }  // namespace perfetto::integration_tests
39 
main(int argc,char ** argv)40 int main(int argc, char** argv) {
41   if (perfetto::integration_tests::heapprofd_end_to_end_test_initializer) {
42     perfetto::integration_tests::heapprofd_end_to_end_test_initializer();
43   }
44   if (perfetto::integration_tests::api_integration_test_initializer) {
45     perfetto::integration_tests::api_integration_test_initializer();
46   }
47 
48   ::testing::InitGoogleTest(&argc, argv);
49   return RUN_ALL_TESTS();
50 }
51