summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-03-08 13:32:37 -0800
committerShentubot <shentubot@google.com>2019-03-08 13:33:32 -0800
commit832589cb076a638ca53076ebb66afb9fac4597d1 (patch)
tree6918d3d1a5cbd135fcb4e50355de296ea976da1c
parentfbacb350391667fa9ffb78a84ae51a37d477aa02 (diff)
Fix tests which fail in kokoro
* open_create_test_runsc_ptrace_shared doesn't expect the write access to / * exec_test_runsc_ptrace_shared could not find /usr/share/zoneinfo/ * clock_gettime_test_runsc_ptrace_shared didn't expect that a thread cpu time can be zero. * affinity_test_runsc_ptrace_shared expected minimum 3 cpus PiperOrigin-RevId: 237509429 Change-Id: I477937e5d2cdf3f8720836bfa972abd35d8220a3
-rwxr-xr-xkokoro/run_tests.sh8
-rw-r--r--test/BUILD4
-rw-r--r--test/syscalls/BUILD5
-rw-r--r--test/syscalls/linux/affinity.cc1
-rw-r--r--test/syscalls/linux/clock_gettime.cc7
-rw-r--r--test/syscalls/linux/exec.cc8
6 files changed, 17 insertions, 16 deletions
diff --git a/kokoro/run_tests.sh b/kokoro/run_tests.sh
index 4980c716a..f0195a5a4 100755
--- a/kokoro/run_tests.sh
+++ b/kokoro/run_tests.sh
@@ -177,16 +177,10 @@ run_root_tests() {
# Run syscall unit tests.
run_syscall_tests() {
cd ${WORKSPACE_DIR}
- # TODO: Exclude tests which fail.
bazel \
"${BAZEL_RBE_FLAGS[@]}" \
test "${BAZEL_BUILD_RBE_FLAGS[@]}" \
- `bazel query //test/syscalls/... |
- grep runsc_ptrace |
- grep -v affinity_test_runsc_ptrace |
- grep -v exec_test_runsc_ptrace |
- grep -v open_create_test_runsc_ptrace |
- grep -v clock_gettime_test_runsc_ptrace`
+ --test_tag_filters=runsc_ptrace //test/syscalls/...
}
# Find and rename all test xml and log files so that Sponge can pick them up.
diff --git a/test/BUILD b/test/BUILD
index 2beb8f7fb..6b83757f6 100644
--- a/test/BUILD
+++ b/test/BUILD
@@ -34,10 +34,6 @@ platform(
name: "dockerPrivileged"
value: "true"
}
- properties: {
- name: "dockerRunAsRoot"
- value: "true"
- }
""",
)
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD
index 51b482ccd..ccb3deda9 100644
--- a/test/syscalls/BUILD
+++ b/test/syscalls/BUILD
@@ -49,7 +49,10 @@ syscall_test(test = "//test/syscalls/linux:chroot_test")
syscall_test(test = "//test/syscalls/linux:clock_getres_test")
-syscall_test(test = "//test/syscalls/linux:clock_gettime_test")
+syscall_test(
+ size = "medium",
+ test = "//test/syscalls/linux:clock_gettime_test",
+)
syscall_test(test = "//test/syscalls/linux:clock_nanosleep_test")
diff --git a/test/syscalls/linux/affinity.cc b/test/syscalls/linux/affinity.cc
index 8a16343d5..3b59d5777 100644
--- a/test/syscalls/linux/affinity.cc
+++ b/test/syscalls/linux/affinity.cc
@@ -155,6 +155,7 @@ TEST_F(AffinityTest, Sanity) {
}
TEST_F(AffinityTest, NewThread) {
+ SKIP_IF(CPU_COUNT(&mask_) < 3);
ASSERT_NO_ERRNO(ClearLowestBit());
ASSERT_NO_ERRNO(ClearLowestBit());
EXPECT_THAT(sched_setaffinity(/*pid=*/0, sizeof(cpu_set_t), &mask_),
diff --git a/test/syscalls/linux/clock_gettime.cc b/test/syscalls/linux/clock_gettime.cc
index 5003928be..dee66c5a8 100644
--- a/test/syscalls/linux/clock_gettime.cc
+++ b/test/syscalls/linux/clock_gettime.cc
@@ -87,7 +87,12 @@ TEST(ClockGettime, JavaThreadTime) {
ASSERT_EQ(0, pthread_getcpuclockid(pthread_self(), &clockid));
struct timespec tp;
ASSERT_THAT(clock_getres(clockid, &tp), SyscallSucceeds());
- ASSERT_THAT(clock_gettime(clockid, &tp), SyscallSucceeds());
+ EXPECT_TRUE(tp.tv_sec > 0 || tp.tv_nsec > 0);
+ // A thread cputime is updated each 10msec and there is no approximation
+ // if a task is running.
+ do {
+ ASSERT_THAT(clock_gettime(clockid, &tp), SyscallSucceeds());
+ } while (tp.tv_sec == 0 && tp.tv_nsec == 0);
EXPECT_TRUE(tp.tv_sec > 0 || tp.tv_nsec > 0);
}
diff --git a/test/syscalls/linux/exec.cc b/test/syscalls/linux/exec.cc
index 1ef40b502..2d2287c2a 100644
--- a/test/syscalls/linux/exec.cc
+++ b/test/syscalls/linux/exec.cc
@@ -476,8 +476,10 @@ TEST(ProcSelfExe, ChangesAcrossExecve) {
}
TEST(ExecTest, CloexecNormalFile) {
- const FileDescriptor fd_closed_on_exec = ASSERT_NO_ERRNO_AND_VALUE(
- Open("/usr/share/zoneinfo", O_RDONLY | O_CLOEXEC));
+ TempPath tempFile = ASSERT_NO_ERRNO_AND_VALUE(
+ TempPath::CreateFileWith(GetAbsoluteTestTmpdir(), "bar", 0755));
+ const FileDescriptor fd_closed_on_exec =
+ ASSERT_NO_ERRNO_AND_VALUE(Open(tempFile.path(), O_RDONLY | O_CLOEXEC));
CheckOutput(WorkloadPath(kAssertClosedWorkload),
{WorkloadPath(kAssertClosedWorkload),
@@ -487,7 +489,7 @@ TEST(ExecTest, CloexecNormalFile) {
// The assert closed workload exits with code 2 if the file still exists. We
// can use this to do a negative test.
const FileDescriptor fd_open_on_exec =
- ASSERT_NO_ERRNO_AND_VALUE(Open("/usr/share/zoneinfo", O_RDONLY));
+ ASSERT_NO_ERRNO_AND_VALUE(Open(tempFile.path(), O_RDONLY));
CheckOutput(WorkloadPath(kAssertClosedWorkload),
{WorkloadPath(kAssertClosedWorkload),