Skip to content

Commit 455a1ec

Browse files
authored
starboard: Create starboard_unittest and fold in a few test targets (youtube#4831)
This CL creates a starboard_unittests and folds in a few ...test targets that are currently built separately (and likely not run very often). The original `target(gtest_target_type, "bla")` are refactored into `source_set("bla")`. After this CL starboard_unittests runs 124 test cases, of which only `EzTimeTExplodeTest.PositivePacific` fails (left DISABLED) with a TODO. Bug: b/384819454
1 parent acdc028 commit 455a1ec

12 files changed

Lines changed: 65 additions & 59 deletions

File tree

‎cobalt/build/testing/targets/linux-x64x11/test_targets.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"services/service_manager/tests:service_manager_unittests",
2828
"skia:skia_unittests",
2929
"sql:sql_unittests",
30+
"starboard:starboard_unittests",
3031
"ui/ozone:ozone_unittests",
3132
"ui/wm:wm_unittests",
3233
"url:url_perftests",
@@ -61,6 +62,7 @@
6162
"out/linux-x64x11_devel/service_manager_unittests",
6263
"out/linux-x64x11_devel/skia_unittests",
6364
"out/linux-x64x11_devel/sql_unittests",
65+
"out/linux-x64x11_devel/starboard_unittests",
6466
"out/linux-x64x11_devel/wm_unittests",
6567
"out/linux-x64x11_devel/url_perftests",
6668
"out/linux-x64x11_devel/url_unittests",

‎starboard/BUILD.gn‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import("//starboard/build/config/os_definitions.gni")
1616
import("//starboard/build/config/starboard_target_type.gni")
1717
import("//starboard/contrib/cast/cast.gni")
18+
import("//testing/test.gni")
1819

1920
# TODO: b/389791129 - Evaluate and cleanup targets in if(!is_cobalt) code block.
2021
if (!is_cobalt) {
@@ -26,16 +27,11 @@ if (!is_cobalt) {
2627
"//starboard/client_porting/icu_init",
2728
]
2829
if (enable_test_targets) {
29-
if (sb_is_evergreen_compatible &&
30-
current_toolchain == starboard_toolchain) {
31-
deps += [ "//starboard/nplb/nplb_evergreen_compat_tests" ]
32-
}
3330
deps += [
34-
"//starboard/client_porting/eztime:eztime_test",
31+
":starboard_unittest",
3532
"//starboard/examples/glclear:starboard_glclear_example",
3633
"//starboard/examples/hello_world:starboard_hello_world_example",
3734
"//starboard/examples/window:starboard_window_example",
38-
"//starboard/extension:extension_test",
3935
"//starboard/nplb",
4036
]
4137
}
@@ -296,5 +292,26 @@ if (current_toolchain == starboard_toolchain) {
296292
}
297293
}
298294
}
299-
# TODO: Create a starboard_unittest target here and fold any gtest_target_type
300-
# in it, e.g. common:common_test.
295+
296+
# TODO(b/384819454): Move this guy to the block above and define here a
297+
# group("starboard_unittests_wrapper") {
298+
# testonly = true
299+
# deps = [ ":starboard_unittests($starboard_toolchain)" ]
300+
# }
301+
# then modify //cobalt/build/...test_targets.json to point to it instead of
302+
# starboard_unittests directly.
303+
test("starboard_unittests") {
304+
deps = [ "//starboard/common:common_test" ]
305+
if (sb_is_evergreen_compatible) {
306+
deps += [
307+
"//starboard/client_porting/eztime:eztime_test",
308+
"//starboard/extension:extension_test",
309+
"//starboard/loader_app:app_key_files_test",
310+
"//starboard/loader_app:app_key_test",
311+
"//starboard/loader_app:drain_file_test",
312+
]
313+
if (current_toolchain == starboard_toolchain) {
314+
deps += [ "//starboard/elf_loader:elf_loader_test" ]
315+
}
316+
}
317+
}

‎starboard/client_porting/eztime/BUILD.gn‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ static_library("eztime") {
2626
]
2727
}
2828

