-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starboard: support --v for verbosity (#4583)
Starboard builds and in particular the nplb integration test support a command line flag --min_log_level=(info|warning|error|fatal). Chromium binaries prefer in general --v (or -v) for this purpose. This CL adds logic to handle --v; to preserve previous behaviour, if and when both --min_log_level and --v are present, the former takes precedence. This CL also add unit tests for the translation between flag arguments and log level. First instance of starboard_unittests ! Bug: 378879686 Bug: 384819454
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2024 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "starboard/common/log.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace starboard { | ||
namespace logging { | ||
|
||
static const std::map<SbLogPriority, std::string> kSbLogPriorityToString = { | ||
{kSbLogPriorityUnknown, "unknown"}, | ||
{kSbLogPriorityInfo, "info"}, | ||
{kSbLogPriorityWarning, "warning"}, | ||
{kSbLogPriorityError, "error"}, | ||
{kSbLogPriorityFatal, "fatal"}}; | ||
|
||
struct TextAndSbPriority { | ||
const std::string text; | ||
const SbLogPriority sb_log_priority; | ||
}; | ||
|
||
using MinLogLevelTranslationTest = testing::TestWithParam<TextAndSbPriority>; | ||
|
||
TEST_P(MinLogLevelTranslationTest, ExpectedBehaviour) { | ||
EXPECT_EQ(StringToLogLevel(GetParam().text), GetParam().sb_log_priority); | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
, | ||
MinLogLevelTranslationTest, | ||
testing::ValuesIn(std::vector<struct TextAndSbPriority>{ | ||
{"", SB_LOG_INFO}, | ||
{"blabla", SB_LOG_INFO}, | ||
{"info", SB_LOG_INFO}, | ||
{"warning", SB_LOG_WARNING}, | ||
{"error", SB_LOG_ERROR}, | ||
{"fatal", SB_LOG_FATAL}, | ||
}), | ||
[](const testing::TestParamInfo<MinLogLevelTranslationTest::ParamType>& | ||
info) { | ||
return "from_" + info.param.text + "_to_" + | ||
kSbLogPriorityToString.at(info.param.sb_log_priority); | ||
}); | ||
|
||
using ChromiumLogLevelTranslationTest = | ||
testing::TestWithParam<TextAndSbPriority>; | ||
|
||
TEST_P(ChromiumLogLevelTranslationTest, ExpectedBehaviour) { | ||
EXPECT_EQ(ChromiumIntToStarboardLogLevel(GetParam().text), | ||
GetParam().sb_log_priority); | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
, | ||
ChromiumLogLevelTranslationTest, | ||
testing::ValuesIn(std::vector<struct TextAndSbPriority>{ | ||
{"0", SB_LOG_INFO}, | ||
{"1", SB_LOG_INFO}, | ||
{"2", SB_LOG_WARNING}, | ||
{"3", SB_LOG_ERROR}, | ||
{"4", SB_LOG_FATAL}, | ||
{"5", SB_LOG_INFO}, | ||
{"100", SB_LOG_INFO}, | ||
}), | ||
[](const testing::TestParamInfo<ChromiumLogLevelTranslationTest::ParamType>& | ||
info) { | ||
return "from_" + info.param.text + "_to_" + | ||
kSbLogPriorityToString.at(info.param.sb_log_priority); | ||
}); | ||
} // namespace logging | ||
} // namespace starboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters