1 /*
2 * Copyright 2018 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 <gtest/gtest.h>
18
19 #include <sched.h>
20
21 #include <processgroup/sched_policy.h>
22 #include <system/graphics.h>
23
24 #include "libsurfaceflinger_unittest_main.h"
25
26 // ------------------------------------------------------------------------
27 // To pass extra command line arguments to the Google Test executable from
28 // atest, you have to use this somewhat verbose syntax:
29 //
30 // clang-format off
31 //
32 // atest libsurfaceflinger_unittest -- --module-arg libsurfaceflinger_unittest:native-test-flag:<--flag>[:<value>]
33 //
34 // For example:
35 //
36 // atest libsurfaceflinger_unittest -- --module-arg libsurfaceflinger_unittest:native-test-flag:--no-slow
37 //
38 // clang-format on
39 // ------------------------------------------------------------------------
40
41 // Set to true if "--no-slow" is passed to the test.
42 bool g_noSlowTests = false;
43
main(int argc,char ** argv)44 int main(int argc, char **argv) {
45 ::testing::InitGoogleTest(&argc, argv);
46
47 // The SurfaceFlinger implementation assumes that threads resume
48 // execution as quickly as possible once they become unblocked.
49 // (These same calls are made in main_surfaceflinger.cpp)
50 setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
51 set_sched_policy(0, SP_FOREGROUND);
52
53 for (int i = 1; i < argc; i++) {
54 if (strcmp(argv[i], "--no-slow") == 0) {
55 g_noSlowTests = true;
56 }
57 }
58
59 return RUN_ALL_TESTS();
60 }