Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ed101ba authored by Steve Fung's avatar Steve Fung
Browse files

crash_reporter: Fix unit tests

- Removed obsolete unit tests.
- Fix remaining unit tests for Android.

Change-Id: I1665447d375178d2bcf941fec3585c8f96cd2bac
parent 1462c78c
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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() {
+0 −1
Original line number Diff line number Diff line
@@ -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:
+0 −8
Original line number Diff line number Diff line
@@ -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";
+5 −4
Original line number Diff line number Diff line
@@ -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());
}
+0 −9
Original line number Diff line number Diff line
@@ -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");
Loading