OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
12 #include "update_engine/action.h" | 12 #include "update_engine/action.h" |
13 #include "update_engine/subprocess.h" | 13 #include "update_engine/subprocess.h" |
14 | 14 |
15 // These are some handy functions for unittests. | 15 // These are some handy functions for unittests. |
16 | 16 |
17 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
18 | 18 |
19 // Writes the data passed to path. The file at path will be overwritten if it | 19 // Writes the data passed to path. The file at path will be overwritten if it |
20 // exists. Returns true on success, false otherwise. | 20 // exists. Returns true on success, false otherwise. |
21 bool WriteFileVector(const std::string& path, const std::vector<char>& data); | 21 bool WriteFileVector(const std::string& path, const std::vector<char>& data); |
22 bool WriteFileString(const std::string& path, const std::string& data); | 22 bool WriteFileString(const std::string& path, const std::string& data); |
23 | 23 |
24 // Returns the size of the file at path. If the file doesn't exist or some | |
25 // error occurrs, -1 is returned. | |
26 off_t FileSize(const std::string& path); | |
27 | |
28 // Reads a symlink from disk. Returns empty string on failure. | 24 // Reads a symlink from disk. Returns empty string on failure. |
29 std::string Readlink(const std::string& path); | 25 std::string Readlink(const std::string& path); |
30 | 26 |
31 // Gzip compresses the data passed using the gzip command line program. | 27 // Gzip compresses the data passed using the gzip command line program. |
32 // Returns compressed data back. | 28 // Returns compressed data back. |
33 std::vector<char> GzipCompressData(const std::vector<char>& data); | 29 std::vector<char> GzipCompressData(const std::vector<char>& data); |
34 | 30 |
35 // Gives back a 512-bytes length array that contains an MBR with | 31 // Gives back a 512-bytes length array that contains an MBR with |
36 // the first partition is marked bootable. | 32 // the first partition is marked bootable. |
37 std::vector<char> GenerateSampleMbr(); | 33 std::vector<char> GenerateSampleMbr(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 static std::string StaticType() { return "ObjectCollectorAction"; } | 185 static std::string StaticType() { return "ObjectCollectorAction"; } |
190 std::string Type() const { return StaticType(); } | 186 std::string Type() const { return StaticType(); } |
191 const T& object() const { return object_; } | 187 const T& object() const { return object_; } |
192 private: | 188 private: |
193 T object_; | 189 T object_; |
194 }; | 190 }; |
195 | 191 |
196 } // namespace chromeos_update_engine | 192 } // namespace chromeos_update_engine |
197 | 193 |
198 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 194 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
OLD | NEW |