| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ASSERT_EQ(0, System(string("mount -o loop image.dat ") + mountpoint)); | 80 ASSERT_EQ(0, System(string("mount -o loop image.dat ") + mountpoint)); |
| 81 | 81 |
| 82 // put a postinst script in | 82 // put a postinst script in |
| 83 string script = string("#!/bin/bash\ntouch ") + cwd + "/postinst_called\n"; | 83 string script = string("#!/bin/bash\ntouch ") + cwd + "/postinst_called\n"; |
| 84 if (do_err_script) { | 84 if (do_err_script) { |
| 85 script = "#!/bin/bash\nexit 1"; | 85 script = "#!/bin/bash\nexit 1"; |
| 86 } | 86 } |
| 87 ASSERT_TRUE(WriteFileString(mountpoint + "/postinst", script)); | 87 ASSERT_TRUE(WriteFileString(mountpoint + "/postinst", script)); |
| 88 ASSERT_EQ(0, System(string("chmod a+x ") + mountpoint + "/postinst")); | 88 ASSERT_EQ(0, System(string("chmod a+x ") + mountpoint + "/postinst")); |
| 89 | 89 |
| 90 ASSERT_EQ(0, System(string("umount ") + mountpoint)); | 90 ASSERT_EQ(0, System(string("umount -d ") + mountpoint)); |
| 91 | 91 |
| 92 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called")); | 92 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called")); |
| 93 | 93 |
| 94 // get a loop device we can use for the install device | 94 // get a loop device we can use for the install device |
| 95 FILE* find_dev_cmd = popen("losetup -f", "r"); | 95 FILE* find_dev_cmd = popen("losetup -f", "r"); |
| 96 ASSERT_TRUE(find_dev_cmd); | 96 ASSERT_TRUE(find_dev_cmd); |
| 97 | 97 |
| 98 char dev[100] = {0}; | 98 char dev[100] = {0}; |
| 99 size_t r = fread(dev, 1, sizeof(dev), find_dev_cmd); | 99 size_t r = fread(dev, 1, sizeof(dev), find_dev_cmd); |
| 100 ASSERT_GT(r, 0); | 100 ASSERT_GT(r, 0); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 // Death tests don't seem to be working on Hardy | 148 // Death tests don't seem to be working on Hardy |
| 149 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) { | 149 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) { |
| 150 ASSERT_EQ(0, getuid()); | 150 ASSERT_EQ(0, getuid()); |
| 151 PostinstallRunnerAction runner_action; | 151 PostinstallRunnerAction runner_action; |
| 152 ASSERT_DEATH({ runner_action.TerminateProcessing(); }, | 152 ASSERT_DEATH({ runner_action.TerminateProcessing(); }, |
| 153 "postinstall_runner_action.h:.*] Check failed"); | 153 "postinstall_runner_action.h:.*] Check failed"); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace chromeos_update_engine | 156 } // namespace chromeos_update_engine |
| OLD | NEW |