blob: c7652864ecf8d0d933643f6b74128b328915f61d [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Alex Deymo2b19cfb2015-03-26 00:35:07 -070016
17#include "update_engine/payload_generator/fake_filesystem.h"
18
19#include <gtest/gtest.h>
20
21namespace chromeos_update_engine {
22
23FakeFilesystem::FakeFilesystem(uint64_t block_size, uint64_t block_count) :
24 block_size_(block_size),
25 block_count_(block_count) {
26}
27
28size_t FakeFilesystem::GetBlockSize() const {
29 return block_size_;
30}
31
32size_t FakeFilesystem::GetBlockCount() const {
33 return block_count_;
34}
35
36bool FakeFilesystem::GetFiles(std::vector<File>* files) const {
37 *files = files_;
38 return true;
39}
40
41void FakeFilesystem::AddFile(const std::string& filename,
42 const std::vector<Extent> extents) {
43 File file;
44 file.name = filename;
45 file.extents = extents;
46 for (const Extent& extent : extents) {
Alex Deymo80f70ff2016-02-10 16:08:11 -080047 EXPECT_LE(0U, extent.start_block());
Alex Deymo2b19cfb2015-03-26 00:35:07 -070048 EXPECT_LE(extent.start_block() + extent.num_blocks(), block_count_);
49 }
50 files_.push_back(file);
51}
52
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070053bool FakeFilesystem::LoadSettings(brillo::KeyValueStore* store) const {
Alex Deymo2e9533b2015-06-26 20:57:06 -070054 if (minor_version_ < 0)
55 return false;
56 store->SetString("PAYLOAD_MINOR_VERSION", std::to_string(minor_version_));
57 return true;
58}
59
Alex Deymo2b19cfb2015-03-26 00:35:07 -070060} // namespace chromeos_update_engine