
Add llvm::cas::ObjectStore abstraction and InMemoryCAS as a in-memory CAS object store implementation. The ObjectStore models its objects as: * Content: An array of bytes for the data to be stored. * Refs: An array of references to other objects in the ObjectStore. And each CAS Object can be idenfied with an unqine ID/Hash. ObjectStore supports following general action: * Expected<ID> store(Content, ArrayRef<Ref>) * Expected<Ref> get(ID) It also introduces following types to interact with a CAS ObjectStore: * CASID: Hash representation for an CAS Objects with its context to help print/compare CASIDs. * ObjectRef: A light-weight ref for an object in the ObjectStore. It is implementation defined so it can be optimized for read/store/references depending on the implementation. * ObjectProxy: A proxy for the users of CAS to interact with the data inside CAS Object. It bundles a ObjectHandle and an ObjectStore instance.
33 lines
959 B
C++
33 lines
959 B
C++
//===- CASTestConfig.h ----------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CAS/ObjectStore.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#ifndef LLVM_UNITTESTS_CASTESTCONFIG_H
|
|
#define LLVM_UNITTESTS_CASTESTCONFIG_H
|
|
|
|
struct CASTestingEnv {
|
|
std::unique_ptr<llvm::cas::ObjectStore> CAS;
|
|
};
|
|
|
|
class CASTest
|
|
: public testing::TestWithParam<std::function<CASTestingEnv(int)>> {
|
|
protected:
|
|
std::optional<int> NextCASIndex;
|
|
|
|
std::unique_ptr<llvm::cas::ObjectStore> createObjectStore() {
|
|
auto TD = GetParam()(++(*NextCASIndex));
|
|
return std::move(TD.CAS);
|
|
}
|
|
void SetUp() { NextCASIndex = 0; }
|
|
void TearDown() { NextCASIndex = std::nullopt; }
|
|
};
|
|
|
|
#endif
|