blob: 0c12e13c0a9fcd79014699c4d537a441ceabaec6 [file] [log] [blame]
rspangler@google.com49fdf182009-10-10 00:57:34 +00001// 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
3// found in the LICENSE file.
4
5#ifndef UPDATE_ENGINE_TEST_UTILS_H__
6#define UPDATE_ENGINE_TEST_UTILS_H__
7
8#include <vector>
9#include <string>
10
11// These are some handy functions for unittests.
12
13namespace chromeos_update_engine {
14
15// Returns the entire contents of the file at path. If the file doesn't
16// exist or error occurrs, an empty vector is returned.
17std::vector<char> ReadFile(const std::string& path);
18
19// Writes the data passed to path. The file at path will be overwritten if it
20// exists. Returns true on success, false otherwise.
21bool WriteFile(const std::string& path, const std::vector<char>& data);
22
23// Returns the size of the file at path. If the file doesn't exist or some
24// error occurrs, -1 is returned.
25off_t FileSize(const std::string& path);
26
27// Gzip compresses the data passed using the gzip command line program.
28// Returns compressed data back.
29std::vector<char> GzipCompressData(const std::vector<char>& data);
30
31} // namespace chromeos_update_engine
32
33#endif // UPDATE_ENGINE_TEST_UTILS_H__