blob: 35b7756f08e4f0c4490f1e2dfa70b4e6237addb8 [file] [log] [blame]
Alex Deymo2b19cfb2015-03-26 00:35:07 -07001// Copyright 2015 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_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_
6#define UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_
7
8// A fake filesystem interface implementation allowing the user to add arbitrary
9// files/metadata.
10
11#include "update_engine/payload_generator/filesystem_interface.h"
12
13#include <string>
14#include <vector>
15
16#include "update_engine/update_metadata.pb.h"
17
18namespace chromeos_update_engine {
19
20class FakeFilesystem : public FilesystemInterface {
21 public:
22 FakeFilesystem(uint64_t block_size, uint64_t block_count);
23 virtual ~FakeFilesystem() = default;
24
25 // FilesystemInterface overrides.
26 size_t GetBlockSize() const override;
27 size_t GetBlockCount() const override;
28 bool GetFiles(std::vector<File>* files) const override;
Alex Deymo2e9533b2015-06-26 20:57:06 -070029 bool LoadSettings(chromeos::KeyValueStore* store) const override;
Alex Deymo2b19cfb2015-03-26 00:35:07 -070030
31 // Fake methods.
32
33 // Add a file to the list of fake files.
34 void AddFile(const std::string& filename, const std::vector<Extent> extents);
35
Alex Deymo2e9533b2015-06-26 20:57:06 -070036 // Sets the PAYLOAD_MINOR_VERSION key stored by LoadSettings(). Use a negative
37 // value to produce an error in LoadSettings().
38 void SetMinorVersion(int minor_version) {
39 minor_version_ = minor_version;
40 }
41
Alex Deymo2b19cfb2015-03-26 00:35:07 -070042 private:
43 FakeFilesystem() = default;
44
45 uint64_t block_size_;
46 uint64_t block_count_;
Alex Deymo2e9533b2015-06-26 20:57:06 -070047 int minor_version_{-1};
Alex Deymo2b19cfb2015-03-26 00:35:07 -070048
49 std::vector<File> files_;
50
51 DISALLOW_COPY_AND_ASSIGN(FakeFilesystem);
52};
53
54} // namespace chromeos_update_engine
55
56#endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_