Skip to content

Commit 82430e3

Browse files
authored
starboard: roll up the remaining unittest targets (#5127)
This PR continues the work of #4831 and rolls up all other targets I could find that looked like unit tests into `starboard_unittests`. With this I see ``` [==========] 1454 tests from 55 test suites ran. (8612 ms total) [ PASSED ] 989 tests. [ SKIPPED ] 465 tests, listed below: ... YOU HAVE 1 DISABLED TEST ``` (the disabled test was from before, the skipped ones are new, see further below). Media-related topics: - A number of tetst (e.g. `AudioDecoderTest` and others) needed a number of system libraries to support codecs like AAC, AC3 etc but those are part of non-free Debian repos, so couldn't install those in Docker. This CL adds a new method `IsProprietaryAudioCodec()` to be used to SKIP test cases related to those codecs, when the build flag `SKIP_PROPRIETARY_CODEC_TESTS` is present. - `VideoDecoderTests` and `PlayerComponentsTest` failed flakily due to X11 use not being torn down correctly; they need `xvfb-run`. This makes me think those are not pure unit-tests but integration tests like `nplb`. For the time being they are commented out with a TODO. - `media_util_test.cc` needed `operator==` on `SbMediaColorMetadata`s, so I added it as extern. - `FileCacheReader` needs to find the media files under the output folder's `content/` directory. Files are under the output folder's `starboard/content`, because of the starboard toolchain. This CL leaves a quick hack and a TODO() to find a proper solution. Finally: - `//starboard/raspi/shared/:starboard_platform_tests` target was empty, this CL removes it. Bug: b/384819454
1 parent 24999ce commit 82430e3

17 files changed

Lines changed: 130 additions & 52 deletions

File tree

‎starboard/BUILD.gn‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,13 @@ if (current_toolchain == starboard_toolchain) {
297297
testonly = true
298298
deps = [ "//starboard/common:common_test" ]
299299
if (!is_android) {
300-
deps += [ "//starboard/elf_loader:elf_loader_test" ]
300+
deps += [
301+
"//starboard/elf_loader:elf_loader_test",
302+
"//starboard/linux/shared:starboard_platform_tests",
303+
"//starboard/loader_app:installation_manager_test",
304+
"//starboard/loader_app:memory_tracker_thread",
305+
"//starboard/shared/starboard/player/filter/testing:player_filter_tests",
306+
]
301307
}
302308
if (sb_is_evergreen_compatible) {
303309
deps += [
@@ -308,6 +314,23 @@ if (current_toolchain == starboard_toolchain) {
308314
"//starboard/loader_app:drain_file_test",
309315
]
310316
}
317+
318+
# Based on y4vor@s comment:
319+
# > `sb_is_evergreen`: Applies only above Starboard and means it is an
320+
# > Evergreen/Hermetic build.
321+
# > `sb_is_evergreen_compatible`: Applies only at the Starboard
322+
# > implementation and means the build would be used for Evergreen.
323+
# I think this below, which was copied from //starboard/loader_app/BUILD.gn,
324+
# should be `sb_is_evergreen_compatible`.
325+
if (sb_is_evergreen) {
326+
deps += [ "//starboard/loader_app:slot_management_test" ]
327+
}
328+
if (is_android) {
329+
deps += [ "//starboard/android/shared:starboard_platform_tests" ]
330+
}
331+
if (build_with_separate_cobalt_toolchain && use_contrib_cast) {
332+
deps += [ "//starboard/contrib/cast/cast_starboard_api/samples:cast_starboard_api_test" ]
333+
}
311334
}
312335
}
313336

‎starboard/android/shared/BUILD.gn‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,10 @@ static_library("starboard_base_symbolize") {
370370
check_includes = false
371371
}
372372

373-
target(gtest_target_type, "starboard_platform_tests") {
373+
source_set("starboard_platform_tests") {
374374
testonly = true
375375

376376
sources = media_tests_sources + player_tests_sources + [
377-
"//starboard/common/test_main.cc",
378377
"//starboard/shared/starboard/drm/drm_test_helpers.cc",
379378
"//starboard/shared/starboard/drm/drm_test_helpers.h",
380379
"jni_env_ext_test.cc",

‎starboard/contrib/cast/cast_starboard_api/samples/BUILD.gn‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (current_toolchain == starboard_toolchain) {
4242
}
4343
}
4444

45-
target(gtest_target_type, "cast_starboard_api_test") {
45+
source_set("cast_starboard_api_test") {
4646
testonly = true
4747
sources = [
4848
"//starboard/common/test_main.cc",

‎starboard/linux/shared/BUILD.gn‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,18 @@ static_library("starboard_platform_sources") {
327327
}
328328

329329
if (current_toolchain == starboard_toolchain) {
330-
target(starboard_level_gtest_target_type, "starboard_platform_tests") {
330+
source_set("starboard_platform_tests") {
331331
testonly = true
332332

333-
sources = media_tests_sources + player_tests_sources + [
334-
"//starboard/common/test_main.cc",
335-
"//starboard/shared/ffmpeg/ffmpeg_audio_decoder_test.cc",
336-
]
333+
sources = media_tests_sources + player_tests_sources
334+
335+
# Despite the file below looking like a unittest, in reality is an
336+
# integration test, since it fully relies on the system's ffmpeg to be
337+
# available, linkable, and of a given version to run and pass.
338+
339+
# TODO(b/384819454): Consider rolling it into nplb if ffmpeg is considered
340+
# active and in use.
341+
#"//starboard/shared/ffmpeg/ffmpeg_audio_decoder_test.cc",
337342

338343
configs += [ "//starboard/build/config:starboard_implementation" ]
339344

‎starboard/linux/shared/player_components_factory.cc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
7979
new OpusAudioDecoder(audio_stream_info));
8080
if (audio_decoder_impl->is_valid()) {
8181
return std::unique_ptr<AudioDecoder>(std::move(audio_decoder_impl));
82+
} else {
83+
SB_LOG(ERROR) << "Failed to create audio decoder for codec "
84+
<< audio_stream_info.codec;
8285
}
8386
} else if (audio_stream_info.codec == kSbMediaAudioCodecAac &&
8487
audio_stream_info.number_of_channels <=
@@ -92,6 +95,9 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
9295
if (audio_decoder_impl && audio_decoder_impl->is_valid()) {
9396
SB_LOG(INFO) << "Playing audio using FfmpegAudioDecoder";
9497
return std::unique_ptr<AudioDecoder>(std::move(audio_decoder_impl));
98+
} else {
99+
SB_LOG(ERROR) << "Failed to create audio decoder for codec "
100+
<< audio_stream_info.codec;
95101
}
96102
}
97103
return std::unique_ptr<AudioDecoder>();

‎starboard/loader_app/BUILD.gn‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,9 @@ static_library("installation_manager") {
253253
}
254254

255255
if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) {
256-
target(starboard_level_gtest_target_type, "installation_manager_test") {
256+
source_set("installation_manager_test") {
257257
testonly = true
258258
sources = [
259-
"//starboard/common/test_main.cc",
260259
"installation_manager_test.cc",
261260
"pending_restart_test.cc",
262261
]
@@ -299,14 +298,11 @@ static_library("slot_management") {
299298
configs += [ "//third_party/jsoncpp:jsoncpp_config" ]
300299
}
301300
if (sb_is_evergreen) {
302-
target(starboard_level_gtest_target_type, "slot_management_test") {
301+
source_set("slot_management_test") {
303302
testonly = true
304303
build_loader = false
305304

306-
sources = [
307-
"//starboard/common/test_main.cc",
308-
"slot_management_test.cc",
309-
]
305+
sources = [ "slot_management_test.cc" ]
310306
deps = [
311307
":app_key_files",
312308
":drain_file",
@@ -354,12 +350,9 @@ if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) {
354350
deps = [ "//starboard:starboard_group" ]
355351
}
356352

357-
target(starboard_level_gtest_target_type, "reset_evergreen_update_test") {
353+
source_set("reset_evergreen_update_test") {
358354
testonly = true
359-
sources = [
360-
"//starboard/common/test_main.cc",
361-
"reset_evergreen_update_test.cc",
362-
]
355+
sources = [ "reset_evergreen_update_test.cc" ]
363356
deps = [
364357
":reset_evergreen_update",
365358
"//starboard:starboard_with_main",

‎starboard/loader_app/installation_manager_test.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class InstallationManagerTest : public ::testing::TestWithParam<int> {
198198
if (result || !dirent) {
199199
break;
200200
}
201-
starboard::strlcpy(dir_entry.data(), dirent->d_name, dir_entry.size());
201+
strncpy(dir_entry.data(), dirent->d_name, dir_entry.size());
202202
std::string full_path = storage_path_;
203203
full_path += kSbFileSepString;
204204
full_path += dir_entry.data();

‎starboard/loader_app/pending_restart_test.cc‎

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

1515
#include "starboard/loader_app/pending_restart.h"
1616

17+
#include "starboard/configuration.h"
1718
#include "starboard/loader_app/installation_manager.h"
1819
#include "testing/gtest/include/gtest/gtest.h"
1920

‎starboard/raspi/shared/BUILD.gn‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,3 @@ static_library("starboard_base_symbolize") {
271271
public_deps = [ "//starboard/elf_loader:evergreen_info" ]
272272
}
273273
}
274-
275-
if (current_toolchain == starboard_toolchain) {
276-
target(starboard_level_gtest_target_type, "starboard_platform_tests") {
277-
build_loader = false
278-
testonly = true
279-
280-
sources = player_tests_sources + [ "//starboard/common/test_main.cc" ]
281-
282-
configs += [ "//starboard/build/config:starboard_implementation" ]
283-
284-
deps = [
285-
"//starboard:starboard_with_main",
286-
"//starboard/shared/starboard/player/filter/testing:test_util",
287-
"//testing/gmock",
288-
"//testing/gtest",
289-
]
290-
}
291-
}

‎starboard/shared/starboard/media/media_util.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ int64_t AudioFramesToDuration(int frames, int samples_per_second) {
442442
return frames * 1'000'000LL / std::max(samples_per_second, 1);
443443
}
444444

445+
bool IsProprietaryAudioCodec(const char* file_name) {
446+
const auto file_name_as_string = std::string(file_name);
447+
return (file_name_as_string.find("heaac") != std::string::npos) ||
448+
(file_name_as_string.find("_aac") != std::string::npos) ||
449+
(file_name_as_string.find("_ec3") != std::string::npos) ||
450+
(file_name_as_string.find("_ac3") != std::string::npos);
451+
}
452+
445453
} // namespace media
446454
} // namespace starboard
447455
} // namespace shared

0 commit comments

Comments
 (0)