• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 <stddef.h>
18 #include <stdint.h>
19 #include <stdlib.h>
20 
21 #include "base/logging.h"
22 #include "base/mem_map.h"
23 #include "base/mutex.h"
24 #include "gtest_extras/IsolateMain.h"
25 #include "runtime.h"
26 
GetInitialArgs(const char *** args,size_t * num_args)27 extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) {
28   static const char* initial_args[] = {
29       "--deadline_threshold_ms=1200000",  // hwasan takes ~10min.
30       "--slow_threshold_ms=300000",
31   };
32   *args = initial_args;
33   *num_args = 2;
34   return true;
35 }
36 
37 // Allow other test code to run global initialization/configuration before gtest infra takes over.
38 extern "C" __attribute__((visibility("default"))) __attribute__((weak)) void ArtTestGlobalInit();
39 
main(int argc,char ** argv,char ** envp)40 int main(int argc, char** argv, char** envp) {
41   // Gtests can be very noisy. For example, an executable with multiple tests will trigger native
42   // bridge warnings. The following line reduces the minimum log severity to ERROR and suppresses
43   // everything else. In case you want to see all messages, comment out the line.
44   const char* log_tag_override = getenv("ART_GTEST_OVERRIDE_LOG_TAGS");
45   setenv("ANDROID_LOG_TAGS", log_tag_override == nullptr ? "*:e" : log_tag_override, 1);
46 
47   art::Locks::Init();
48   art::InitLogging(argv, art::Runtime::Abort);
49   art::MemMap::Init();
50   LOG(INFO) << "Running main() from common_runtime_test.cc...";
51   if (ArtTestGlobalInit != nullptr) {
52     ArtTestGlobalInit();
53   }
54   return IsolateMain(argc, argv, envp);
55 }
56