Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / sandbox / linux / tests / unit_tests_unittest.cc
blob57799b14c04d985729677334dd841a630acd8655
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <signal.h>
6 #include <stdlib.h>
7 #include <sys/types.h>
8 #include <sys/wait.h>
9 #include <unistd.h>
11 #include "base/logging.h"
12 #include "base/posix/eintr_wrapper.h"
13 #include "sandbox/linux/tests/unit_tests.h"
15 namespace sandbox {
17 namespace {
19 // Let's not use any of the "magic" values used internally in unit_tests.cc,
20 // such as kExpectedValue.
21 const int kExpectedExitCode = 100;
23 SANDBOX_DEATH_TEST(UnitTests,
24 DeathExitCode,
25 DEATH_EXIT_CODE(kExpectedExitCode)) {
26 _exit(kExpectedExitCode);
29 const int kExpectedSignalNumber = SIGKILL;
31 SANDBOX_DEATH_TEST(UnitTests,
32 DeathBySignal,
33 DEATH_BY_SIGNAL(kExpectedSignalNumber)) {
34 raise(kExpectedSignalNumber);
37 SANDBOX_DEATH_TEST(UnitTests,
38 DeathWithMessage,
39 DEATH_MESSAGE("Hello")) {
40 LOG(ERROR) << "Hello";
41 _exit(1);
44 SANDBOX_DEATH_TEST(UnitTests,
45 SEGVDeathWithMessage,
46 DEATH_SEGV_MESSAGE("Hello")) {
47 LOG(ERROR) << "Hello";
48 while (1) {
49 volatile char* addr = reinterpret_cast<volatile char*>(NULL);
50 *addr = '\0';
53 _exit(2);
56 SANDBOX_TEST_ALLOW_NOISE(UnitTests, NoisyTest) {
57 LOG(ERROR) << "The cow says moo!";
60 } // namespace
62 } // namespace sandbox