summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux
diff options
context:
space:
mode:
authorAdrien Leravat <Pixep@users.noreply.github.com>2019-06-21 22:40:16 -0700
committerAdrien Leravat <Pixep@users.noreply.github.com>2019-06-24 21:14:38 -0700
commit3688e6e99d16b0c6ecb7c8b3528a541ce6afe3a7 (patch)
tree594793c2f2fb2fc702cfa22ee57b3ad902219181 /test/syscalls/linux
parente9ea7230f7dc70d3e1bb5ae32b6927209cafb465 (diff)
Add CLOCK_BOOTTIME as a CLOCK_MONOTONIC alias
Makes CLOCK_BOOTTIME available with * clock_gettime * timerfd_create * clock_gettime vDSO CLOCK_BOOTTIME is implemented as an alias to CLOCK_MONOTONIC. CLOCK_MONOTONIC already keeps track of time across save and restore. This is the closest possible behavior to Linux CLOCK_BOOTIME, as there is no concept of suspend/resume. Updates google/gvisor#218
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r--test/syscalls/linux/clock_gettime.cc8
-rw-r--r--test/syscalls/linux/vdso_clock_gettime.cc6
2 files changed, 10 insertions, 4 deletions
diff --git a/test/syscalls/linux/clock_gettime.cc b/test/syscalls/linux/clock_gettime.cc
index 335a38d41..9efd20b1a 100644
--- a/test/syscalls/linux/clock_gettime.cc
+++ b/test/syscalls/linux/clock_gettime.cc
@@ -132,6 +132,9 @@ std::string PrintClockId(::testing::TestParamInfo<clockid_t> info) {
return "CLOCK_MONOTONIC_COARSE";
case CLOCK_MONOTONIC_RAW:
return "CLOCK_MONOTONIC_RAW";
+ case CLOCK_BOOTTIME:
+ // CLOCK_BOOTTIME is a monotonic clock.
+ return "CLOCK_BOOTTIME";
default:
return absl::StrCat(info.param);
}
@@ -140,15 +143,14 @@ std::string PrintClockId(::testing::TestParamInfo<clockid_t> info) {
INSTANTIATE_TEST_SUITE_P(ClockGettime, MonotonicClockTest,
::testing::Values(CLOCK_MONOTONIC,
CLOCK_MONOTONIC_COARSE,
- CLOCK_MONOTONIC_RAW),
+ CLOCK_MONOTONIC_RAW,
+ CLOCK_BOOTTIME),
PrintClockId);
TEST(ClockGettime, UnimplementedReturnsEINVAL) {
SKIP_IF(!IsRunningOnGvisor());
struct timespec tp;
- EXPECT_THAT(clock_gettime(CLOCK_BOOTTIME, &tp),
- SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(clock_gettime(CLOCK_REALTIME_ALARM, &tp),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(clock_gettime(CLOCK_BOOTTIME_ALARM, &tp),
diff --git a/test/syscalls/linux/vdso_clock_gettime.cc b/test/syscalls/linux/vdso_clock_gettime.cc
index 759a50569..7e56c3de0 100644
--- a/test/syscalls/linux/vdso_clock_gettime.cc
+++ b/test/syscalls/linux/vdso_clock_gettime.cc
@@ -39,6 +39,8 @@ std::string PrintClockId(::testing::TestParamInfo<clockid_t> info) {
return "CLOCK_MONOTONIC";
case CLOCK_REALTIME:
return "CLOCK_REALTIME";
+ case CLOCK_BOOTTIME:
+ return "CLOCK_BOOTTIME";
default:
return absl::StrCat(info.param);
}
@@ -95,7 +97,9 @@ TEST_P(CorrectVDSOClockTest, IsCorrect) {
}
INSTANTIATE_TEST_SUITE_P(ClockGettime, CorrectVDSOClockTest,
- ::testing::Values(CLOCK_MONOTONIC, CLOCK_REALTIME),
+ ::testing::Values(CLOCK_MONOTONIC,
+ CLOCK_REALTIME,
+ CLOCK_BOOTTIME),
PrintClockId);
} // namespace