summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/target_map/target_map.test.cpp8
-rw-r--r--test/buildtool/execution_api/execution_service/TARGETS1
-rw-r--r--test/buildtool/execution_api/execution_service/cas_server.test.cpp5
-rw-r--r--test/buildtool/execution_api/local/TARGETS1
-rw-r--r--test/buildtool/execution_api/local/local_execution.test.cpp5
-rw-r--r--test/buildtool/graph_traverser/TARGETS1
-rw-r--r--test/buildtool/graph_traverser/graph_traverser_remote.test.cpp4
-rw-r--r--test/buildtool/storage/TARGETS2
-rw-r--r--test/buildtool/storage/local_ac.test.cpp13
-rw-r--r--test/buildtool/storage/local_cas.test.cpp8
-rw-r--r--test/utils/TARGETS1
-rw-r--r--test/utils/hermeticity/test_storage_config.hpp7
12 files changed, 32 insertions, 24 deletions
diff --git a/test/buildtool/build_engine/target_map/target_map.test.cpp b/test/buildtool/build_engine/target_map/target_map.test.cpp
index 0880422f..c64bb306 100644
--- a/test/buildtool/build_engine/target_map/target_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/target_map.test.cpp
@@ -961,10 +961,14 @@ TEST_CASE("built-in rules", "[target_map]") {
CHECK(error_msg == "NONE");
CHECK(bar_result->Artifacts()->ToJson()["foo.txt."]["type"] == "KNOWN");
CHECK(bar_result->Artifacts()->ToJson()["foo.txt."]["data"]["id"] ==
- HashFunction::Instance().ComputeBlobHash("bar").HexString());
+ storage_config.Get()
+ .hash_function.ComputeBlobHash("bar")
+ .HexString());
CHECK(baz_result->Artifacts()->ToJson()["foo.txt."]["type"] == "KNOWN");
CHECK(baz_result->Artifacts()->ToJson()["foo.txt."]["data"]["id"] ==
- HashFunction::Instance().ComputeBlobHash("baz").HexString());
+ storage_config.Get()
+ .hash_function.ComputeBlobHash("baz")
+ .HexString());
}
}
diff --git a/test/buildtool/execution_api/execution_service/TARGETS b/test/buildtool/execution_api/execution_service/TARGETS
index f50057c7..754615d5 100644
--- a/test/buildtool/execution_api/execution_service/TARGETS
+++ b/test/buildtool/execution_api/execution_service/TARGETS
@@ -17,7 +17,6 @@
, ["@", "src", "src/buildtool/storage", "config"]
, ["@", "src", "src/buildtool/storage", "storage"]
, ["@", "gsl", "", "gsl"]
- , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "buildtool", "execution_api", "execution_service"]
}
diff --git a/test/buildtool/execution_api/execution_service/cas_server.test.cpp b/test/buildtool/execution_api/execution_service/cas_server.test.cpp
index 845d94aa..3e566861 100644
--- a/test/buildtool/execution_api/execution_service/cas_server.test.cpp
+++ b/test/buildtool/execution_api/execution_service/cas_server.test.cpp
@@ -17,7 +17,6 @@
#include "catch2/catch_test_macros.hpp"
#include "gsl/gsl"
#include "src/buildtool/common/artifact_digest.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/execution_service/cas_server.hpp"
#include "src/buildtool/file_system/git_repo.hpp"
#include "src/buildtool/file_system/object_type.hpp"
@@ -59,7 +58,7 @@ TEST_CASE("CAS Service: upload incomplete tree", "[execution_service]") {
auto empty_tree = GitRepo::CreateShallowTree(empty_entries);
REQUIRE(empty_tree);
auto empty_tree_digest = ArtifactDigest::Create<ObjectType::Tree>(
- HashFunction::Instance(), empty_tree->second);
+ storage_config.Get().hash_function, empty_tree->second);
// Create a tree containing the empty tree.
auto entries = GitRepo::tree_entries_t{};
@@ -67,7 +66,7 @@ TEST_CASE("CAS Service: upload incomplete tree", "[execution_service]") {
auto tree = GitRepo::CreateShallowTree(entries);
REQUIRE(tree);
auto tree_digest = ArtifactDigest::Create<ObjectType::Tree>(
- HashFunction::Instance(), tree->second);
+ storage_config.Get().hash_function, tree->second);
// Upload tree. The tree invariant is violated, thus, a negative answer is
// expected.
diff --git a/test/buildtool/execution_api/local/TARGETS b/test/buildtool/execution_api/local/TARGETS
index 212bf0b6..41870428 100644
--- a/test/buildtool/execution_api/local/TARGETS
+++ b/test/buildtool/execution_api/local/TARGETS
@@ -15,7 +15,6 @@
, ["utils", "test_storage_config"]
, ["@", "src", "src/buildtool/storage", "storage"]
, ["@", "src", "src/buildtool/storage", "config"]
- , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "buildtool", "execution_api", "local"]
}
diff --git a/test/buildtool/execution_api/local/local_execution.test.cpp b/test/buildtool/execution_api/local/local_execution.test.cpp
index cac83b2a..8aea5950 100644
--- a/test/buildtool/execution_api/local/local_execution.test.cpp
+++ b/test/buildtool/execution_api/local/local_execution.test.cpp
@@ -21,7 +21,6 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_description.hpp"
#include "src/buildtool/common/repository_config.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
@@ -174,7 +173,7 @@ TEST_CASE("LocalExecution: No input, create output", "[execution_api]") {
std::string test_content("test");
auto test_digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), test_content);
+ storage_config.Get().hash_function, test_content);
std::string output_path{"output_file"};
std::vector<std::string> const cmdline = {
@@ -234,7 +233,7 @@ TEST_CASE("LocalExecution: One input copied to output", "[execution_api]") {
std::string test_content("test");
auto test_digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), test_content);
+ storage_config.Get().hash_function, test_content);
REQUIRE(api.Upload(ArtifactBlobContainer{{ArtifactBlob{
test_digest, test_content, /*is_exec=*/false}}},
false));
diff --git a/test/buildtool/graph_traverser/TARGETS b/test/buildtool/graph_traverser/TARGETS
index 4b1a531f..0ed5533f 100644
--- a/test/buildtool/graph_traverser/TARGETS
+++ b/test/buildtool/graph_traverser/TARGETS
@@ -52,6 +52,7 @@
, ["utils", "test_remote_config"]
, ["@", "src", "src/buildtool/storage", "storage"]
, ["@", "src", "src/buildtool/storage", "config"]
+ , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "buildtool", "graph_traverser"]
}
diff --git a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp
index 504b96a1..fa8202ce 100644
--- a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp
+++ b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp
@@ -13,6 +13,7 @@
// limitations under the License.
#include "catch2/catch_test_macros.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -33,6 +34,9 @@
StorageConfig::Builder builder;
auto config = builder.SetBuildRoot(cache_dir)
+ .SetHashType(Compatibility::IsCompatible()
+ ? HashFunction::JustHash::Compatible
+ : HashFunction::JustHash::Native)
.SetRemoteExecutionArgs(remote_config.remote_address,
remote_config.platform_properties,
remote_config.dispatch)
diff --git a/test/buildtool/storage/TARGETS b/test/buildtool/storage/TARGETS
index a2b0b0d2..4a2881c3 100644
--- a/test/buildtool/storage/TARGETS
+++ b/test/buildtool/storage/TARGETS
@@ -24,7 +24,6 @@
, ["utils", "blob_creator"]
, ["@", "src", "src/buildtool/storage", "storage"]
, ["@", "src", "src/buildtool/storage", "config"]
- , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "buildtool", "storage"]
}
@@ -42,7 +41,6 @@
, ["@", "src", "src/buildtool/storage", "storage"]
, ["@", "src", "src/buildtool/storage", "config"]
, ["utils", "test_storage_config"]
- , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "buildtool", "storage"]
}
diff --git a/test/buildtool/storage/local_ac.test.cpp b/test/buildtool/storage/local_ac.test.cpp
index b3a4fcd1..c692a75c 100644
--- a/test/buildtool/storage/local_ac.test.cpp
+++ b/test/buildtool/storage/local_ac.test.cpp
@@ -18,7 +18,6 @@
#include "gsl/gsl"
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/bazel_types.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/storage/config.hpp"
@@ -38,7 +37,7 @@ TEST_CASE("LocalAC: Single action, single result", "[storage]") {
auto const& cas = storage.CAS();
auto action_id = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "action");
+ storage_config.Get().hash_function, "action");
CHECK(not ac.CachedResult(action_id));
CHECK(RunDummyExecution(&ac, &cas, action_id, "result"));
auto ac_result = ac.CachedResult(action_id);
@@ -53,9 +52,9 @@ TEST_CASE("LocalAC: Two different actions, two different results",
auto const& cas = storage.CAS();
auto action_id1 = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "action1");
+ storage_config.Get().hash_function, "action1");
auto action_id2 = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "action2");
+ storage_config.Get().hash_function, "action2");
CHECK(not ac.CachedResult(action_id1));
CHECK(not ac.CachedResult(action_id2));
@@ -84,9 +83,9 @@ TEST_CASE("LocalAC: Two different actions, same two results", "[storage]") {
auto const& cas = storage.CAS();
auto action_id1 = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "action1");
+ storage_config.Get().hash_function, "action1");
auto action_id2 = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "action2");
+ storage_config.Get().hash_function, "action2");
CHECK(not ac.CachedResult(action_id1));
CHECK(not ac.CachedResult(action_id2));
@@ -115,7 +114,7 @@ TEST_CASE("LocalAC: Same two actions, two different results", "[storage]") {
auto const& cas = storage.CAS();
auto action_id = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), "same action");
+ storage_config.Get().hash_function, "same action");
CHECK(not ac.CachedResult(action_id));
std::string result_content1{};
diff --git a/test/buildtool/storage/local_cas.test.cpp b/test/buildtool/storage/local_cas.test.cpp
index c1d65b8e..b4ede8ca 100644
--- a/test/buildtool/storage/local_cas.test.cpp
+++ b/test/buildtool/storage/local_cas.test.cpp
@@ -17,7 +17,6 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
@@ -34,7 +33,7 @@ TEST_CASE("LocalCAS: Add blob to storage from bytes", "[storage]") {
std::string test_bytes("test");
auto test_digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), test_bytes);
+ storage_config.Get().hash_function, test_bytes);
// check blob not in storage
CHECK(not cas.BlobPath(test_digest, true));
@@ -85,7 +84,7 @@ TEST_CASE("LocalCAS: Add blob to storage from non-executable file",
"test/buildtool/storage/data/non_executable_file"};
auto test_blob =
- CreateBlobFromPath(non_exec_file, HashFunction::Instance());
+ CreateBlobFromPath(non_exec_file, storage_config.Get().hash_function);
REQUIRE(test_blob);
// check blob not in storage
@@ -135,7 +134,8 @@ TEST_CASE("LocalCAS: Add blob to storage from executable file", "[storage]") {
std::filesystem::path exec_file{
"test/buildtool/storage/data/executable_file"};
- auto test_blob = CreateBlobFromPath(exec_file, HashFunction::Instance());
+ auto test_blob =
+ CreateBlobFromPath(exec_file, storage_config.Get().hash_function);
REQUIRE(test_blob);
// check blob not in storage
diff --git a/test/utils/TARGETS b/test/utils/TARGETS
index 13ad7626..58353130 100644
--- a/test/utils/TARGETS
+++ b/test/utils/TARGETS
@@ -52,6 +52,7 @@
, ["@", "src", "src/buildtool/logging", "logging"]
, ["@", "src", "src/buildtool/storage", "config"]
, ["@", "src", "src/utils/cpp", "tmp_dir"]
+ , ["@", "src", "src/buildtool/crypto", "hash_function"]
]
, "stage": ["test", "utils"]
}
diff --git a/test/utils/hermeticity/test_storage_config.hpp b/test/utils/hermeticity/test_storage_config.hpp
index e5346c75..26dc53df 100644
--- a/test/utils/hermeticity/test_storage_config.hpp
+++ b/test/utils/hermeticity/test_storage_config.hpp
@@ -21,6 +21,7 @@
#include <utility> //std::move
#include "gsl/gsl"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
@@ -51,7 +52,11 @@ class TestStorageConfig final {
}
StorageConfig::Builder builder;
- auto config = builder.SetBuildRoot(temp_dir->GetPath()).Build();
+ auto config = builder.SetBuildRoot(temp_dir->GetPath())
+ .SetHashType(Compatibility::IsCompatible()
+ ? HashFunction::JustHash::Compatible
+ : HashFunction::JustHash::Native)
+ .Build();
if (not config) {
Logger::Log(LogLevel::Error, config.error());
std::exit(EXIT_FAILURE);