crash_reporter: Fix unit tests
- Removed obsolete unit tests. - Fix remaining unit tests for Android. Change-Id: I1665447d375178d2bcf941fec3585c8f96cd2bac
This commit is contained in:
parent
1462c78c9c
commit
8ed101bab5
|
@ -47,7 +47,6 @@ const char kCrashTestInProgressPath[] =
|
|||
const char kDefaultLogConfig[] = "/etc/crash_reporter_logs.conf";
|
||||
const char kDefaultUserName[] = "chronos";
|
||||
const char kLeaveCoreFile[] = "/data/misc/crash_reporter/.leave_core";
|
||||
const char kLsbRelease[] = "/etc/lsb-release";
|
||||
const char kShellPath[] = "/system/bin/sh";
|
||||
const char kSystemCrashPath[] = "/data/misc/crash_reporter/crash";
|
||||
const char kUploadVarPrefix[] = "upload_var_";
|
||||
|
@ -90,8 +89,7 @@ using base::FilePath;
|
|||
using base::StringPrintf;
|
||||
|
||||
CrashCollector::CrashCollector()
|
||||
: lsb_release_(kLsbRelease),
|
||||
log_config_path_(kDefaultLogConfig) {
|
||||
: log_config_path_(kDefaultLogConfig) {
|
||||
}
|
||||
|
||||
CrashCollector::~CrashCollector() {
|
||||
|
|
|
@ -158,7 +158,6 @@ class CrashCollector {
|
|||
IsFeedbackAllowedFunction is_feedback_allowed_function_;
|
||||
std::string extra_metadata_;
|
||||
base::FilePath forced_crash_directory_;
|
||||
std::string lsb_release_;
|
||||
base::FilePath log_config_path_;
|
||||
|
||||
private:
|
||||
|
|
|
@ -177,15 +177,8 @@ TEST_F(CrashCollectorTest, CheckHasCapacityStrangeNames) {
|
|||
TEST_F(CrashCollectorTest, MetaData) {
|
||||
const char kMetaFileBasename[] = "generated.meta";
|
||||
FilePath meta_file = test_dir_.Append(kMetaFileBasename);
|
||||
FilePath lsb_release = test_dir_.Append("lsb-release");
|
||||
FilePath payload_file = test_dir_.Append("payload-file");
|
||||
std::string contents;
|
||||
collector_.lsb_release_ = lsb_release.value();
|
||||
const char kLsbContents[] =
|
||||
"CHROMEOS_RELEASE_BOARD=lumpy\n"
|
||||
"CHROMEOS_RELEASE_VERSION=6727.0.2015_01_26_0853\n"
|
||||
"CHROMEOS_RELEASE_NAME=Chromium OS\n";
|
||||
ASSERT_TRUE(base::WriteFile(lsb_release, kLsbContents, strlen(kLsbContents)));
|
||||
const char kPayload[] = "foo";
|
||||
ASSERT_TRUE(base::WriteFile(payload_file, kPayload, strlen(kPayload)));
|
||||
collector_.AddCrashMetaData("foo", "bar");
|
||||
|
@ -194,7 +187,6 @@ TEST_F(CrashCollectorTest, MetaData) {
|
|||
const char kExpectedMeta[] =
|
||||
"foo=bar\n"
|
||||
"exec_name=kernel\n"
|
||||
"ver=6727.0.2015_01_26_0853\n"
|
||||
"payload=test/payload-file\n"
|
||||
"payload_size=3\n"
|
||||
"done=1\n";
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
namespace {
|
||||
|
||||
// Name of the checked-in configuration file containing log-collection commands.
|
||||
const char kConfigFile[] = "crash_reporter_logs.conf";
|
||||
const char kConfigFile[] = "/system/etc/crash_reporter_logs.conf";
|
||||
|
||||
// Executable name for Chrome. kConfigFile is expected to contain this entry.
|
||||
const char kChromeExecName[] = "chrome";
|
||||
// Signature name for crash_reporter user collection.
|
||||
// kConfigFile is expected to contain this entry.
|
||||
const char kUserCollectorSignature[] = "crash_reporter-user-collection";
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -35,6 +36,6 @@ TEST(CrashReporterLogsTest, ReadConfig) {
|
|||
brillo::KeyValueStore store;
|
||||
ASSERT_TRUE(store.Load(base::FilePath(kConfigFile)));
|
||||
std::string command;
|
||||
EXPECT_TRUE(store.GetString(kChromeExecName, &command));
|
||||
EXPECT_TRUE(store.GetString(kUserCollectorSignature, &command));
|
||||
EXPECT_FALSE(command.empty());
|
||||
}
|
||||
|
|
|
@ -253,15 +253,6 @@ TEST_F(KernelCollectorTest, CollectPreservedFileMissing) {
|
|||
ASSERT_EQ(0, s_crashes);
|
||||
}
|
||||
|
||||
TEST_F(KernelCollectorTest, CollectBadDirectory) {
|
||||
WriteStringToFile(kcrash_file(), "====1.1\nsomething");
|
||||
ASSERT_TRUE(collector_.Collect());
|
||||
ASSERT_TRUE(FindLog("Unable to create appropriate crash directory"))
|
||||
<< "Did not find expected error string in log: {\n"
|
||||
<< GetLog() << "}";
|
||||
ASSERT_EQ(1, s_crashes);
|
||||
}
|
||||
|
||||
void KernelCollectorTest::SetUpSuccessfulCollect() {
|
||||
collector_.ForceCrashDirectory(test_crash_directory());
|
||||
WriteStringToFile(kcrash_file(), "====1.1\nsomething");
|
||||
|
|
|
@ -37,11 +37,6 @@ bool s_metrics = false;
|
|||
|
||||
const char kFilePath[] = "/my/path";
|
||||
|
||||
// Keep in sync with UserCollector::ShouldDump.
|
||||
const char kChromeIgnoreMsg[] =
|
||||
"ignoring call by kernel - chrome crash; "
|
||||
"waiting for chrome to call us directly";
|
||||
|
||||
void CountCrash() {
|
||||
++s_crashes;
|
||||
}
|
||||
|
@ -167,24 +162,6 @@ TEST_F(UserCollectorTest, HandleNonChromeCrashWithConsent) {
|
|||
ASSERT_EQ(s_crashes, 1);
|
||||
}
|
||||
|
||||
TEST_F(UserCollectorTest, HandleChromeCrashWithConsent) {
|
||||
s_metrics = true;
|
||||
collector_.HandleCrash("5:2:ignored", "chrome");
|
||||
EXPECT_TRUE(FindLog(
|
||||
"Received crash notification for chrome[5] sig 2"));
|
||||
EXPECT_TRUE(FindLog(kChromeIgnoreMsg));
|
||||
ASSERT_EQ(s_crashes, 0);
|
||||
}
|
||||
|
||||
TEST_F(UserCollectorTest, HandleSuppliedChromeCrashWithConsent) {
|
||||
s_metrics = true;
|
||||
collector_.HandleCrash("0:2:chrome", nullptr);
|
||||
EXPECT_TRUE(FindLog(
|
||||
"Received crash notification for supplied_chrome[0] sig 2"));
|
||||
EXPECT_TRUE(FindLog(kChromeIgnoreMsg));
|
||||
ASSERT_EQ(s_crashes, 0);
|
||||
}
|
||||
|
||||
TEST_F(UserCollectorTest, GetProcessPath) {
|
||||
FilePath path = collector_.GetProcessPath(100);
|
||||
ASSERT_EQ("/proc/100", path.value());
|
||||
|
@ -226,7 +203,7 @@ TEST_F(UserCollectorTest, GetExecutableBaseNameFromPid) {
|
|||
pid_t my_pid = getpid();
|
||||
EXPECT_TRUE(collector_.GetExecutableBaseNameFromPid(my_pid, &base_name));
|
||||
EXPECT_FALSE(FindLog("Readlink failed"));
|
||||
EXPECT_EQ("crash_reporter_test", base_name);
|
||||
EXPECT_EQ("crash_reporter_tests", base_name);
|
||||
}
|
||||
|
||||
TEST_F(UserCollectorTest, GetFirstLineWithPrefix) {
|
||||
|
|
Loading…
Reference in New Issue