aboutsummaryrefslogtreecommitdiff
path: root/chromeos
diff options
context:
space:
mode:
authorAri Hausman-Cohen <arihc@google.com>2015-08-11 17:25:27 -0700
committerAri Hausman-Cohen <arihc@google.com>2015-08-13 13:34:14 -0700
commitcc76bff0d0a26687b9117f748bb8473761cfdfe6 (patch)
treeb0aaf4c7b1337f4443899cfdb3f9827a7f977549 /chromeos
parent5d7fc29f9f5a9c9858f3df2395eed31abe72c5a7 (diff)
downloadlibbrillo-cc76bff0d0a26687b9117f748bb8473761cfdfe6.tar.gz
Added unit test target, unit tests run and pass with bionic runner
As b/22772126 says, mm runtests should do the "right thing". For clarity, this has been renamed so you use mm runtargettests. The "right thing" is here interpreted to mean build & run the unit tests using the bionic test runner on the target. All tests should pass. BUG: 22772126, 22874311 Change-Id: Id68bbf18bc7a8b3b36e80408af0399fdb53bad61
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/flag_helper_unittest.cc3
-rw-r--r--chromeos/process_unittest.cc17
2 files changed, 20 insertions, 0 deletions
diff --git a/chromeos/flag_helper_unittest.cc b/chromeos/flag_helper_unittest.cc
index bb2257e..3178aaa 100644
--- a/chromeos/flag_helper_unittest.cc
+++ b/chromeos/flag_helper_unittest.cc
@@ -18,6 +18,9 @@ class FlagHelperTest : public ::testing::Test {
public:
FlagHelperTest() {}
~FlagHelperTest() override { chromeos::FlagHelper::ResetForTesting(); }
+ static void SetUpTestCase() {
+ base::CommandLine::Init(0, nullptr);
+ }
};
// Test that the DEFINE_xxxx macros can create the respective variables
diff --git a/chromeos/process_unittest.cc b/chromeos/process_unittest.cc
index 81a8f34..c74e1ed 100644
--- a/chromeos/process_unittest.cc
+++ b/chromeos/process_unittest.cc
@@ -85,6 +85,12 @@ class ProcessTest : public ::testing::Test {
ClearLog();
}
+ static void SetUpTestCase() {
+ base::CommandLine::Init(0, nullptr);
+ ::chromeos::InitLog(chromeos::kLogToStderr);
+ ::chromeos::LogToString(true);
+ }
+
protected:
void CheckStderrCaptured();
FilePath GetFdPath(int fd);
@@ -260,6 +266,7 @@ TEST_F(ProcessTest, NoParams) {
EXPECT_EQ(-1, process_.Run());
}
+#if !defined(__BRILLO__) // Bionic intercepts the segfault in brillo
TEST_F(ProcessTest, SegFaultHandling) {
process_.AddArg(kBinSh);
process_.AddArg("-c");
@@ -267,6 +274,16 @@ TEST_F(ProcessTest, SegFaultHandling) {
EXPECT_EQ(-1, process_.Run());
EXPECT_TRUE(FindLog("did not exit normally: 11"));
}
+#endif
+
+TEST_F(ProcessTest, KillHandling) {
+ process_.AddArg(kBinSh);
+ process_.AddArg("-c");
+ process_.AddArg("kill -KILL $$");
+ EXPECT_EQ(-1, process_.Run());
+ EXPECT_TRUE(FindLog("did not exit normally: 9"));
+}
+
TEST_F(ProcessTest, KillNoPid) {
process_.Kill(SIGTERM, 0);