1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
2# Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without modification,
5# are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this list of
8#    conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice, this list
11#    of conditions and the following disclaimer in the documentation and/or other materials
12#    provided with the distribution.
13#
14# 3. Neither the name of the copyright holder nor the names of its contributors may be used
15#    to endorse or promote products derived from this software without specific prior written
16#    permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30import("config.gni")
31
32local_flags = [
33  "-fpermissive",
34  "-O2",
35  "-fbuiltin",
36  "-Wno-narrowing",
37  "-fPIE",
38  "-Wno-error",
39]
40if (LOSCFG_USER_TEST_SMP == "enable" ||
41    (LOSCFG_USER_TEST_SMP == "default" && board_name == "hispark_taurus")) {
42  local_flags += [ "-DLOSCFG_USER_TEST_SMP" ]
43}
44
45config("public_config_for_door") {
46  cflags = [ "-DLOSCFG_USER_TEST_SMOKE" ]
47  cflags += local_flags
48  cflags_cc = cflags
49}
50
51config("public_config_for_all") {
52  cflags = [
53    "-DLOSCFG_USER_TEST_SMOKE",
54    "-DLOSCFG_USER_TEST_FULL",
55  ]
56  cflags += local_flags
57  cflags_cc = cflags
58}
59
60config("public_config_for_pressure") {
61  cflags = [ "-DLOSCFG_USER_TEST_PRESSURE" ]
62  cflags += local_flags
63  cflags_cc = cflags
64}
65
66# Note: The execution time of a single XXX_door.bin cannot exceed 90 seconds.
67group("unittest") {
68  deps = []
69  if (ohos_build_type == "debug") {
70    deps += [ "tools:liteos_unittest_run" ]
71
72    # basic test
73    if (LOSCFG_USER_TEST_BASIC == true) {
74      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
75        deps += [ "basic:liteos_a_basic_unittest_door" ]
76      }
77      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
78        deps += [ "basic:liteos_a_basic_unittest" ]
79      }
80    }
81
82    # drivers test
83    if (LOSCFG_USER_TEST_DRIVERS == true) {
84      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
85        deps += [ "drivers:liteos_a_drivers_unittest_door" ]
86      }
87      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
88        deps += [ "drivers:liteos_a_drivers_unittest" ]
89      }
90    }
91
92    # extended test
93    if (LOSCFG_USER_TEST_EXTENDED == true) {
94      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
95        deps += [ "extended:liteos_a_extended_unittest_door" ]
96      }
97      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
98        deps += [ "extended:liteos_a_extended_unittest" ]
99      }
100    }
101
102    # fs test
103    if (LOSCFG_USER_TEST_FS == true) {
104      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
105        deps += [ "fs:liteos_a_fs_unittest_door" ]
106      }
107      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
108        deps += [ "fs:liteos_a_fs_unittest" ]
109      }
110      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_HIGH) {
111        deps += [ "fs:liteos_a_fs_unittest_pressure" ]
112      }
113    }
114
115    # libc test
116    if (LOSCFG_USER_TEST_LIBC == true) {
117      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
118        deps += [
119          "libc/io:liteos_a_libc_io_unittest_door",
120          "libc/misc:liteos_a_libc_misc_unittest_door",
121          "libc/posix:liteos_a_libc_posix_unittest_door",
122          "libc/sys:liteos_a_libc_sys_unittest_door",
123          "libc/time:liteos_a_libc_time_unittest_door",
124          "libc/util:liteos_a_libc_util_unittest_door",
125        ]
126      }
127      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
128        deps += [
129          "libc/io:liteos_a_libc_io_unittest",
130          "libc/misc:liteos_a_libc_misc_unittest",
131          "libc/posix:liteos_a_libc_posix_unittest",
132          "libc/sys:liteos_a_libc_sys_unittest",
133          "libc/time:liteos_a_libc_time_unittest",
134          "libc/util:liteos_a_libc_util_unittest",
135        ]
136      }
137    }
138
139    # net test
140    if (LOSCFG_USER_TEST_NET == true) {
141      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
142        deps += [ "net:liteos_a_net_unittest_door" ]
143      }
144      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
145        deps += [ "net:liteos_a_net_unittest" ]
146      }
147    }
148
149    # process test
150    if (LOSCFG_USER_TEST_PROCESS_THREAD == true) {
151      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
152        deps += [
153          "process/basic/process:liteos_a_process_basic_process_unittest_door",
154          "process/basic/pthread:liteos_a_process_basic_pthread_unittest_door",
155          "process/lock:liteos_a_process_lock_unittest_door",
156        ]
157        if (LOSCFG_USER_TEST_PROCESS_FS == true) {
158          deps += [ "process/fs:liteos_a_process_fs_unittest_door" ]
159        }
160        if (LOSCFG_USER_TEST_PROCESS_PLIMITS == true) {
161          deps += [ "process/plimits:liteos_a_process_plimits_unittest_door" ]
162        }
163      }
164      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
165        deps += [
166          "process/basic/process:liteos_a_process_basic_process_unittest",
167          "process/basic/pthread:liteos_a_process_basic_pthread_unittest",
168          "process/lock:liteos_a_process_lock_unittest",
169        ]
170        if (LOSCFG_USER_TEST_PROCESS_FS == true) {
171          deps += [ "process/fs:liteos_a_process_fs_unittest" ]
172        }
173        if (LOSCFG_USER_TEST_PROCESS_PLIMITS == true) {
174          deps += [ "process/plimits:liteos_a_process_plimits_unittest" ]
175        }
176      }
177    }
178
179    # security test
180    if (LOSCFG_USER_TEST_SECURITY == true) {
181      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
182        deps += [ "security:liteos_a_security_unittest_door" ]
183      }
184      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
185        deps += [ "security:liteos_a_security_unittest" ]
186      }
187    }
188
189    # container test
190    if (LOSCFG_USER_TEST_CONTAINER == true) {
191      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
192        deps += [ "container:liteos_a_container_unittest_door" ]
193      }
194      if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
195        deps += [ "container:liteos_a_container_unittest" ]
196      }
197    }
198
199    # fuzz test
200    if (LOSCFG_USER_FUZZ_TEST == true) {
201      deps += [ "fuzz:liteos_a_fuzztest" ]
202    }
203  }
204}
205