| // Copyright 2021 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef THIRD_PARTY_F2FS_TEST_UNIT_UNIT_LIB_H_ |
| #define THIRD_PARTY_F2FS_TEST_UNIT_UNIT_LIB_H_ |
| |
| #include <unordered_set> |
| |
| #include "third_party/f2fs/f2fs.h" |
| |
| namespace f2fs { |
| namespace unittest_lib { |
| |
| void MkfsOnFakeDev(std::unique_ptr<Bcache> *bc, uint64_t blockCount = 819200, |
| uint32_t blockSize = kDefaultSectorSize); |
| void MountWithOptions(MountOptions &options, std::unique_ptr<Bcache> *bc, |
| std::unique_ptr<F2fs> *fs); |
| void Unmount(std::unique_ptr<F2fs> fs, std::unique_ptr<Bcache> *bc); |
| |
| void CreateRoot(F2fs *fs, fbl::RefPtr<VnodeF2fs> *out); |
| void Lookup(VnodeF2fs *parent, std::string_view name, fbl::RefPtr<fs::Vnode> *out); |
| |
| void CreateChild(Dir *vn, uint32_t mode, std::string_view name); |
| void DeleteChild(Dir *vn, std::string_view name); |
| |
| void CheckInlineDir(VnodeF2fs *vn); |
| void CheckNonInlineDir(VnodeF2fs *vn); |
| |
| void CheckChildrenFromReaddir(Dir *dir, std::unordered_set<std::string> childs); |
| void CheckChildrenInBlock(Dir *vn, unsigned int bidx, std::unordered_set<std::string> childs); |
| |
| std::string GetRandomName(unsigned int len); |
| |
| void AppendToFile(File *file, const void *data, size_t len); |
| |
| void CheckNodeLevel(F2fs *fs, VnodeF2fs *vn, int level); |
| |
| void CheckNidsFree(F2fs *fs, std::unordered_set<nid_t> &nids); |
| void CheckNidsInuse(F2fs *fs, std::unordered_set<nid_t> &nids); |
| void CheckBlkaddrsFree(F2fs *fs, std::unordered_set<block_t> &blkaddrs); |
| void CheckBlkaddrsInuse(F2fs *fs, std::unordered_set<block_t> &blkaddrs); |
| |
| } // namespace unittest_lib |
| } // namespace f2fs |
| |
| #endif // THIRD_PARTY_F2FS_TEST_UNIT_UNIT_LIB_H_ |