diff --git a/test/config_test/BUILD b/test/config_test/BUILD index 496cac0e82f05..792ba3d603204 100644 --- a/test/config_test/BUILD +++ b/test/config_test/BUILD @@ -24,6 +24,7 @@ envoy_cc_test( ], deps = [ ":config_test_lib", + "//source/common/filesystem:filesystem_lib", "//test/test_common:environment_lib", "//test/test_common:utility_lib", ], diff --git a/test/config_test/example_configs_test.cc b/test/config_test/example_configs_test.cc index 2e02d41608be1..939b8df53e9cc 100644 --- a/test/config_test/example_configs_test.cc +++ b/test/config_test/example_configs_test.cc @@ -1,3 +1,5 @@ +#include "common/filesystem/filesystem_impl.h" + #include "test/config_test/config_test.h" #include "test/test_common/environment.h" #include "test/test_common/utility.h" @@ -5,10 +7,20 @@ #include "gtest/gtest.h" namespace Envoy { + TEST(ExampleConfigsTest, All) { TestEnvironment::exec( {TestEnvironment::runfilesPath("test/config_test/example_configs_test_setup.sh")}); +#ifdef WIN32 + Filesystem::InstanceImplWin32 file_system; +#else + Filesystem::InstanceImplPosix file_system; +#endif + + const auto config_file_count = std::stoi( + file_system.fileReadToEnd(TestEnvironment::temporaryDirectory() + "/config-file-count.txt")); + // Change working directory, otherwise we won't be able to read files using relative paths. #ifdef PATH_MAX char cwd[PATH_MAX]; @@ -19,12 +31,7 @@ TEST(ExampleConfigsTest, All) { RELEASE_ASSERT(::getcwd(cwd, sizeof(cwd)) != nullptr, ""); RELEASE_ASSERT(::chdir(directory.c_str()) == 0, ""); -#if defined(__APPLE__) || defined(WIN32) - // freebind/freebind.yaml is not supported on macOS or Windows and is disabled via Bazel. - EXPECT_EQ(37UL, ConfigTest::run(directory)); -#else - EXPECT_EQ(38UL, ConfigTest::run(directory)); -#endif + EXPECT_EQ(config_file_count, ConfigTest::run(directory)); ConfigTest::testMerge(); diff --git a/test/config_test/example_configs_test_setup.sh b/test/config_test/example_configs_test_setup.sh index 876438e7bea15..49c2066add89d 100755 --- a/test/config_test/example_configs_test_setup.sh +++ b/test/config_test/example_configs_test_setup.sh @@ -5,3 +5,6 @@ set -e DIR="$TEST_TMPDIR"/test/config_test mkdir -p "$DIR" tar -xvf "$TEST_SRCDIR"/envoy/configs/example_configs.tar -C "$DIR" + +# find uses full path to prevent using Windows find on Windows. +/usr/bin/find "$DIR" -type f | grep -c .yaml > "$TEST_TMPDIR"/config-file-count.txt