summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authormdempsky@chromium.org <mdempsky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 06:56:16 +0000
committermdempsky@chromium.org <mdempsky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 06:56:16 +0000
commit4fc615ed30696c624f122c185f8065a2a994a88c (patch)
tree6dd7e808cec20f3875c230b85ff0c180f58c2ecb /sandbox
parent0e88e1d18018dd18374a04e6ab163e18f6851afa (diff)
downloadchromium_src-4fc615ed30696c624f122c185f8065a2a994a88c.zip
chromium_src-4fc615ed30696c624f122c185f8065a2a994a88c.tar.gz
chromium_src-4fc615ed30696c624f122c185f8065a2a994a88c.tar.bz2
Fix DEATH_BY_SIGNAL helper
For compatibility with old Android versions, we can't rely on abort() raising SIGABRT. Instead, we expect that raise(SIGKILL) will raise SIGKILL. BUG=352226 Review URL: https://codereview.chromium.org/201773003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/sandbox_linux_test_sources.gypi1
-rw-r--r--sandbox/linux/tests/unit_tests.h2
-rw-r--r--sandbox/linux/tests/unit_tests_unittest.cc32
3 files changed, 34 insertions, 1 deletions
diff --git a/sandbox/linux/sandbox_linux_test_sources.gypi b/sandbox/linux/sandbox_linux_test_sources.gypi
index a48017b..e81c2a8 100644
--- a/sandbox/linux/sandbox_linux_test_sources.gypi
+++ b/sandbox/linux/sandbox_linux_test_sources.gypi
@@ -19,6 +19,7 @@
'tests/test_utils.h',
'tests/unit_tests.cc',
'tests/unit_tests.h',
+ 'tests/unit_tests_unittest.cc',
'services/broker_process_unittest.cc',
'services/scoped_process_unittest.cc',
'services/thread_helpers_unittests.cc',
diff --git a/sandbox/linux/tests/unit_tests.h b/sandbox/linux/tests/unit_tests.h
index 74aabe4..3f6092e 100644
--- a/sandbox/linux/tests/unit_tests.h
+++ b/sandbox/linux/tests/unit_tests.h
@@ -47,7 +47,7 @@ bool IsRunningOnValgrind();
sandbox::UnitTests::DeathExitCode, \
reinterpret_cast<void*>(static_cast<intptr_t>(rc))
#define DEATH_BY_SIGNAL(s) \
- sandbox::UnitTests::DeathExitCode, \
+ sandbox::UnitTests::DeathBySignal, \
reinterpret_cast<void*>(static_cast<intptr_t>(s))
// A SANDBOX_DEATH_TEST is just like a SANDBOX_TEST (see below), but it assumes
diff --git a/sandbox/linux/tests/unit_tests_unittest.cc b/sandbox/linux/tests/unit_tests_unittest.cc
new file mode 100644
index 0000000..2084b97
--- /dev/null
+++ b/sandbox/linux/tests/unit_tests_unittest.cc
@@ -0,0 +1,32 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <signal.h>
+#include <stdlib.h>
+
+#include "sandbox/linux/tests/unit_tests.h"
+
+namespace sandbox {
+
+namespace {
+
+const int kExpectedExitCode = 42;
+
+SANDBOX_DEATH_TEST(UnitTests,
+ DeathExitCode,
+ DEATH_EXIT_CODE(kExpectedExitCode)) {
+ exit(kExpectedExitCode);
+}
+
+const int kExpectedSignalNumber = SIGKILL;
+
+SANDBOX_DEATH_TEST(UnitTests,
+ DeathBySignal,
+ DEATH_BY_SIGNAL(kExpectedSignalNumber)) {
+ raise(kExpectedSignalNumber);
+}
+
+} // namespace
+
+} // namespace sandbox