Skip to content

Remove misc-include-cleaner suppression in util_tests.cpp #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions modules/core/util/func_tests/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@

#include "core/util/include/util.hpp"

#ifndef _WIN32
extern "C" int unsetenv(const char* name);
extern "C" int setenv(const char* name, const char* value, int overwrite);
#endif

TEST(util_tests, check_unset_env) {
#ifndef _WIN32
int save_var = ppc::util::GetPPCNumThreads();

unsetenv("OMP_NUM_THREADS"); // NOLINT(misc-include-cleaner)
unsetenv("OMP_NUM_THREADS");

EXPECT_EQ(ppc::util::GetPPCNumThreads(), 1);

setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1);
#else
GTEST_SKIP();
#endif
Expand All @@ -25,11 +30,11 @@ TEST(util_tests, check_set_env) {
int save_var = ppc::util::GetPPCNumThreads();

const int num_threads = static_cast<int>(std::thread::hardware_concurrency());
setenv("OMP_NUM_THREADS", std::to_string(num_threads).c_str(), 1); // NOLINT(misc-include-cleaner)
setenv("OMP_NUM_THREADS", std::to_string(num_threads).c_str(), 1);

EXPECT_EQ(ppc::util::GetPPCNumThreads(), num_threads);

setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1);
#else
GTEST_SKIP();
#endif
Expand Down
Loading