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

Unified Diff: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc

Issue 563043005: Linux sandbox: move RestrictClockID() to sandbox/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add header. Created 6 years, 3 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
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | sandbox/linux/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
index bc8414d22be5572e8dcc12b2e1bc1d71f9d439b6..026f8821f3eaadc978e69296352aff83e5669eb2 100644
--- a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
@@ -431,6 +431,10 @@ BPF_TEST_C(NaClNonSfiSandboxTest,
BPF_ASSERT_EQ(ENOMEM, errno);
}
+// clockid restrictions are mostly tested in sandbox/ with the
+// RestrictClockID() unittests. Some basic tests are duplicated here as
+// a precaution.
+
void CheckClock(clockid_t clockid) {
struct timespec ts;
ts.tv_sec = ts.tv_nsec = -1;
@@ -456,67 +460,6 @@ BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
}
-#if defined(OS_CHROMEOS)
-
-// A custom BPF tester delegate to run IsRunningOnChromeOS() before
-// the sandbox is enabled because we cannot run it with non-SFI BPF
-// sandbox enabled.
-class ClockSystemTesterDelegate : public sandbox::BPFTesterDelegate {
- public:
- ClockSystemTesterDelegate()
- : is_running_on_chromeos_(base::SysInfo::IsRunningOnChromeOS()) {}
- virtual ~ClockSystemTesterDelegate() {}
-
- virtual scoped_ptr<sandbox::SandboxBPFPolicy> GetSandboxBPFPolicy() OVERRIDE {
- return scoped_ptr<sandbox::SandboxBPFPolicy>(
- new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy());
- }
- virtual void RunTestFunction() OVERRIDE {
- if (is_running_on_chromeos_) {
- CheckClock(base::TimeTicks::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);
- }
- }
-
- private:
- const bool is_running_on_chromeos_;
- DISALLOW_COPY_AND_ASSIGN(ClockSystemTesterDelegate);
-};
-
-BPF_TEST_D(BPFTest, BPFTestWithDelegateClass, ClockSystemTesterDelegate);
-
-#else
-
-BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
- clock_gettime_crash_system_trace,
- DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
- nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
- struct timespec ts;
- clock_gettime(base::TimeTicks::kClockSystemTrace, &ts);
-}
-
-#endif // defined(OS_CHROMEOS)
-
-BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
- clock_gettime_crash_cpu_clock,
- DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
- nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
- // We can't use clock_getcpuclockid() because it's not implemented in newlib,
- // and it might not work inside the sandbox anyway.
- const pid_t kInitPID = 1;
- const clockid_t kInitCPUClockID =
- MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED);
-
- struct timespec ts;
- clock_gettime(kInitCPUClockID, &ts);
-}
-
BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
invalid_syscall_crash,
DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()),
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | sandbox/linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698