From 475b862fdb1aeeb78e13d8b27aec37ead95267ae Mon Sep 17 00:00:00 2001 From: Giuseppe Ottaviano Date: Wed, 14 Aug 2024 06:58:38 -0700 Subject: [PATCH] Re-enable CacheLocality.LinuxActual test under remote execution Reviewed By: r1mikey Differential Revision: D61265741 fbshipit-source-id: dd8456bd450fa46fd967fcbb9195e510355ca313 --- folly/concurrency/test/BUCK | 1 + folly/concurrency/test/CacheLocalityTest.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/folly/concurrency/test/BUCK b/folly/concurrency/test/BUCK index c9a0b113148..7d5424af1b2 100644 --- a/folly/concurrency/test/BUCK +++ b/folly/concurrency/test/BUCK @@ -27,6 +27,7 @@ cpp_unittest( "//folly/concurrency:cache_locality", "//folly/portability:gtest", "//folly/portability:sys_resource", + "//folly/portability:unistd", "//folly/test:test_utils", ], external_deps = [ diff --git a/folly/concurrency/test/CacheLocalityTest.cpp b/folly/concurrency/test/CacheLocalityTest.cpp index 18770101ddc..386bd2371ba 100644 --- a/folly/concurrency/test/CacheLocalityTest.cpp +++ b/folly/concurrency/test/CacheLocalityTest.cpp @@ -16,7 +16,6 @@ #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include @@ -981,14 +981,16 @@ TEST(CacheLocality, LinuxActual) { return; } - auto in_re = ::getenv("RE_PLATFORM"); - SKIP_IF(in_re != nullptr); + // CacheLocality reports the topology for all cpus, even those that are not + // available in the current environment (for example a container with pinned + // CPUs), so we can't use _SC_NPROCESSORS_ONLN or std::hardware_concurrency(). + auto expectedNumCpus = sysconf(_SC_NPROCESSORS_CONF); auto parsed1 = CacheLocality::readFromProcCpuinfo(); - EXPECT_EQ(parsed1.numCpus, std::thread::hardware_concurrency()); + EXPECT_EQ(parsed1.numCpus, expectedNumCpus); auto parsed2 = CacheLocality::readFromSysfs(); - EXPECT_EQ(parsed2.numCpus, std::thread::hardware_concurrency()); + EXPECT_EQ(parsed2.numCpus, expectedNumCpus); LOG(INFO) << fmt::format( "[cpuinfo] numCachesByLevel={}", parsed1.numCachesByLevel);