Skip to content

Commit 06e5f7c

Browse files
committed
test: cover GetNumThreads default
1 parent e8c853a commit 06e5f7c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/core/util/tests/util.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <gtest/gtest.h>
44

5+
#include <libenvpp/detail/get.hpp>
56
#include <string_view>
67

78
#include "omp.h"
@@ -15,15 +16,14 @@ TEST(util_tests, extracts_correct_namespace) {
1516
EXPECT_EQ(kNs, "my::nested");
1617
}
1718

18-
TEST(util_tests, threads_control_check_openmp_disabled_valgrind) {
19-
int ppc_num_threads = ppc::util::GetNumThreads();
19+
TEST(util_tests, GetNumThreadsEnvUnsetReturn) {
20+
const auto num_threads_env_var = env::get<int>("PPC_NUM_THREADS");
2021

21-
int omp_num_threads = -1;
22-
#pragma omp parallel default(none) shared(omp_num_threads) num_threads(ppc::util::GetNumThreads())
23-
omp_num_threads = omp_get_num_threads();
24-
25-
// Check Result
26-
ASSERT_EQ(ppc_num_threads, omp_num_threads);
22+
if (num_threads_env_var.has_value()) {
23+
EXPECT_EQ(ppc::util::GetNumThreads(), omp_get_num_threads());
24+
} else {
25+
GTEST_SKIP() << "PPC_NUM_THREADS environment variable is set, skipping test";
26+
}
2727
}
2828

2929
namespace test_ns {

0 commit comments

Comments
 (0)