Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc
index e653b8a0c6d373cf722696725072dd44c70dadda..aaed480d6996389bad8d91514861d177f37be1c2 100644
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc
@@ -26,6 +26,7 @@
#include "sandbox/linux/seccomp-bpf/syscall.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
+#include "sandbox/linux/system_headers/linux_time.h"
#include "sandbox/linux/tests/unit_tests.h"
#if !defined(OS_ANDROID)
@@ -60,7 +61,13 @@ class RestrictClockIdPolicy : public bpf_dsl::Policy {
void CheckClock(clockid_t clockid) {
struct timespec ts;
- ts.tv_sec = ts.tv_nsec = -1;
+ ts.tv_sec = -1;
+ ts.tv_nsec = -1;
+ BPF_ASSERT_EQ(0, clock_getres(clockid, &ts));
+ BPF_ASSERT_EQ(0, ts.tv_sec);
+ BPF_ASSERT_LE(0, ts.tv_nsec);
+ ts.tv_sec = -1;
+ ts.tv_nsec = -1;
BPF_ASSERT_EQ(0, clock_gettime(clockid, &ts));
BPF_ASSERT_LE(0, ts.tv_sec);
BPF_ASSERT_LE(0, ts.tv_nsec);
@@ -70,8 +77,10 @@ BPF_TEST_C(ParameterRestrictions,
clock_gettime_allowed,
RestrictClockIdPolicy) {
CheckClock(CLOCK_MONOTONIC);
+ CheckClock(CLOCK_MONOTONIC_COARSE);
CheckClock(CLOCK_PROCESS_CPUTIME_ID);
CheckClock(CLOCK_REALTIME);
+ CheckClock(CLOCK_REALTIME_COARSE);
CheckClock(CLOCK_THREAD_CPUTIME_ID);
}
@@ -99,14 +108,14 @@ class ClockSystemTesterDelegate : public sandbox::BPFTesterDelegate {
}
void RunTestFunction() override {
if (is_running_on_chromeos_) {
- CheckClock(base::TimeTicks::kClockSystemTrace);
+ CheckClock(base::TraceTicks::kClockSystemTrace);
} else {
struct timespec ts;
// kClockSystemTrace is 11, which is CLOCK_THREAD_CPUTIME_ID of
// the init process (pid=1). If kernel supports this feature,
// this may succeed even if this is not running on Chrome OS. We
// just check this clock_gettime call does not crash.
- clock_gettime(base::TimeTicks::kClockSystemTrace, &ts);
+ clock_gettime(base::TraceTicks::kClockSystemTrace, &ts);
}
}
@@ -124,7 +133,7 @@ BPF_DEATH_TEST_C(ParameterRestrictions,
DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()),
RestrictClockIdPolicy) {
struct timespec ts;
- clock_gettime(base::TimeTicks::kClockSystemTrace, &ts);
+ clock_gettime(base::TraceTicks::kClockSystemTrace, &ts);
}
#endif // defined(OS_CHROMEOS)
« no previous file with comments | « sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ('k') | sandbox/linux/syscall_broker/broker_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698