29-
target(gtest_target_type, "eztime_test") {
29+
source_set("eztime_test") {
3030
testonly = true
3131

3232
sources = [
33-
"//starboard/common/test_main.cc",
3433
"eztime_test.cc",
3534
"test_constants.h",
3635
]

‎starboard/client_porting/eztime/eztime_test.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ TEST(EzTimeTExplodeTest, PositiveLocal) {
129129
EXPECT_EQ(8, exploded.tm_sec);
130130
}
131131

132-
TEST(EzTimeTExplodeTest, PositivePacific) {
132+
// TODO(b/397817771): Fix and re-enable.
133+
TEST(EzTimeTExplodeTest, DISABLED_PositivePacific) {
133134
EzTimeExploded exploded = {0};
134135
EXPECT_TRUE(
135136
EzTimeTExplode(&kTestTimePositive, kEzTimeZonePacific, &exploded));

‎starboard/common/BUILD.gn‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static_library("file_wrapper") {
9999
deps = [ "//starboard:starboard_headers_only" ]
100100
}
101101

102-
target(gtest_target_type, "common_test") {
102+
source_set("common_test") {
103103
testonly = true
104104
sources = [
105105
"fixed_no_free_allocator_test.cc",

‎starboard/elf_loader/BUILD.gn‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) {
155155

156156
# TODO: b/309493306 - Stop building evergreen targets for all non-evergreen platforms.
157157
if (current_toolchain == starboard_toolchain) {
158-
target(starboard_level_gtest_target_type, "elf_loader_test") {
158+
source_set("elf_loader_test") {
159159
testonly = true
160160

161-
sources = [ "//starboard/common/test_main.cc" ]
162161
deps = [
163162
"//starboard:starboard_with_main",
164163
"//testing/gmock",
@@ -167,7 +166,7 @@ if (current_toolchain == starboard_toolchain) {
167166

168167
if (target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" ||
169168
target_cpu == "arm64") {
170-
sources += [
169+
sources = [
171170
"dynamic_section_test.cc",
172171
"elf_header_test.cc",
173172
"elf_loader_test.cc",

‎starboard/elf_loader/elf_header_test.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <string>
1818

19+
#include "starboard/common/log.h"
1920
#include "starboard/elf_loader/file.h"
2021
#include "testing/gmock/include/gmock/gmock.h"
2122
#include "testing/gtest/include/gtest/gtest.h"

‎starboard/elf_loader/program_table_test.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string>
1919
#include <vector>
2020

21+
#include "starboard/common/log.h"
2122
#include "starboard/elf_loader/file.h"
2223
#include "testing/gmock/include/gmock/gmock.h"
2324
#include "testing/gtest/include/gtest/gtest.h"

‎starboard/extension/BUILD.gn‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
target(gtest_target_type, "extension_test") {
15+
source_set("extension_test") {
1616
testonly = true
17-
has_pedantic_warnings = true
1817
sources = [
19-
"//starboard/common/test_main.cc",
2018
"enhanced_audio_test.cc",
2119
"extension_test.cc",
2220
]

‎starboard/loader_app/BUILD.gn‎

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,15 @@ static_library("app_key_files") {
159159
]
160160
}
161161

162-
if (sb_is_evergreen) {
163-
target(gtest_target_type, "app_key_files_test") {
164-
testonly = true
165-
sources = [
166-
"//starboard/common/test_main.cc",
167-
"app_key_files_test.cc",
168-
]
169-
deps = [
170-
":app_key_files",
171-
"//testing/gmock",
172-
"//testing/gtest",
173-
]
174-
}
162+
source_set("app_key_files_test") {
163+
testonly = true
164+
sources = [ "app_key_files_test.cc" ]
165+
deps = [
166+
":app_key_files",
167+
"//starboard:starboard_group",
168+
"//testing/gmock",
169+
"//testing/gtest",
170+
]
175171
}
176172

177173
static_library("app_key") {
@@ -188,19 +184,14 @@ static_library("app_key") {
188184
]
189185
}
190186

191-
if (sb_is_evergreen) {
192-
target(gtest_target_type, "app_key_test") {
193-
testonly = true
194-
sources = [
195-
"//starboard/common/test_main.cc",
196-
"app_key_test.cc",
197-
]
198-
deps = [
199-
":app_key",
200-
"//testing/gmock",
201-
"//testing/gtest",
202-
]
203-
}
187+
source_set("app_key_test") {
188+
testonly = true
189+
sources = [ "app_key_test.cc" ]
190+
deps = [
191+
":app_key",
192+
"//testing/gmock",
193+
"//testing/gtest",
194+
]
204195
}
205196

206197
static_library("drain_file") {
@@ -224,21 +215,16 @@ static_library("drain_file_helper") {
224215
]
225216
}
226217

227-
if (sb_is_evergreen) {
228-
target(gtest_target_type, "drain_file_test") {
229-
testonly = true
230-
sources = [
231-
"//starboard/common/test_main.cc",
232-
"drain_file_test.cc",
233-
]
234-
deps = [
235-
":drain_file",
236-
":drain_file_helper",
237-
"//starboard/common",
238-
"//testing/gmock",
239-
"//testing/gtest",
240-
]
241-
}
218+
source_set("drain_file_test") {
219+
testonly = true
220+
sources = [ "drain_file_test.cc" ]
221+
deps = [
222+
":drain_file",
223+
":drain_file_helper",
224+
"//starboard/common",
225+
"//testing/gmock",
226+
"//testing/gtest",
227+
]
242228
}
243229

244230
proto_library("installation_store_proto") {

0 commit comments

Comments
 (0)