Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: user_collector_test.cc

Issue 4603001: crash-reporter: Avoid writing through symlinks. (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git@master
Patch Set: Respond to review Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « user_collector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: user_collector_test.cc
diff --git a/user_collector_test.cc b/user_collector_test.cc
index db707f5accce5ce6d86f65c24c038e5e97b87687..06ba9b8f50da629f54e23a4d0236b352f4ea70f0 100644
--- a/user_collector_test.cc
+++ b/user_collector_test.cc
@@ -7,6 +7,7 @@
#include "base/file_util.h"
#include "crash-reporter/system_logging_mock.h"
#include "crash-reporter/user_collector.h"
+#include "crash-reporter/test_helpers.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
@@ -15,12 +16,6 @@ static bool s_metrics = false;
static const char kFilePath[] = "/my/path";
-// This test assumes the following standard binaries are installed.
-static const char kBinBash[] = "/bin/bash";
-static const char kBinCp[] = "/bin/cp";
-static const char kBinEcho[] = "/bin/echo";
-static const char kBinFalse[] = "/bin/false";
-
void CountCrash() {
++s_crashes;
}
@@ -91,69 +86,6 @@ TEST_F(UserCollectorTest, DisableNoFileAccess) {
std::string::npos);
}
-TEST_F(UserCollectorTest, ForkExecAndPipe) {
- std::vector<const char *> args;
- char output_file[] = "test/fork_out";
-
- // Test basic call with stdout.
- args.clear();
- args.push_back(kBinEcho);
- args.push_back("hello world");
- EXPECT_EQ(0, collector_.ForkExecAndPipe(args, output_file));
- ExpectFileEquals("hello world\n", output_file);
- EXPECT_EQ("", logging_.log());
-
- // Test non-zero return value
- logging_.clear();
- args.clear();
- args.push_back(kBinFalse);
- EXPECT_EQ(1, collector_.ForkExecAndPipe(args, output_file));
- ExpectFileEquals("", output_file);
- EXPECT_EQ("", logging_.log());
-
- // Test bad output_file.
- EXPECT_EQ(127, collector_.ForkExecAndPipe(args, "/bad/path"));
-
- // Test bad executable.
- logging_.clear();
- args.clear();
- args.push_back("false");
- EXPECT_EQ(127, collector_.ForkExecAndPipe(args, output_file));
-
- // Test stderr captured.
- std::string contents;
- logging_.clear();
- args.clear();
- args.push_back(kBinCp);
- EXPECT_EQ(1, collector_.ForkExecAndPipe(args, output_file));
- EXPECT_TRUE(file_util::ReadFileToString(FilePath(output_file),
- &contents));
- EXPECT_NE(std::string::npos, contents.find("missing file operand"));
- EXPECT_EQ("", logging_.log());
-
- // NULL parameter.
- logging_.clear();
- args.clear();
- args.push_back(NULL);
- EXPECT_EQ(-1, collector_.ForkExecAndPipe(args, output_file));
- EXPECT_NE(std::string::npos,
- logging_.log().find("Bad parameter"));
-
- // No parameters.
- args.clear();
- EXPECT_EQ(127, collector_.ForkExecAndPipe(args, output_file));
-
- // Segmentation faulting process.
- logging_.clear();
- args.clear();
- args.push_back(kBinBash);
- args.push_back("-c");
- args.push_back("kill -SEGV $$");
- EXPECT_EQ(-1, collector_.ForkExecAndPipe(args, output_file));
- EXPECT_NE(std::string::npos,
- logging_.log().find("Process did not exit normally"));
-}
-
TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) {
s_metrics = false;
collector_.HandleCrash(10, 20, "foobar");
« no previous file with comments | « user_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698