diff --git a/base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp b/base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp index b58020a24e0..f6286470283 100644 --- a/base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp +++ b/base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp @@ -20,6 +20,7 @@ #include namespace cuttlefish { +namespace { char pipe_message[] = "Testing the pipe"; @@ -34,4 +35,5 @@ TEST(SendFD, Basic) { EXPECT_EQ(0, strcmp(buf, pipe_message)); } -} +} // namespace +} // namespace cuttlefish diff --git a/base/cvd/cuttlefish/common/libs/utils/base64_test.cpp b/base/cvd/cuttlefish/common/libs/utils/base64_test.cpp index 83cbd770490..ae162e26dfb 100644 --- a/base/cvd/cuttlefish/common/libs/utils/base64_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/base64_test.cpp @@ -25,6 +25,7 @@ #include "cuttlefish/result/result_type.h" namespace cuttlefish { +namespace { TEST(Base64Test, EncodeMult3) { ASSERT_THAT(EncodeBase64("foobar"), IsOkAndValue("Zm9vYmFy")); @@ -70,4 +71,6 @@ TEST(Base64Test, EncodeThreeZeroes) { ASSERT_THAT(DecodeBase64(*string_encoding), IsOkAndValue(in)); } -} + +} // namespace +} // namespace cuttlefish diff --git a/base/cvd/cuttlefish/common/libs/utils/files_test.cpp b/base/cvd/cuttlefish/common/libs/utils/files_test.cpp index 3cd20a48dc8..4eecb40e8d1 100644 --- a/base/cvd/cuttlefish/common/libs/utils/files_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/files_test.cpp @@ -29,6 +29,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { using testing::IsTrue; @@ -227,4 +228,5 @@ TEST(FilesTest, SearchFileNotFoundReturnsError) { EXPECT_FALSE(result.ok()); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/common/libs/utils/flag_parser_test.cpp b/base/cvd/cuttlefish/common/libs/utils/flag_parser_test.cpp index 33022b42e64..f3f7cd48fb0 100644 --- a/base/cvd/cuttlefish/common/libs/utils/flag_parser_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/flag_parser_test.cpp @@ -32,6 +32,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { TEST(FlagParser, DuplicateAlias) { FlagAlias alias = {FlagAliasMode::kFlagExact, "--flag"}; @@ -481,4 +482,5 @@ TEST_F(FlagConsumesArbitraryTest, TwoValuesOtherFlag) { ASSERT_EQ(elems_, (std::vector{"v1", "v2", ""})); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/common/libs/utils/proc_file_utils_test.cpp b/base/cvd/cuttlefish/common/libs/utils/proc_file_utils_test.cpp index fe308987cfb..d385b737503 100644 --- a/base/cvd/cuttlefish/common/libs/utils/proc_file_utils_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/proc_file_utils_test.cpp @@ -25,6 +25,7 @@ #include "cuttlefish/common/libs/utils/proc_file_utils.h" namespace cuttlefish { +namespace { TEST(ProcFileUid, SelfUidTest) { auto my_pid = getpid(); @@ -43,4 +44,5 @@ TEST(ProcFilePid, CurrentPidCollected) { ASSERT_TRUE(Contains(*pids_result, this_pid)); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/common/libs/utils/unix_sockets_test.cpp b/base/cvd/cuttlefish/common/libs/utils/unix_sockets_test.cpp index 3d733deef89..0149dd54a79 100644 --- a/base/cvd/cuttlefish/common/libs/utils/unix_sockets_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/unix_sockets_test.cpp @@ -27,6 +27,7 @@ #include "cuttlefish/common/libs/fs/shared_fd.h" namespace cuttlefish { +namespace { SharedFD CreateMemFDWithData(const std::string& data) { auto memfd = SharedFD::MemfdCreate(""); @@ -197,4 +198,5 @@ TEST(UnixMessageSocket, AutoCredentials) { ASSERT_EQ(getgid(), credentials_out->gid); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/unittest/utils_tests.cpp b/base/cvd/cuttlefish/host/commands/assemble_cvd/unittest/utils_tests.cpp index b8eeaa8057e..074021d6e95 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/unittest/utils_tests.cpp +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/unittest/utils_tests.cpp @@ -22,6 +22,7 @@ #include "launch_cvd.pb.h" namespace cuttlefish { +namespace { TEST(DisplayConfigTest, ParseProto) { std::string flag_value = "ChoKCgi4CBDYBBh4IDwKDAi4CBDYBBh4IDwqAA=="; @@ -42,4 +43,5 @@ TEST(DisplayConfigTest, ParseProto) { ASSERT_TRUE(result); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/frontline_parser_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/frontline_parser_test.cpp index 627d8380ef8..e95e29170ce 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/frontline_parser_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/frontline_parser_test.cpp @@ -21,6 +21,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { TEST(FrontlineParserTest, SelectorArgs) { cvd_common::Args input{"cvd", "--instance_name=1", "status"}; @@ -32,4 +33,5 @@ TEST(FrontlineParserTest, SelectorArgs) { ASSERT_EQ(input, (std::vector{"cvd", "status"})); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/configs_inheritance_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/configs_inheritance_test.cc index 57d78f9037f..a732f0f96a2 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/configs_inheritance_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/configs_inheritance_test.cc @@ -23,6 +23,7 @@ #include "cuttlefish/host/commands/cvd/cli/parser/test_common.h" namespace cuttlefish { +namespace { TEST(FlagsInheritanceTest, MergeTwoIndependentJson) { const char* dst_string = R""""( @@ -140,4 +141,5 @@ TEST(FlagsInheritanceTest, MergeTwoOverlappedJson) { EXPECT_EQ(dst_object["instances"][0]["vm"]["memory_mb"], 2048); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/flags_parser_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/flags_parser_test.cc index 77c4f144dca..61f9c30e6ae 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/flags_parser_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/flags_parser_test.cc @@ -22,6 +22,7 @@ #include "cuttlefish/host/commands/cvd/cli/parser/test_common.h" namespace cuttlefish { +namespace { TEST(FlagsParserTest, ParseInvalidJson) { const char* test_string = R""""( @@ -170,4 +171,5 @@ TEST(BootFlagsParserTest, ParseNetSimFlagEnabled) { << "netsim_uwb flag is missing or wrongly formatted"; } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/boot_configs_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/boot_configs_test.cc index d24b4c2e5f8..7ea6662604e 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/boot_configs_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/boot_configs_test.cc @@ -21,6 +21,7 @@ #include "cuttlefish/host/commands/cvd/cli/parser/test_common.h" namespace cuttlefish { +namespace { TEST(BootFlagsParserTest, ParseTwoInstancesBootAnimationFlagEmptyJson) { const char* test_string = R""""( @@ -352,4 +353,5 @@ TEST(BootFlagsParserTest, ParseTwoInstancesEnforceSecurityFlagFullJson) { << "guest_enforce_security flag is missing or wrongly formatted"; } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/disk_configs_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/disk_configs_test.cc index 404925c3bcb..40c61a23383 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/disk_configs_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/disk_configs_test.cc @@ -21,6 +21,7 @@ #include "cuttlefish/host/commands/cvd/cli/parser/test_common.h" namespace cuttlefish { +namespace { TEST(BootFlagsParserTest, ParseTwoInstancesBlankDataImageEmptyJson) { const char* test_string = R""""( @@ -108,4 +109,5 @@ TEST(BootFlagsParserTest, ParseTwoInstancesBlankDataImageFullJson) { << "blank_data_image_mb flag is missing or wrongly formatted"; } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/graphics_configs_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/graphics_configs_test.cc index 07bf64e96a7..f6ea3414d11 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/graphics_configs_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/graphics_configs_test.cc @@ -31,11 +31,12 @@ #include "cuttlefish/host/commands/cvd/cli/parser/test_common.h" #include "cuttlefish/result/result_matchers.h" +namespace cuttlefish { +namespace { + using google::protobuf::Message; using google::protobuf::util::MessageDifferencer; -namespace cuttlefish { - // TODO: schuffelen - make this into a matcher static void AssertProtoEquals(const Message& expected, const Message& actual) { MessageDifferencer diff; @@ -241,4 +242,5 @@ TEST(BootFlagsParserTest, ParseTwoInstancesAutoTabletDisplaysFlag) { AssertProtoEquals(expected, (*display).value()); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/vm_configs_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/vm_configs_test.cc index f56a2b586c7..b92348488df 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/vm_configs_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/vm_configs_test.cc @@ -26,6 +26,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { TEST(VmFlagsParserTest, ParseTwoInstancesCpuFlagEmptyJson) { const char* test_string = R""""( @@ -994,4 +995,5 @@ TEST(VmFlagsParserTest, ParseTwoInstancesCustomActionsFlagPartialJson) { EXPECT_THAT(ParseJson(custom_actions[0]), IsOkAndValue(expected_actions)); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/metrics_configs_test.cc b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/metrics_configs_test.cc index 5de4eb3baf0..39e8891bf0a 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/parser/metrics_configs_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/parser/metrics_configs_test.cc @@ -25,6 +25,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { using ::testing::IsTrue; using ::testing::Not; @@ -125,4 +126,5 @@ TEST(MetricsFlagsParserTest, ParseTwoInstancesMetricsReportFlagEmptyJson) { << "report_anonymous_usage_stats flag is missing or wrongly formatted"; } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/creation_analyzer_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/creation_analyzer_test.cpp index 86e97a77eee..6cb6b781ef7 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/creation_analyzer_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/creation_analyzer_test.cpp @@ -45,8 +45,6 @@ std::string AutoGeneratedHome(const std::string& subdir) { return parent + "/" + std::to_string(getuid()) + "/" + subdir; } -} // namespace - static auto home_test_inputs = testing::Values( InputOutput{ .cmd_args = "cvd start --daemon", @@ -284,5 +282,6 @@ TEST(AutoHomeTest, DefaultFollowedByNonDefaultTest) { << result_2nd_non_default.error().Trace(); } +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/cvd_flags_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/cvd_flags_test.cpp index d430e6c87c4..3e663a0fa58 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/cvd_flags_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/cvd_flags_test.cpp @@ -17,6 +17,7 @@ #include "cuttlefish/host/commands/cvd/unittests/selector/cvd_flags_helper.h" namespace cuttlefish { +namespace { TEST_F(CvdFlagCollectionTest, Init) { auto output_result = flag_collection_.FilterFlags(input_); @@ -70,4 +71,5 @@ TEST(CvdFlagTest, FlagProxyFilter) { cvd_common::Args{"--bar --foo=name --enable_vnc"}); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/host_tool_target_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/host_tool_target_test.cpp index ff41be09357..5ed0a0ddab0 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/host_tool_target_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/host_tool_target_test.cpp @@ -22,6 +22,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { TEST(HostToolTarget, KnownFlags) { std::string android_host_out = StringFromEnv("ANDROID_HOST_OUT", ""); @@ -60,4 +61,5 @@ TEST(HostToolManager, KnownBins) { << "stop_bin was " << *stop_bin; } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_ids_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_ids_test.cpp index 86c53ed9ced..6020b7826c7 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_ids_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_ids_test.cpp @@ -20,6 +20,7 @@ namespace cuttlefish { namespace selector { +namespace { TEST_P(InstanceIdTest, InstanceIdCalculation) { auto selector_options_res = ParseCommonSelectorArguments(selector_args_); @@ -122,5 +123,6 @@ INSTANTIATE_TEST_SUITE_P( .requested_num_instances = 3, .expected_result = false})); +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_names_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_names_test.cpp index 13fb886a61a..dee56e1cdcb 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_names_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/selector/parser_names_test.cpp @@ -23,6 +23,7 @@ namespace cuttlefish { namespace selector { +namespace { TEST_P(ValidNamesTest, ValidInputs) { auto selector_options_res = ParseCommonSelectorArguments(selector_args_); @@ -89,5 +90,6 @@ INSTANTIATE_TEST_SUITE_P(CvdParser, InvalidNamesTest, "--group_name=3a", "--instance_name", "--instance_name=*7a")); +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/fetch/downloaders_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/fetch/downloaders_test.cpp index ee0175ced30..fd783ebf88a 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/fetch/downloaders_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/fetch/downloaders_test.cpp @@ -28,6 +28,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { std::string CreateTempFileWithText(const std::string& filepath, const std::string& text) { @@ -123,4 +124,5 @@ TEST_F(FetchCvdTests, CasDownloaderInvokedIfDownloaderPathSetInCasConfig) { EXPECT_THAT(FileExists(cas_output_filepath_), IsTrue()); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd_parser_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd_parser_test.cpp index 34868fba057..d7204faae6e 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd_parser_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd_parser_test.cpp @@ -25,6 +25,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { using testing::Eq; @@ -60,4 +61,5 @@ TEST(FetchCvdParserTests, CreatesCasDownloaderFlags) { Eq(10000000000)); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database_test.cpp index ef753a03eb8..3e1e0590761 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database_test.cpp @@ -50,6 +50,7 @@ namespace cuttlefish { namespace selector { +namespace { LocalInstanceGroup::Builder GroupParamWithInstances( const std::string& name, const std::string& home_dir, @@ -404,5 +405,6 @@ TEST_F(CvdInstanceDatabaseTest, UpdateInstances) { EXPECT_EQ(find_res->Instances()[1].state(), cvd::INSTANCE_STATE_STARTING); } +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_group_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_group_test.cpp index a5876cfc9dc..d4dff4a9d80 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_group_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_group_test.cpp @@ -24,6 +24,7 @@ namespace cuttlefish { namespace selector { +namespace { static std::string GroupName() { return "yah_ong"; } @@ -81,5 +82,6 @@ TEST_F(LocalInstanceGroupUnitTest, SearchById) { } } +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_test.cpp index 1dbc54e28dc..a30c9de2b6e 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/local_instance_test.cpp @@ -19,6 +19,7 @@ namespace cuttlefish { namespace selector { +namespace { /** * Note that invalid inputs must be tested at the InstanceDatabase level @@ -47,5 +48,6 @@ TEST(LocalinstanceTest, Fields) { EXPECT_EQ(parent_group.Proto().name(), "super"); } +} // namespace } // namespace selector } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/autogen_ids_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/autogen_ids_test.cpp index d5cfe54578e..60b6674118a 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/autogen_ids_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/autogen_ids_test.cpp @@ -23,6 +23,7 @@ #include "cuttlefish/host/commands/cvd/unittests/server/utils.h" namespace cuttlefish { +namespace { TEST(CvdAutoGenId, CvdTwoFollowedByFive) { cvd_common::Envs envs; @@ -68,4 +69,5 @@ TEST(CvdAutoGenId, CvdTwoFollowedByFive) { CmdRunner::Run("cvd reset -y", envs); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/basic_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/basic_test.cpp index 45df17425e5..7b45495622d 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/basic_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/basic_test.cpp @@ -22,6 +22,7 @@ #include "cuttlefish/host/commands/cvd/unittests/server/cmd_runner.h" namespace cuttlefish { +namespace { TEST(CvdBasic, CvdDefaultStart) { cvd_common::Envs envs; @@ -49,4 +50,5 @@ TEST(CvdBasic, CvdDefaultStart) { CmdRunner::Run("cvd reset -y", envs); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/clear_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/clear_test.cpp index 40712eef060..5aea477f64b 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/clear_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/clear_test.cpp @@ -23,6 +23,7 @@ #include "cuttlefish/host/commands/cvd/unittests/server/utils.h" namespace cuttlefish { +namespace { TEST(CvdClear, ClearAfterThreeStarts) { cvd_common::Envs envs; @@ -73,4 +74,5 @@ TEST(CvdClear, ClearAfterThreeStarts) { CmdRunner::Run("cvd reset -y", envs); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/collect_flags_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/collect_flags_test.cpp index 1d334f0d84b..542cf57c5a6 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/collect_flags_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/collect_flags_test.cpp @@ -26,6 +26,7 @@ #include "cuttlefish/host/commands/cvd/utils/flags_collector.h" namespace cuttlefish { +namespace { TEST(CvdHelpFlagCollect, LauncCvd) { cvd_common::Envs envs; @@ -58,4 +59,5 @@ TEST(CvdHelpFlagCollect, LauncCvd) { ASSERT_EQ(bad_flag_itr, flags.cend()); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/help_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/help_test.cpp index c269c7ea793..25c2a5af66e 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/help_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/help_test.cpp @@ -58,8 +58,6 @@ bool MaybeCvdStart(const CmdResult& result) { return ContainsAll(stdout, {"vhost", "modem", "daemon", "adb"}); } -} // namespace - TEST(CvdDriver, CvdHelp) { cvd_common::Envs envs; CmdRunner::Run("cvd reset -y", envs); @@ -137,4 +135,5 @@ TEST(CvdSubtool, CvdStartHelp) { CmdRunner::Run("cvd reset -y", envs); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/instance_ids_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/instance_ids_test.cpp index 0f06012ba8e..2c490229f89 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/instance_ids_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/instance_ids_test.cpp @@ -22,6 +22,7 @@ #include "cuttlefish/host/commands/cvd/unittests/server/utils.h" namespace cuttlefish { +namespace { TEST(CvdInstanceIds, CvdTakenInstanceIds) { cvd_common::Envs envs; @@ -74,4 +75,5 @@ TEST(CvdInstanceIds, CvdTakenInstanceIds) { CmdRunner::Run("cvd reset -y", envs); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/snapshot_test.cpp b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/snapshot_test.cpp index 1c5ee6925a2..defe7607063 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/unittests/server/snapshot_test.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/unittests/server/snapshot_test.cpp @@ -25,6 +25,7 @@ namespace cuttlefish { namespace cvdsnapshot { +namespace { TEST_F(CvdSnapshotTest, CvdSuspendResume) { auto cmd_suspend = CmdRunner::Run("cvd suspend", envs); @@ -83,5 +84,6 @@ TEST_F(CvdSnapshotTest, CvdSuspendSnapshotResumeRestore) { ASSERT_TRUE(cmd_rm.Success()) << cmd_rm.Stderr(); } +} // namespace } // namespace cvdsnapshot } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/gpx_parser_test.cc b/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/gpx_parser_test.cc index a21ddb7eff3..92648006424 100644 --- a/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/gpx_parser_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/gpx_parser_test.cc @@ -22,8 +22,8 @@ #include "cuttlefish/host/libs/location/StringParse.h" namespace cuttlefish { - namespace { + bool ParseGpxFile(GpsFixArray* locations, char* text, std::string* error) { bool result; TemporaryDir myDir; @@ -43,8 +43,6 @@ bool ParseGpxString(GpsFixArray* locations, char* text, std::string* error) { return result; } -} // namespace - TEST(GpxParser, ParseFileNotFound) { GpsFixArray locations; std::string error; @@ -378,4 +376,5 @@ TEST(GpxParser, ParseValidDocumentString) { EXPECT_EQ("Trkpt 2-2", locations[7].name); } +} // namespace } // namespace cuttlefish \ No newline at end of file diff --git a/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/kml_parser_test.cc b/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/kml_parser_test.cc index 6b59b108a53..c6c52bddfb4 100644 --- a/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/kml_parser_test.cc +++ b/base/cvd/cuttlefish/host/commands/cvd_import_locations/unittest/kml_parser_test.cc @@ -41,7 +41,6 @@ bool ParseKmlString(GpsFixArray* locations, char* text, std::string* error) { result = KmlParser::parseString(text, strlen(text), locations, error); return result; } -} // namespace TEST(KmlParser, ParseNonexistentFile) { GpsFixArray locations; @@ -658,4 +657,5 @@ TEST(KmlParser, ParsePlacemarkNullNameNoCrashString) { EXPECT_STREQ("", locations.front().description.c_str()); } +} // namespace } // namespace cuttlefish \ No newline at end of file diff --git a/base/cvd/cuttlefish/host/commands/metrics/utils_tests.cpp b/base/cvd/cuttlefish/host/commands/metrics/utils_tests.cpp index 2acc91393cf..b3db54d8f50 100644 --- a/base/cvd/cuttlefish/host/commands/metrics/utils_tests.cpp +++ b/base/cvd/cuttlefish/host/commands/metrics/utils_tests.cpp @@ -21,6 +21,8 @@ #include "cuttlefish/host/commands/metrics/utils.h" namespace cuttlefish { +namespace { + TEST(MacAddressTest, ValidMacAddress) { std::string mac = metrics::GetMacAddress(); ASSERT_FALSE(mac.empty()); @@ -38,4 +40,5 @@ TEST(MacAddressTest, MacAddressFormat) { EXPECT_EQ(mac[14], ':'); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/command_parser_test.cpp b/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/command_parser_test.cpp index c1d53762ab5..78b93f6f218 100644 --- a/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/command_parser_test.cpp +++ b/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/command_parser_test.cpp @@ -17,6 +17,8 @@ #include +namespace { + TEST(CommandParserUnitTest, SkipPrefix) { std::string command = "AT+SPUSATENVECMD=\"D3078202018190014E\""; @@ -101,3 +103,5 @@ TEST(CommandParserUnitTest, GetNextStrDeciToHex) { std::string result2(cmd.GetNextStrDeciToHex()); ASSERT_STREQ("6F05", result2.c_str()); // 28421 } + +} // namespace diff --git a/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/pdu_parser_test.cpp b/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/pdu_parser_test.cpp index 7eb00b5ae58..4ae9868c14e 100644 --- a/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/pdu_parser_test.cpp +++ b/base/cvd/cuttlefish/host/commands/modem_simulator/unittest/pdu_parser_test.cpp @@ -17,6 +17,8 @@ #include +namespace { + TEST(PDUParserTest, IsValidPDU_true) { std::string pdu = "0001000D91688118109844F0000017AFD7903AB55A9BBA69D639D4ADCBF99E3DCCAE9701"; cuttlefish::PDUParser smspdu(pdu); @@ -57,3 +59,5 @@ TEST(PDUParserTest, BCDToString) { const char *expect = "21436587"; ASSERT_STREQ(process_value.c_str(), expect); } + +} // namespace diff --git a/base/cvd/cuttlefish/host/commands/secure_env/encrypted_serializable_test.cpp b/base/cvd/cuttlefish/host/commands/secure_env/encrypted_serializable_test.cpp index 61b825c636d..356cd2296ba 100644 --- a/base/cvd/cuttlefish/host/commands/secure_env/encrypted_serializable_test.cpp +++ b/base/cvd/cuttlefish/host/commands/secure_env/encrypted_serializable_test.cpp @@ -25,6 +25,7 @@ #include "cuttlefish/host/commands/secure_env/tpm_resource_manager.h" namespace cuttlefish { +namespace { TEST(TpmEncryptedSerializable, BinaryData) { TestTpm tpm; @@ -52,4 +53,5 @@ TEST(TpmEncryptedSerializable, BinaryData) { ASSERT_EQ(0, memcmp(input_data, output.begin(), sizeof(input_data))); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/libs/config/adb/test.cpp b/base/cvd/cuttlefish/host/libs/config/adb/test.cpp index 1d1fff16447..5165e032d55 100644 --- a/base/cvd/cuttlefish/host/libs/config/adb/test.cpp +++ b/base/cvd/cuttlefish/host/libs/config/adb/test.cpp @@ -29,6 +29,7 @@ #include "cuttlefish/host/libs/feature/feature.h" namespace cuttlefish { +namespace { struct TestData { INJECT(TestData(AdbConfig& config, AdbConfigFragment& fragment)) @@ -79,4 +80,5 @@ TEST(AdbConfigTest, SerializeDeserialize) { ASSERT_EQ(data1.config.RunConnector(), data2.config.RunConnector()); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/libs/web/android_build_string_tests.cpp b/base/cvd/cuttlefish/host/libs/web/android_build_string_tests.cpp index b178e5e4ea2..29bc6f77e63 100644 --- a/base/cvd/cuttlefish/host/libs/web/android_build_string_tests.cpp +++ b/base/cvd/cuttlefish/host/libs/web/android_build_string_tests.cpp @@ -26,6 +26,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { using ::testing::ElementsAre; using ::testing::Eq; @@ -201,4 +202,5 @@ TEST(BuildStringGflagsCompatFlagTests, MultiValueMixedWithEmptySuccess) { DeviceBuildString{.branch_or_id = "abcde", .target = "test_target"})); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp index 35ce0e2e187..009df5ad66f 100644 --- a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp +++ b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp @@ -39,6 +39,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { std::string CreateTempFileWithText(const std::string& filepath, const std::string& text) { @@ -672,9 +673,11 @@ TEST_F(CasDownloaderTests, CacheMaxSize_OverriddenWhenTooSmall) { HasSubstr(fmt::format("-cache-max-size={}", kMinCacheMaxSize))); } +} // namespace + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } -} // namespace cuttlefish +} // namespace cuttlefish \ No newline at end of file diff --git a/base/cvd/cuttlefish/host/libs/web/cas/cas_flags_test.cpp b/base/cvd/cuttlefish/host/libs/web/cas/cas_flags_test.cpp index 5daa7587443..cbfbb9452ec 100644 --- a/base/cvd/cuttlefish/host/libs/web/cas/cas_flags_test.cpp +++ b/base/cvd/cuttlefish/host/libs/web/cas/cas_flags_test.cpp @@ -24,6 +24,7 @@ #include namespace cuttlefish { +namespace { class CasFlagsTests : public ::testing::Test { protected: @@ -197,4 +198,5 @@ TEST_F(CasFlagsTests, PriorityLogicCliBlocksConfig) { EXPECT_EQ(flag.value(), 200); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/io/in_memory_test.cc b/base/cvd/cuttlefish/io/in_memory_test.cc index c9ae1ae8579..1ca2771d096 100644 --- a/base/cvd/cuttlefish/io/in_memory_test.cc +++ b/base/cvd/cuttlefish/io/in_memory_test.cc @@ -25,6 +25,7 @@ #include "cuttlefish/result/result_matchers.h" namespace cuttlefish { +namespace { TEST(InMemoryIoTest, WriteSeek) { std::unique_ptr instance = InMemoryIo(); @@ -84,4 +85,5 @@ TEST(InMemoryIoTest, WriteWriteReadAt) { ASSERT_EQ(absl::StrCat(str, str), data_read); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/pretty/container_test.cc b/base/cvd/cuttlefish/pretty/container_test.cc index b791ab0e190..add09215b6a 100644 --- a/base/cvd/cuttlefish/pretty/container_test.cc +++ b/base/cvd/cuttlefish/pretty/container_test.cc @@ -38,8 +38,6 @@ void ExpectFormatsTo(const PrettyContainerType& ps, EXPECT_EQ(sstream.str(), trimmed); } -} // namespace - TEST(PrettyContainer, Empty) { ExpectFormatsTo(PrettyContainer(std::vector{}), "{}"); } @@ -96,4 +94,5 @@ TEST(PrettyContainer, NestedMember) { )"); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/pretty/json_test.cc b/base/cvd/cuttlefish/pretty/json_test.cc index bf754796ac0..483f17f310e 100644 --- a/base/cvd/cuttlefish/pretty/json_test.cc +++ b/base/cvd/cuttlefish/pretty/json_test.cc @@ -21,6 +21,7 @@ #include "json/value.h" namespace cuttlefish { +namespace { TEST(PrettyJson, Structured) { Json::Value structured; @@ -42,4 +43,5 @@ TEST(PrettyJson, Structured) { EXPECT_TRUE(absl::StrContains(formatted, "\"value\"")); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/pretty/pretty_test.cc b/base/cvd/cuttlefish/pretty/pretty_test.cc index 4b46e191828..f5ae3b749a2 100644 --- a/base/cvd/cuttlefish/pretty/pretty_test.cc +++ b/base/cvd/cuttlefish/pretty/pretty_test.cc @@ -71,8 +71,6 @@ PrettyStruct Pretty(const OuterStruct& outer, .Member("int_opt_unset", outer.int_opt_unset); } -} // namespace - TEST(Pretty, OuterInnerStruct) { OuterStruct outer{ .number_vector = {1, 2, 3}, @@ -152,4 +150,5 @@ OuterStruct { EXPECT_EQ(absl::StrCat(Pretty(outer)), expected); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/pretty/struct_test.cc b/base/cvd/cuttlefish/pretty/struct_test.cc index 4be0d789d71..64db823f784 100644 --- a/base/cvd/cuttlefish/pretty/struct_test.cc +++ b/base/cvd/cuttlefish/pretty/struct_test.cc @@ -37,8 +37,6 @@ void ExpectFormatsTo(const PrettyStruct& ps, const std::string_view expected) { EXPECT_EQ(sstream.str(), trimmed); } -} // namespace - TEST(PrettyStruct, Empty) { ExpectFormatsTo(PrettyStruct("Empty"), "Empty {}"); } @@ -87,4 +85,5 @@ Outer { )"); } +} // namespace } // namespace cuttlefish diff --git a/base/cvd/cuttlefish/result/result_test.cpp b/base/cvd/cuttlefish/result/result_test.cpp index a8b1885785e..9b6805da29f 100644 --- a/base/cvd/cuttlefish/result/result_test.cpp +++ b/base/cvd/cuttlefish/result/result_test.cpp @@ -30,8 +30,6 @@ namespace { using ::testing::HasSubstr; using ::testing::StrEq; -} // namespace - TEST(ResultTest, ExpectBoolGoodNoMessage) { const auto result = []() -> Result { CF_EXPECT(true); @@ -147,4 +145,5 @@ TEST(ResultTest, ExpectEqBadWithMessage) { IsErrorAndMessage(HasSubstr("ExpectEqBadWithMessage message"))); } +} // namespace } // namespace cuttlefish