-
Notifications
You must be signed in to change notification settings - Fork 396
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
Add test for omrsysinfo_is_running_in_container #6567
Conversation
477b8c0
to
a543007
Compare
a543007
to
0791836
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fvtest/porttest/si.cpp
Outdated
char *omr_running_in_docker = getenv("OMR_RUNNING_IN_DOCKER"); | ||
if ((NULL != omr_running_in_docker) && (0 == strcmp(omr_running_in_docker, "1"))) { | ||
isRunningInContainer = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Camel case syntax is required: https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md#variables.
char *omr_running_in_docker = getenv("OMR_RUNNING_IN_DOCKER"); | |
if ((NULL != omr_running_in_docker) && (0 == strcmp(omr_running_in_docker, "1"))) { | |
isRunningInContainer = true; | |
} | |
char *omrRunningInDocker = getenv("OMR_RUNNING_IN_DOCKER"); | |
if ((NULL != omrRunningInDocker) && (0 == strcmp(omrRunningInDocker, "1"))) { | |
isRunningInContainer = true; | |
} |
fvtest/porttest/si.cpp
Outdated
@@ -2376,6 +2376,7 @@ TEST(PortSysinfoTest, sysinfo_test_os_kernel_info) | |||
class CgroupTest : public ::testing::Test { | |||
protected: | |||
#if defined(LINUX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the cgroup API implementation, it uses defined(LINUX) && !defined(OMRZTPF)
. We will have to use this expression in the tests. We will also need to account for this in #6559 since it is unmerged.
fvtest/porttest/si.cpp
Outdated
#if defined(LINUX) | ||
ASSERT_EQ(isRunningInContainer, CgroupTest::isRunningInContainer); | ||
#else /* defined(LINUX) */ | ||
if (FALSE != runningInContainer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already a boolean.
if (FALSE != runningInContainer) { | |
if (runningInContainer) { |
BOOLEAN runningInContainer = omrsysinfo_is_running_in_container(); | ||
|
||
#if defined(LINUX) | ||
ASSERT_EQ(runningInContainer, CgroupTest::isRunningInContainer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment should be added: If this test fails, then it should be verified that OMR_RUNNING_IN_DOCKER
(env var) is correctly set. For a containerized run, OMR_RUNNING_IN_DOCKER
is set to 1
. For a non-containerized run, OMR_RUNNING_IN_DOCKER
is either unset or set to 0
.
Add test for omrsysinfo_is_running_in_container and fix cgroup tests when running in a cgroup v1 container. Issue: eclipse#1281 Signed-off-by: Eric Yang <[email protected]>
0791836
to
17e9d92
Compare
Done |
jenkins build all |
All are known failures unrelated to this PR.
Compiler issue. Tracked in #6556. Unrelated to this PR. Network issue. Tracked in #6516. Unrelated to this PR. |
All PR builds inside a Docker container have passed: #6570 (comment). Thus, approving the PR. |
Add test for omrsysinfo_is_running_in_container and fix cgroup tests when
running in a cgroup v1 container.
Issue: #1281
Signed-off-by: Eric Yang [email protected]