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

Side by Side Diff: postinstall_runner_action_unittest.cc

Issue 6347053: Try to mount new filesystem w/ ext2 first, then ext3. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fix comment for review Created 9 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « postinstall_runner_action.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sys/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <unistd.h> 7 #include <unistd.h>
8
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
11
12 #include <base/string_util.h>
10 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14
11 #include "update_engine/postinstall_runner_action.h" 15 #include "update_engine/postinstall_runner_action.h"
12 #include "update_engine/test_utils.h" 16 #include "update_engine/test_utils.h"
13 #include "update_engine/utils.h" 17 #include "update_engine/utils.h"
14 18
15 using std::string; 19 using std::string;
16 using std::vector; 20 using std::vector;
17 21
18 namespace chromeos_update_engine { 22 namespace chromeos_update_engine {
19 23
20 namespace { 24 namespace {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 cwd = string(&buf[0], strlen(&buf[0])); 87 cwd = string(&buf[0], strlen(&buf[0]));
84 } 88 }
85 89
86 // create the au destination, if it doesn't exist 90 // create the au destination, if it doesn't exist
87 ASSERT_EQ(0, System(string("mkdir -p ") + mountpoint)); 91 ASSERT_EQ(0, System(string("mkdir -p ") + mountpoint));
88 92
89 // create 10MiB sparse file 93 // create 10MiB sparse file
90 ASSERT_EQ(0, system("dd if=/dev/zero of=image.dat seek=10485759 bs=1 " 94 ASSERT_EQ(0, system("dd if=/dev/zero of=image.dat seek=10485759 bs=1 "
91 "count=1")); 95 "count=1"));
92 96
93 // format it as ext3 97 // format it as ext2
94 ASSERT_EQ(0, system("mkfs.ext3 -F image.dat")); 98 ASSERT_EQ(0, system("mkfs.ext2 -F image.dat"));
95 99
96 // mount it 100 // mount it
97 ASSERT_EQ(0, System(string("mount -o loop image.dat ") + mountpoint)); 101 ASSERT_EQ(0, System(string("mount -o loop image.dat ") + mountpoint));
98 102
99 // put a postinst script in 103 // put a postinst script in
100 string script = string("#!/bin/bash\ntouch ") + cwd + "/postinst_called\n"; 104 string script = StringPrintf("#!/bin/bash\n"
105 "mount | grep au_postint_mount | grep ext2\n"
106 "if [ $? -eq 0 ]; then\n"
107 " touch %s/postinst_called\n"
108 "fi\n",
109 cwd.c_str());
101 if (do_err_script) { 110 if (do_err_script) {
102 script = "#!/bin/bash\nexit 1"; 111 script = "#!/bin/bash\nexit 1";
103 } 112 }
104 ASSERT_TRUE(WriteFileString(mountpoint + "/postinst", script)); 113 ASSERT_TRUE(WriteFileString(mountpoint + "/postinst", script));
105 ASSERT_EQ(0, System(string("chmod a+x ") + mountpoint + "/postinst")); 114 ASSERT_EQ(0, System(string("chmod a+x ") + mountpoint + "/postinst"));
106 115
107 ASSERT_EQ(0, System(string("umount -d ") + mountpoint)); 116 ASSERT_EQ(0, System(string("umount -d ") + mountpoint));
108 117
109 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called")); 118 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called"));
110 119
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 180
172 // Death tests don't seem to be working on Hardy 181 // Death tests don't seem to be working on Hardy
173 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) { 182 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) {
174 ASSERT_EQ(0, getuid()); 183 ASSERT_EQ(0, getuid());
175 PostinstallRunnerAction runner_action; 184 PostinstallRunnerAction runner_action;
176 ASSERT_DEATH({ runner_action.TerminateProcessing(); }, 185 ASSERT_DEATH({ runner_action.TerminateProcessing(); },
177 "postinstall_runner_action.h:.*] Check failed"); 186 "postinstall_runner_action.h:.*] Check failed");
178 } 187 }
179 188
180 } // namespace chromeos_update_engine 189 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « postinstall_runner_action.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698