Skip to content

Commit bdaba2e

Browse files
authored
starboard: Create starboard_unittest_wrapper (youtube#5031)
This is a follow up to youtube#4831 which landed with a TODO to move the newly introduced `starboard_unittests` into a `if (current_toolchain == starboard_toolchain)` block, and let external users depend on a `starboard_unittests_wrapper` instead. youtube#4831 landed unintendedly, so this CL follows up quickly; CI is likely to fail while youtube#4464 is being worked on. Bug: b/384819454
1 parent 088ed67 commit bdaba2e

4 files changed

Lines changed: 40 additions & 26 deletions

File tree

‎cobalt/build/archive_test_artifacts.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def create_archive(
8282
f'{target_name}__test_runner_script.runtime_deps')
8383
else:
8484
deps_file = os.path.join(out_dir, f'{target_name}.runtime_deps')
85+
if not os.path.exists(deps_file):
86+
# If |deps_file| doesn't exist it could be due to being generated with
87+
# the starboard_toolchain. In that case, we should look in subfolders.
88+
# For the time being, just try with an extra starboard/ in the path.
89+
deps_file = os.path.join(out_dir, 'starboard',
90+
f'{target_name}.runtime_deps')
8591

8692
print('Collecting runtime dependencies for', target)
8793
with open(deps_file, 'r', encoding='utf-8') as runtime_deps_file:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"services/service_manager/tests:service_manager_unittests",
3131
"skia:skia_unittests",
3232
"sql:sql_unittests",
33-
"starboard:starboard_unittests",
33+
"starboard:starboard_unittests_wrapper",
3434
"starboard/nplb:nplb",
3535
"third_party/blink/renderer/platform:blink_platform_nocompile_tests",
3636
"third_party/blink/renderer/platform:blink_platform_perftests",
@@ -86,7 +86,7 @@
8686
"out/linux-x64x11_devel/service_manager_unittests",
8787
"out/linux-x64x11_devel/skia_unittests",
8888
"out/linux-x64x11_devel/sql_unittests",
89-
"out/linux-x64x11_devel/starboard_unittests",
89+
"out/linux-x64x11_devel/starboard_unittests_wrapper",
9090
"out/linux-x64x11_devel/trace_processor_minimal_smoke_tests",
9191
"out/linux-x64x11_devel/url_perftests",
9292
"out/linux-x64x11_devel/url_unittests",

‎starboard/BUILD.gn‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -292,27 +292,26 @@ if (current_toolchain == starboard_toolchain) {
292292
public_deps += [ "//$starboard_path:starboard_platform_with_main" ]
293293
}
294294
}
295-
}
296295

297-
# TODO(b/384819454): Move this guy to the block above and define here a
298-
# group("starboard_unittests_wrapper") {
299-
# testonly = true
300-
# deps = [ ":starboard_unittests($starboard_toolchain)" ]
301-
# }
302-
# then modify //cobalt/build/...test_targets.json to point to it instead of
303-
# starboard_unittests directly.
304-
test("starboard_unittests") {
305-
deps = [ "//starboard/common:common_test" ]
306-
if (sb_is_evergreen_compatible) {
307-
deps += [
308-
"//starboard/client_porting/eztime:eztime_test",
309-
"//starboard/extension:extension_test",
310-
"//starboard/loader_app:app_key_files_test",
311-
"//starboard/loader_app:app_key_test",
312-
"//starboard/loader_app:drain_file_test",
313-
]
314-
if (current_toolchain == starboard_toolchain) {
296+
source_set("starboard_unittests") {
297+
testonly = true
298+
deps = [ "//starboard/common:common_test" ]
299+
if (!is_android) {
315300
deps += [ "//starboard/elf_loader:elf_loader_test" ]
316301
}
302+
if (sb_is_evergreen_compatible) {
303+
deps += [
304+
"//starboard/client_porting/eztime:eztime_test",
305+
"//starboard/extension:extension_test",
306+
"//starboard/loader_app:app_key_files_test",
307+
"//starboard/loader_app:app_key_test",
308+
"//starboard/loader_app:drain_file_test",
309+
]
310+
}
317311
}
318312
}
313+
314+
test("starboard_unittests_wrapper") {
315+
testonly = true
316+
deps = [ ":starboard_unittests($starboard_toolchain)" ]
317+
}

‎starboard/elf_loader/lz4_file_impl_test.cc‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,23 @@ TEST(LZ4FileImplTest, ValidFileDecompressionSucceeds) {
6767
std::vector<char> content_path(kSbFileMaxPath + 1);
6868
EXPECT_TRUE(SbSystemGetPath(kSbSystemPathContentDirectory,
6969
content_path.data(), kSbFileMaxPath + 1));
70-
std::string file_path = std::string(content_path.data()) + kSbFileSepChar +
71-
"test" + kSbFileSepChar + "starboard" +
72-
kSbFileSepChar + "elf_loader" + kSbFileSepChar +
73-
"testdata" + kSbFileSepChar + "compressed.lz4";
70+
const auto content_path_as_string = std::string(content_path.data());
71+
const auto path_inside_content =
72+
std::string({kSbFileSepChar}) + "test" + kSbFileSepChar + "starboard" +
73+
kSbFileSepChar + "elf_loader" + kSbFileSepChar + "testdata" +
74+
kSbFileSepChar + "compressed.lz4";
75+
const std::string file_path = content_path_as_string + path_inside_content;
7476

7577
LZ4FileImpl file;
7678

77-
EXPECT_TRUE(file.Open(file_path.c_str()));
79+
if (!file.Open(file_path.c_str())) {
80+
// Couldn't open |file_path|. This is usually because |content_path| is
81+
// incorrect; it's usually something like e.g. out/linux.../content when it
82+
// should be out/linux.../starboard/content, to account for the starboard
83+
// toolchain's extra output folder. By default kSbSystemPathContentDirectory
84+
// is where the binary runs.
85+
GTEST_SKIP();
86+
}
7887

7988
char decompressed[SB_ARRAY_SIZE(kUncompressedData)]{0};
8089

0 commit comments

Comments
 (0)