| Index: chromeos/process_test.cc
|
| diff --git a/chromeos/process_test.cc b/chromeos/process_test.cc
|
| index 98d4bf8637567834320ed99faf87b6e100831feb..14aa967747bef06dd6489e4d4cec7d8a8bc34835 100644
|
| --- a/chromeos/process_test.cc
|
| +++ b/chromeos/process_test.cc
|
| @@ -196,6 +196,44 @@ TEST_F(ProcessTest, RedirectStdinUsingPipe) {
|
| ExpectFileEquals(kMessage, output_file_.c_str());
|
| }
|
|
|
| +TEST_F(ProcessTest, WithSameUid) {
|
| + gid_t uid = geteuid();
|
| + process_.AddArg(kBinEcho);
|
| + process_.SetUid(uid);
|
| + EXPECT_EQ(0, process_.Run());
|
| +}
|
| +
|
| +TEST_F(ProcessTest, WithSameGid) {
|
| + gid_t gid = getegid();
|
| + process_.AddArg(kBinEcho);
|
| + process_.SetGid(gid);
|
| + EXPECT_EQ(0, process_.Run());
|
| +}
|
| +
|
| +TEST_F(ProcessTest, WithIllegalUid) {
|
| + ASSERT_NE(0, geteuid());
|
| + process_.AddArg(kBinEcho);
|
| + process_.SetUid(0);
|
| + EXPECT_EQ(127, process_.Run());
|
| + std::string contents;
|
| + EXPECT_TRUE(file_util::ReadFileToString(FilePath(output_file_),
|
| + &contents));
|
| + EXPECT_NE(std::string::npos,
|
| + contents.find("Unable to set UID to 0: 1\n"));
|
| +}
|
| +
|
| +TEST_F(ProcessTest, WithIllegalGid) {
|
| + ASSERT_NE(0, getegid());
|
| + process_.AddArg(kBinEcho);
|
| + process_.SetGid(0);
|
| + EXPECT_EQ(127, process_.Run());
|
| + std::string contents;
|
| + EXPECT_TRUE(file_util::ReadFileToString(FilePath(output_file_),
|
| + &contents));
|
| + EXPECT_NE(std::string::npos,
|
| + contents.find("Unable to set GID to 0: 1\n"));
|
| +}
|
| +
|
| TEST_F(ProcessTest, NoParams) {
|
| EXPECT_EQ(127, process_.Run());
|
| }
|
|
|