aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/tests')
-rw-r--r--src/libstore/tests/derivation.cc369
-rw-r--r--src/libstore/tests/derived-path.cc153
-rw-r--r--src/libstore/tests/derived-path.hh39
-rw-r--r--src/libstore/tests/downstream-placeholder.cc41
-rw-r--r--src/libstore/tests/libstore.hh26
-rw-r--r--src/libstore/tests/local.mk29
-rw-r--r--src/libstore/tests/machines.cc169
-rw-r--r--src/libstore/tests/nar-info-disk-cache.cc123
-rw-r--r--src/libstore/tests/outputs-spec.cc239
-rw-r--r--src/libstore/tests/outputs-spec.hh18
-rw-r--r--src/libstore/tests/path.cc157
-rw-r--r--src/libstore/tests/path.hh29
-rw-r--r--src/libstore/tests/references.cc45
-rw-r--r--src/libstore/tests/test-data/machines.bad_format1
-rw-r--r--src/libstore/tests/test-data/machines.valid3
15 files changed, 0 insertions, 1441 deletions
diff --git a/src/libstore/tests/derivation.cc b/src/libstore/tests/derivation.cc
deleted file mode 100644
index c360c9707..000000000
--- a/src/libstore/tests/derivation.cc
+++ /dev/null
@@ -1,369 +0,0 @@
-#include <nlohmann/json.hpp>
-#include <gtest/gtest.h>
-
-#include "experimental-features.hh"
-#include "derivations.hh"
-
-#include "tests/libstore.hh"
-
-namespace nix {
-
-class DerivationTest : public LibStoreTest
-{
-public:
- /**
- * We set these in tests rather than the regular globals so we don't have
- * to worry about race conditions if the tests run concurrently.
- */
- ExperimentalFeatureSettings mockXpSettings;
-};
-
-class CaDerivationTest : public DerivationTest
-{
- void SetUp() override
- {
- mockXpSettings.set("experimental-features", "ca-derivations");
- }
-};
-
-class DynDerivationTest : public DerivationTest
-{
- void SetUp() override
- {
- mockXpSettings.set("experimental-features", "dynamic-derivations ca-derivations");
- }
-};
-
-class ImpureDerivationTest : public DerivationTest
-{
- void SetUp() override
- {
- mockXpSettings.set("experimental-features", "impure-derivations");
- }
-};
-
-TEST_F(DerivationTest, BadATerm_version) {
- ASSERT_THROW(
- parseDerivation(
- *store,
- R"(DrvWithVersion("invalid-version",[],[("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv",["cat","dog"])],["/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"],"wasm-sel4","foo",["bar","baz"],[("BIG_BAD","WOLF")]))",
- "whatever",
- mockXpSettings),
- FormatError);
-}
-
-TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps) {
- ASSERT_THROW(
- parseDerivation(
- *store,
- R"(Derive([],[("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv",(["cat","dog"],[("cat",["kitten"]),("goose",["gosling"])]))],["/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"],"wasm-sel4","foo",["bar","baz"],[("BIG_BAD","WOLF")]))",
- "dyn-dep-derivation",
- mockXpSettings),
- FormatError);
-}
-
-#define TEST_JSON(FIXTURE, NAME, STR, VAL, DRV_NAME, OUTPUT_NAME) \
- TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _to_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- STR ## _json, \
- (DerivationOutput { VAL }).toJSON( \
- *store, \
- DRV_NAME, \
- OUTPUT_NAME)); \
- } \
- \
- TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _from_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- DerivationOutput { VAL }, \
- DerivationOutput::fromJSON( \
- *store, \
- DRV_NAME, \
- OUTPUT_NAME, \
- STR ## _json, \
- mockXpSettings)); \
- }
-
-TEST_JSON(DerivationTest, inputAddressed,
- R"({
- "path": "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"
- })",
- (DerivationOutput::InputAddressed {
- .path = store->parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"),
- }),
- "drv-name", "output-name")
-
-TEST_JSON(DerivationTest, caFixedFlat,
- R"({
- "hashAlgo": "sha256",
- "hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f",
- "path": "/nix/store/rhcg9h16sqvlbpsa6dqm57sbr2al6nzg-drv-name-output-name"
- })",
- (DerivationOutput::CAFixed {
- .ca = {
- .method = FileIngestionMethod::Flat,
- .hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
- },
- }),
- "drv-name", "output-name")
-
-TEST_JSON(DerivationTest, caFixedNAR,
- R"({
- "hashAlgo": "r:sha256",
- "hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f",
- "path": "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"
- })",
- (DerivationOutput::CAFixed {
- .ca = {
- .method = FileIngestionMethod::Recursive,
- .hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
- },
- }),
- "drv-name", "output-name")
-
-TEST_JSON(DynDerivationTest, caFixedText,
- R"({
- "hashAlgo": "text:sha256",
- "hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f",
- "path": "/nix/store/6s1zwabh956jvhv4w9xcdb5jiyanyxg1-drv-name-output-name"
- })",
- (DerivationOutput::CAFixed {
- .ca = {
- .hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
- },
- }),
- "drv-name", "output-name")
-
-TEST_JSON(CaDerivationTest, caFloating,
- R"({
- "hashAlgo": "r:sha256"
- })",
- (DerivationOutput::CAFloating {
- .method = FileIngestionMethod::Recursive,
- .hashType = htSHA256,
- }),
- "drv-name", "output-name")
-
-TEST_JSON(DerivationTest, deferred,
- R"({ })",
- DerivationOutput::Deferred { },
- "drv-name", "output-name")
-
-TEST_JSON(ImpureDerivationTest, impure,
- R"({
- "hashAlgo": "r:sha256",
- "impure": true
- })",
- (DerivationOutput::Impure {
- .method = FileIngestionMethod::Recursive,
- .hashType = htSHA256,
- }),
- "drv-name", "output-name")
-
-#undef TEST_JSON
-
-#define TEST_JSON(FIXTURE, NAME, STR, VAL) \
- TEST_F(FIXTURE, Derivation_ ## NAME ## _to_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- STR ## _json, \
- (VAL).toJSON(*store)); \
- } \
- \
- TEST_F(FIXTURE, Derivation_ ## NAME ## _from_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- (VAL), \
- Derivation::fromJSON( \
- *store, \
- STR ## _json, \
- mockXpSettings)); \
- }
-
-#define TEST_ATERM(FIXTURE, NAME, STR, VAL, DRV_NAME) \
- TEST_F(FIXTURE, Derivation_ ## NAME ## _to_aterm) { \
- ASSERT_EQ( \
- STR, \
- (VAL).unparse(*store, false)); \
- } \
- \
- TEST_F(FIXTURE, Derivation_ ## NAME ## _from_aterm) { \
- auto parsed = parseDerivation( \
- *store, \
- STR, \
- DRV_NAME, \
- mockXpSettings); \
- ASSERT_EQ( \
- (VAL).toJSON(*store), \
- parsed.toJSON(*store)); \
- ASSERT_EQ( \
- (VAL), \
- parsed); \
- }
-
-Derivation makeSimpleDrv(const Store & store) {
- Derivation drv;
- drv.name = "simple-derivation";
- drv.inputSrcs = {
- store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
- };
- drv.inputDrvs = {
- .map = {
- {
- store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
- {
- .value = {
- "cat",
- "dog",
- },
- },
- },
- },
- };
- drv.platform = "wasm-sel4";
- drv.builder = "foo";
- drv.args = {
- "bar",
- "baz",
- };
- drv.env = {
- {
- "BIG_BAD",
- "WOLF",
- },
- };
- return drv;
-}
-
-TEST_JSON(DerivationTest, simple,
- R"({
- "name": "simple-derivation",
- "inputSrcs": [
- "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"
- ],
- "inputDrvs": {
- "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv": {
- "dynamicOutputs": {},
- "outputs": [
- "cat",
- "dog"
- ]
- }
- },
- "system": "wasm-sel4",
- "builder": "foo",
- "args": [
- "bar",
- "baz"
- ],
- "env": {
- "BIG_BAD": "WOLF"
- },
- "outputs": {}
- })",
- makeSimpleDrv(*store))
-
-TEST_ATERM(DerivationTest, simple,
- R"(Derive([],[("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv",["cat","dog"])],["/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"],"wasm-sel4","foo",["bar","baz"],[("BIG_BAD","WOLF")]))",
- makeSimpleDrv(*store),
- "simple-derivation")
-
-Derivation makeDynDepDerivation(const Store & store) {
- Derivation drv;
- drv.name = "dyn-dep-derivation";
- drv.inputSrcs = {
- store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
- };
- drv.inputDrvs = {
- .map = {
- {
- store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
- DerivedPathMap<StringSet>::ChildNode {
- .value = {
- "cat",
- "dog",
- },
- .childMap = {
- {
- "cat",
- DerivedPathMap<StringSet>::ChildNode {
- .value = {
- "kitten",
- },
- },
- },
- {
- "goose",
- DerivedPathMap<StringSet>::ChildNode {
- .value = {
- "gosling",
- },
- },
- },
- },
- },
- },
- },
- };
- drv.platform = "wasm-sel4";
- drv.builder = "foo";
- drv.args = {
- "bar",
- "baz",
- };
- drv.env = {
- {
- "BIG_BAD",
- "WOLF",
- },
- };
- return drv;
-}
-
-TEST_JSON(DynDerivationTest, dynDerivationDeps,
- R"({
- "name": "dyn-dep-derivation",
- "inputSrcs": [
- "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"
- ],
- "inputDrvs": {
- "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv": {
- "dynamicOutputs": {
- "cat": {
- "dynamicOutputs": {},
- "outputs": ["kitten"]
- },
- "goose": {
- "dynamicOutputs": {},
- "outputs": ["gosling"]
- }
- },
- "outputs": [
- "cat",
- "dog"
- ]
- }
- },
- "system": "wasm-sel4",
- "builder": "foo",
- "args": [
- "bar",
- "baz"
- ],
- "env": {
- "BIG_BAD": "WOLF"
- },
- "outputs": {}
- })",
- makeDynDepDerivation(*store))
-
-TEST_ATERM(DynDerivationTest, dynDerivationDeps,
- R"(DrvWithVersion("xp-dyn-drv",[],[("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv",(["cat","dog"],[("cat",["kitten"]),("goose",["gosling"])]))],["/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"],"wasm-sel4","foo",["bar","baz"],[("BIG_BAD","WOLF")]))",
- makeDynDepDerivation(*store),
- "dyn-dep-derivation")
-
-#undef TEST_JSON
-#undef TEST_ATERM
-
-}
diff --git a/src/libstore/tests/derived-path.cc b/src/libstore/tests/derived-path.cc
deleted file mode 100644
index 3fa3c0801..000000000
--- a/src/libstore/tests/derived-path.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <regex>
-
-#include <nlohmann/json.hpp>
-#include <gtest/gtest.h>
-#include <rapidcheck/gtest.h>
-
-#include "tests/derived-path.hh"
-#include "tests/libstore.hh"
-
-namespace rc {
-using namespace nix;
-
-Gen<DerivedPath::Opaque> Arbitrary<DerivedPath::Opaque>::arbitrary()
-{
- return gen::just(DerivedPath::Opaque {
- .path = *gen::arbitrary<StorePath>(),
- });
-}
-
-Gen<SingleDerivedPath::Built> Arbitrary<SingleDerivedPath::Built>::arbitrary()
-{
- return gen::just(SingleDerivedPath::Built {
- .drvPath = make_ref<SingleDerivedPath>(*gen::arbitrary<SingleDerivedPath>()),
- .output = (*gen::arbitrary<StorePathName>()).name,
- });
-}
-
-Gen<DerivedPath::Built> Arbitrary<DerivedPath::Built>::arbitrary()
-{
- return gen::just(DerivedPath::Built {
- .drvPath = make_ref<SingleDerivedPath>(*gen::arbitrary<SingleDerivedPath>()),
- .outputs = *gen::arbitrary<OutputsSpec>(),
- });
-}
-
-Gen<SingleDerivedPath> Arbitrary<SingleDerivedPath>::arbitrary()
-{
- switch (*gen::inRange<uint8_t>(0, std::variant_size_v<SingleDerivedPath::Raw>)) {
- case 0:
- return gen::just<SingleDerivedPath>(*gen::arbitrary<SingleDerivedPath::Opaque>());
- case 1:
- return gen::just<SingleDerivedPath>(*gen::arbitrary<SingleDerivedPath::Built>());
- default:
- assert(false);
- }
-}
-
-Gen<DerivedPath> Arbitrary<DerivedPath>::arbitrary()
-{
- switch (*gen::inRange<uint8_t>(0, std::variant_size_v<DerivedPath::Raw>)) {
- case 0:
- return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Opaque>());
- case 1:
- return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Built>());
- default:
- assert(false);
- }
-}
-
-}
-
-namespace nix {
-
-class DerivedPathTest : public LibStoreTest
-{
-};
-
-/**
- * Round trip (string <-> data structure) test for
- * `DerivedPath::Opaque`.
- */
-TEST_F(DerivedPathTest, opaque) {
- std::string_view opaque = "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
- auto elem = DerivedPath::parse(*store, opaque);
- auto * p = std::get_if<DerivedPath::Opaque>(&elem);
- ASSERT_TRUE(p);
- ASSERT_EQ(p->path, store->parseStorePath(opaque));
- ASSERT_EQ(elem.to_string(*store), opaque);
-}
-
-/**
- * Round trip (string <-> data structure) test for a simpler
- * `DerivedPath::Built`.
- */
-TEST_F(DerivedPathTest, built_opaque) {
- std::string_view built = "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x.drv^bar,foo";
- auto elem = DerivedPath::parse(*store, built);
- auto * p = std::get_if<DerivedPath::Built>(&elem);
- ASSERT_TRUE(p);
- ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names { "foo", "bar" }));
- ASSERT_EQ(*p->drvPath, ((SingleDerivedPath) SingleDerivedPath::Opaque {
- .path = store->parseStorePath(built.substr(0, 49)),
- }));
- ASSERT_EQ(elem.to_string(*store), built);
-}
-
-/**
- * Round trip (string <-> data structure) test for a more complex,
- * inductive `DerivedPath::Built`.
- */
-TEST_F(DerivedPathTest, built_built) {
- /**
- * We set these in tests rather than the regular globals so we don't have
- * to worry about race conditions if the tests run concurrently.
- */
- ExperimentalFeatureSettings mockXpSettings;
- mockXpSettings.set("experimental-features", "dynamic-derivations ca-derivations");
-
- std::string_view built = "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x.drv^foo^bar,baz";
- auto elem = DerivedPath::parse(*store, built, mockXpSettings);
- auto * p = std::get_if<DerivedPath::Built>(&elem);
- ASSERT_TRUE(p);
- ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names { "bar", "baz" }));
- auto * drvPath = std::get_if<SingleDerivedPath::Built>(&*p->drvPath);
- ASSERT_TRUE(drvPath);
- ASSERT_EQ(drvPath->output, "foo");
- ASSERT_EQ(*drvPath->drvPath, ((SingleDerivedPath) SingleDerivedPath::Opaque {
- .path = store->parseStorePath(built.substr(0, 49)),
- }));
- ASSERT_EQ(elem.to_string(*store), built);
-}
-
-/**
- * Without the right experimental features enabled, we cannot parse a
- * complex inductive derived path.
- */
-TEST_F(DerivedPathTest, built_built_xp) {
- ASSERT_THROW(
- DerivedPath::parse(*store, "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x.drv^foo^bar,baz"),
- MissingExperimentalFeature);
-}
-
-#ifndef COVERAGE
-
-RC_GTEST_FIXTURE_PROP(
- DerivedPathTest,
- prop_legacy_round_rip,
- (const DerivedPath & o))
-{
- RC_ASSERT(o == DerivedPath::parseLegacy(*store, o.to_string_legacy(*store)));
-}
-
-RC_GTEST_FIXTURE_PROP(
- DerivedPathTest,
- prop_round_rip,
- (const DerivedPath & o))
-{
- RC_ASSERT(o == DerivedPath::parse(*store, o.to_string(*store)));
-}
-
-#endif
-
-}
diff --git a/src/libstore/tests/derived-path.hh b/src/libstore/tests/derived-path.hh
deleted file mode 100644
index 98d61f228..000000000
--- a/src/libstore/tests/derived-path.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-///@file
-
-#include <rapidcheck/gen/Arbitrary.h>
-
-#include <derived-path.hh>
-
-#include "tests/path.hh"
-#include "tests/outputs-spec.hh"
-
-namespace rc {
-using namespace nix;
-
-template<>
-struct Arbitrary<SingleDerivedPath::Opaque> {
- static Gen<SingleDerivedPath::Opaque> arbitrary();
-};
-
-template<>
-struct Arbitrary<SingleDerivedPath::Built> {
- static Gen<SingleDerivedPath::Built> arbitrary();
-};
-
-template<>
-struct Arbitrary<SingleDerivedPath> {
- static Gen<SingleDerivedPath> arbitrary();
-};
-
-template<>
-struct Arbitrary<DerivedPath::Built> {
- static Gen<DerivedPath::Built> arbitrary();
-};
-
-template<>
-struct Arbitrary<DerivedPath> {
- static Gen<DerivedPath> arbitrary();
-};
-
-}
diff --git a/src/libstore/tests/downstream-placeholder.cc b/src/libstore/tests/downstream-placeholder.cc
deleted file mode 100644
index fd29530ac..000000000
--- a/src/libstore/tests/downstream-placeholder.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <gtest/gtest.h>
-
-#include "downstream-placeholder.hh"
-
-namespace nix {
-
-TEST(DownstreamPlaceholder, unknownCaOutput) {
- /**
- * We set these in tests rather than the regular globals so we don't have
- * to worry about race conditions if the tests run concurrently.
- */
- ExperimentalFeatureSettings mockXpSettings;
- mockXpSettings.set("experimental-features", "ca-derivations");
-
- ASSERT_EQ(
- DownstreamPlaceholder::unknownCaOutput(
- StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv" },
- "out",
- mockXpSettings).render(),
- "/0c6rn30q4frawknapgwq386zq358m8r6msvywcvc89n6m5p2dgbz");
-}
-
-TEST(DownstreamPlaceholder, unknownDerivation) {
- /**
- * Same reason as above
- */
- ExperimentalFeatureSettings mockXpSettings;
- mockXpSettings.set("experimental-features", "dynamic-derivations ca-derivations");
-
- ASSERT_EQ(
- DownstreamPlaceholder::unknownDerivation(
- DownstreamPlaceholder::unknownCaOutput(
- StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv.drv" },
- "out",
- mockXpSettings),
- "out",
- mockXpSettings).render(),
- "/0gn6agqxjyyalf0dpihgyf49xq5hqxgw100f0wydnj6yqrhqsb3w");
-}
-
-}
diff --git a/src/libstore/tests/libstore.hh b/src/libstore/tests/libstore.hh
deleted file mode 100644
index ef93457b5..000000000
--- a/src/libstore/tests/libstore.hh
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-///@file
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "store-api.hh"
-
-namespace nix {
-
-class LibStoreTest : public ::testing::Test {
- public:
- static void SetUpTestSuite() {
- initLibStore();
- }
-
- protected:
- LibStoreTest()
- : store(openStore("dummy://"))
- { }
-
- ref<Store> store;
-};
-
-
-} /* namespace nix */
diff --git a/src/libstore/tests/local.mk b/src/libstore/tests/local.mk
deleted file mode 100644
index 03becc7d1..000000000
--- a/src/libstore/tests/local.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-check: libstore-tests-exe_RUN
-
-programs += libstore-tests-exe
-
-libstore-tests-exe_NAME = libnixstore-tests
-
-libstore-tests-exe_DIR := $(d)
-
-libstore-tests-exe_INSTALL_DIR :=
-
-libstore-tests-exe_LIBS = libstore-tests
-
-libstore-tests-exe_LDFLAGS := $(GTEST_LIBS)
-
-libraries += libstore-tests
-
-libstore-tests_NAME = libnixstore-tests
-
-libstore-tests_DIR := $(d)
-
-libstore-tests_INSTALL_DIR :=
-
-libstore-tests_SOURCES := $(wildcard $(d)/*.cc)
-
-libstore-tests_CXXFLAGS += -I src/libstore -I src/libutil
-
-libstore-tests_LIBS = libutil-tests libstore libutil
-
-libstore-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS)
diff --git a/src/libstore/tests/machines.cc b/src/libstore/tests/machines.cc
deleted file mode 100644
index f51052b14..000000000
--- a/src/libstore/tests/machines.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-#include "machines.hh"
-#include "globals.hh"
-
-#include <gmock/gmock-matchers.h>
-
-using testing::Contains;
-using testing::ElementsAre;
-using testing::EndsWith;
-using testing::Eq;
-using testing::Field;
-using testing::SizeIs;
-
-using nix::absPath;
-using nix::FormatError;
-using nix::getMachines;
-using nix::Machine;
-using nix::Machines;
-using nix::pathExists;
-using nix::Settings;
-using nix::settings;
-
-class Environment : public ::testing::Environment {
- public:
- void SetUp() override { settings.thisSystem = "TEST_ARCH-TEST_OS"; }
-};
-
-testing::Environment* const foo_env =
- testing::AddGlobalTestEnvironment(new Environment);
-
-TEST(machines, getMachinesWithEmptyBuilders) {
- settings.builders = "";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(0));
-}
-
-TEST(machines, getMachinesUriOnly) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(1));
- EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
- EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("TEST_ARCH-TEST_OS")));
- EXPECT_THAT(actual[0], Field(&Machine::sshKey, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(1)));
- EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(1)));
- EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, SizeIs(0)));
-}
-
-TEST(machines, getMachinesDefaults) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - - - - - -";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(1));
- EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
- EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("TEST_ARCH-TEST_OS")));
- EXPECT_THAT(actual[0], Field(&Machine::sshKey, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(1)));
- EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(1)));
- EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, SizeIs(0)));
- EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, SizeIs(0)));
-}
-
-TEST(machines, getMachinesWithNewLineSeparator) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl\nnix@itchy.labs.cs.uu.nl";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(2));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@itchy.labs.cs.uu.nl"))));
-}
-
-TEST(machines, getMachinesWithSemicolonSeparator) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl";
- Machines actual = getMachines();
- EXPECT_THAT(actual, SizeIs(2));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@itchy.labs.cs.uu.nl"))));
-}
-
-TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl i686-linux "
- "/home/nix/.ssh/id_scratchy_auto 8 3 kvm "
- "benchmark SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(1));
- EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
- EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("i686-linux")));
- EXPECT_THAT(actual[0], Field(&Machine::sshKey, Eq("/home/nix/.ssh/id_scratchy_auto")));
- EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(8)));
- EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(3)));
- EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, ElementsAre("kvm")));
- EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, ElementsAre("benchmark")));
- EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, Eq("SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==")));
-}
-
-TEST(machines,
- getMachinesWithCorrectCompleteSingleBuilderWithTabColumnDelimiter) {
- settings.builders =
- "nix@scratchy.labs.cs.uu.nl\ti686-linux\t/home/nix/.ssh/"
- "id_scratchy_auto\t8\t3\tkvm\tbenchmark\tSSH+HOST+PUBLIC+"
- "KEY+BASE64+ENCODED==";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(1));
- EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
- EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("i686-linux")));
- EXPECT_THAT(actual[0], Field(&Machine::sshKey, Eq("/home/nix/.ssh/id_scratchy_auto")));
- EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(8)));
- EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(3)));
- EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, ElementsAre("kvm")));
- EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, ElementsAre("benchmark")));
- EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, Eq("SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==")));
-}
-
-TEST(machines, getMachinesWithMultiOptions) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl Arch1,Arch2 - - - "
- "SupportedFeature1,SupportedFeature2 "
- "MandatoryFeature1,MandatoryFeature2";
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(1));
- EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
- EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("Arch1", "Arch2")));
- EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, ElementsAre("SupportedFeature1", "SupportedFeature2")));
- EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, ElementsAre("MandatoryFeature1", "MandatoryFeature2")));
-}
-
-TEST(machines, getMachinesWithIncorrectFormat) {
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - eight";
- EXPECT_THROW(getMachines(), FormatError);
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - -1";
- EXPECT_THROW(getMachines(), FormatError);
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 three";
- EXPECT_THROW(getMachines(), FormatError);
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 -3";
- EXPECT_THROW(getMachines(), FormatError);
- settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 3 - - BAD_BASE64";
- EXPECT_THROW(getMachines(), FormatError);
-}
-
-TEST(machines, getMachinesWithCorrectFileReference) {
- auto path = absPath("src/libstore/tests/test-data/machines.valid");
- ASSERT_TRUE(pathExists(path));
-
- settings.builders = std::string("@") + path;
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(3));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@itchy.labs.cs.uu.nl"))));
- EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@poochie.labs.cs.uu.nl"))));
-}
-
-TEST(machines, getMachinesWithCorrectFileReferenceToEmptyFile) {
- auto path = "/dev/null";
- ASSERT_TRUE(pathExists(path));
-
- settings.builders = std::string("@") + path;
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(0));
-}
-
-TEST(machines, getMachinesWithIncorrectFileReference) {
- settings.builders = std::string("@") + absPath("/not/a/file");
- Machines actual = getMachines();
- ASSERT_THAT(actual, SizeIs(0));
-}
-
-TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
- settings.builders = std::string("@") + absPath("src/libstore/tests/test-data/machines.bad_format");
- EXPECT_THROW(getMachines(), FormatError);
-}
diff --git a/src/libstore/tests/nar-info-disk-cache.cc b/src/libstore/tests/nar-info-disk-cache.cc
deleted file mode 100644
index b4bdb8329..000000000
--- a/src/libstore/tests/nar-info-disk-cache.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "nar-info-disk-cache.hh"
-
-#include <gtest/gtest.h>
-#include <rapidcheck/gtest.h>
-#include "sqlite.hh"
-#include <sqlite3.h>
-
-
-namespace nix {
-
-TEST(NarInfoDiskCacheImpl, create_and_read) {
- // This is a large single test to avoid some setup overhead.
-
- int prio = 12345;
- bool wantMassQuery = true;
-
- Path tmpDir = createTempDir();
- AutoDelete delTmpDir(tmpDir);
- Path dbPath(tmpDir + "/test-narinfo-disk-cache.sqlite");
-
- int savedId;
- int barId;
- SQLite db;
- SQLiteStmt getIds;
-
- {
- auto cache = getTestNarInfoDiskCache(dbPath);
-
- // Set up "background noise" and check that different caches receive different ids
- {
- auto bc1 = cache->createCache("https://bar", "/nix/storedir", wantMassQuery, prio);
- auto bc2 = cache->createCache("https://xyz", "/nix/storedir", false, 12);
- ASSERT_NE(bc1, bc2);
- barId = bc1;
- }
-
- // Check that the fields are saved and returned correctly. This does not test
- // the select statement yet, because of in-memory caching.
- savedId = cache->createCache("http://foo", "/nix/storedir", wantMassQuery, prio);;
- {
- auto r = cache->upToDateCacheExists("http://foo");
- ASSERT_TRUE(r);
- ASSERT_EQ(r->priority, prio);
- ASSERT_EQ(r->wantMassQuery, wantMassQuery);
- ASSERT_EQ(savedId, r->id);
- }
-
- // We're going to pay special attention to the id field because we had a bug
- // that changed it.
- db = SQLite(dbPath);
- getIds.create(db, "select id from BinaryCaches where url = 'http://foo'");
-
- {
- auto q(getIds.use());
- ASSERT_TRUE(q.next());
- ASSERT_EQ(savedId, q.getInt(0));
- ASSERT_FALSE(q.next());
- }
-
- // Pretend that the caches are older, but keep one up to date, as "background noise"
- db.exec("update BinaryCaches set timestamp = timestamp - 1 - 7 * 24 * 3600 where url <> 'https://xyz';");
-
- // This shows that the in-memory cache works
- {
- auto r = cache->upToDateCacheExists("http://foo");
- ASSERT_TRUE(r);
- ASSERT_EQ(r->priority, prio);
- ASSERT_EQ(r->wantMassQuery, wantMassQuery);
- }
- }
-
- {
- // We can't clear the in-memory cache, so we use a new cache object. This is
- // more realistic anyway.
- auto cache2 = getTestNarInfoDiskCache(dbPath);
-
- {
- auto r = cache2->upToDateCacheExists("http://foo");
- ASSERT_FALSE(r);
- }
-
- // "Update", same data, check that the id number is reused
- cache2->createCache("http://foo", "/nix/storedir", wantMassQuery, prio);
-
- {
- auto r = cache2->upToDateCacheExists("http://foo");
- ASSERT_TRUE(r);
- ASSERT_EQ(r->priority, prio);
- ASSERT_EQ(r->wantMassQuery, wantMassQuery);
- ASSERT_EQ(r->id, savedId);
- }
-
- {
- auto q(getIds.use());
- ASSERT_TRUE(q.next());
- auto currentId = q.getInt(0);
- ASSERT_FALSE(q.next());
- ASSERT_EQ(currentId, savedId);
- }
-
- // Check that the fields can be modified, and the id remains the same
- {
- auto r0 = cache2->upToDateCacheExists("https://bar");
- ASSERT_FALSE(r0);
-
- cache2->createCache("https://bar", "/nix/storedir", !wantMassQuery, prio + 10);
- auto r = cache2->upToDateCacheExists("https://bar");
- ASSERT_EQ(r->wantMassQuery, !wantMassQuery);
- ASSERT_EQ(r->priority, prio + 10);
- ASSERT_EQ(r->id, barId);
- }
-
- // // Force update (no use case yet; we only retrieve cache metadata when stale based on timestamp)
- // {
- // cache2->createCache("https://bar", "/nix/storedir", wantMassQuery, prio + 20);
- // auto r = cache2->upToDateCacheExists("https://bar");
- // ASSERT_EQ(r->wantMassQuery, wantMassQuery);
- // ASSERT_EQ(r->priority, prio + 20);
- // }
- }
-}
-
-}
diff --git a/src/libstore/tests/outputs-spec.cc b/src/libstore/tests/outputs-spec.cc
deleted file mode 100644
index 952945185..000000000
--- a/src/libstore/tests/outputs-spec.cc
+++ /dev/null
@@ -1,239 +0,0 @@
-#include "outputs-spec.hh"
-
-#include <nlohmann/json.hpp>
-#include <gtest/gtest.h>
-#include <rapidcheck/gtest.h>
-
-namespace nix {
-
-#ifndef NDEBUG
-TEST(OutputsSpec, no_empty_names) {
- ASSERT_DEATH(OutputsSpec::Names { std::set<std::string> { } }, "");
-}
-#endif
-
-#define TEST_DONT_PARSE(NAME, STR) \
- TEST(OutputsSpec, bad_ ## NAME) { \
- std::optional OutputsSpecOpt = \
- OutputsSpec::parseOpt(STR); \
- ASSERT_FALSE(OutputsSpecOpt); \
- }
-
-TEST_DONT_PARSE(empty, "")
-TEST_DONT_PARSE(garbage, "&*()")
-TEST_DONT_PARSE(double_star, "**")
-TEST_DONT_PARSE(star_first, "*,foo")
-TEST_DONT_PARSE(star_second, "foo,*")
-
-#undef TEST_DONT_PARSE
-
-TEST(OutputsSpec, all) {
- std::string_view str = "*";
- OutputsSpec expected = OutputsSpec::All { };
- ASSERT_EQ(OutputsSpec::parse(str), expected);
- ASSERT_EQ(expected.to_string(), str);
-}
-
-TEST(OutputsSpec, names_out) {
- std::string_view str = "out";
- OutputsSpec expected = OutputsSpec::Names { "out" };
- ASSERT_EQ(OutputsSpec::parse(str), expected);
- ASSERT_EQ(expected.to_string(), str);
-}
-
-TEST(OutputsSpec, names_underscore) {
- std::string_view str = "a_b";
- OutputsSpec expected = OutputsSpec::Names { "a_b" };
- ASSERT_EQ(OutputsSpec::parse(str), expected);
- ASSERT_EQ(expected.to_string(), str);
-}
-
-TEST(OutputsSpec, names_numberic) {
- std::string_view str = "01";
- OutputsSpec expected = OutputsSpec::Names { "01" };
- ASSERT_EQ(OutputsSpec::parse(str), expected);
- ASSERT_EQ(expected.to_string(), str);
-}
-
-TEST(OutputsSpec, names_out_bin) {
- OutputsSpec expected = OutputsSpec::Names { "out", "bin" };
- ASSERT_EQ(OutputsSpec::parse("out,bin"), expected);
- // N.B. This normalization is OK.
- ASSERT_EQ(expected.to_string(), "bin,out");
-}
-
-#define TEST_SUBSET(X, THIS, THAT) \
- X((OutputsSpec { THIS }).isSubsetOf(THAT));
-
-TEST(OutputsSpec, subsets_all_all) {
- TEST_SUBSET(ASSERT_TRUE, OutputsSpec::All { }, OutputsSpec::All { });
-}
-
-TEST(OutputsSpec, subsets_names_all) {
- TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, OutputsSpec::All { });
-}
-
-TEST(OutputsSpec, subsets_names_names_eq) {
- TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, OutputsSpec::Names { "a" });
-}
-
-TEST(OutputsSpec, subsets_names_names_noneq) {
- TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, (OutputsSpec::Names { "a", "b" }));
-}
-
-TEST(OutputsSpec, not_subsets_all_names) {
- TEST_SUBSET(ASSERT_FALSE, OutputsSpec::All { }, OutputsSpec::Names { "a" });
-}
-
-TEST(OutputsSpec, not_subsets_names_names) {
- TEST_SUBSET(ASSERT_FALSE, (OutputsSpec::Names { "a", "b" }), (OutputsSpec::Names { "a" }));
-}
-
-#undef TEST_SUBSET
-
-#define TEST_UNION(RES, THIS, THAT) \
- ASSERT_EQ(OutputsSpec { RES }, (OutputsSpec { THIS }).union_(THAT));
-
-TEST(OutputsSpec, union_all_all) {
- TEST_UNION(OutputsSpec::All { }, OutputsSpec::All { }, OutputsSpec::All { });
-}
-
-TEST(OutputsSpec, union_all_names) {
- TEST_UNION(OutputsSpec::All { }, OutputsSpec::All { }, OutputsSpec::Names { "a" });
-}
-
-TEST(OutputsSpec, union_names_all) {
- TEST_UNION(OutputsSpec::All { }, OutputsSpec::Names { "a" }, OutputsSpec::All { });
-}
-
-TEST(OutputsSpec, union_names_names) {
- TEST_UNION((OutputsSpec::Names { "a", "b" }), OutputsSpec::Names { "a" }, OutputsSpec::Names { "b" });
-}
-
-#undef TEST_UNION
-
-#define TEST_DONT_PARSE(NAME, STR) \
- TEST(ExtendedOutputsSpec, bad_ ## NAME) { \
- std::optional extendedOutputsSpecOpt = \
- ExtendedOutputsSpec::parseOpt(STR); \
- ASSERT_FALSE(extendedOutputsSpecOpt); \
- }
-
-TEST_DONT_PARSE(carot_empty, "^")
-TEST_DONT_PARSE(prefix_carot_empty, "foo^")
-TEST_DONT_PARSE(garbage, "^&*()")
-TEST_DONT_PARSE(double_star, "^**")
-TEST_DONT_PARSE(star_first, "^*,foo")
-TEST_DONT_PARSE(star_second, "^foo,*")
-
-#undef TEST_DONT_PARSE
-
-TEST(ExtendedOutputsSpec, defeault) {
- std::string_view str = "foo";
- auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
- ASSERT_EQ(prefix, "foo");
- ExtendedOutputsSpec expected = ExtendedOutputsSpec::Default { };
- ASSERT_EQ(extendedOutputsSpec, expected);
- ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
-}
-
-TEST(ExtendedOutputsSpec, all) {
- std::string_view str = "foo^*";
- auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
- ASSERT_EQ(prefix, "foo");
- ExtendedOutputsSpec expected = OutputsSpec::All { };
- ASSERT_EQ(extendedOutputsSpec, expected);
- ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
-}
-
-TEST(ExtendedOutputsSpec, out) {
- std::string_view str = "foo^out";
- auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
- ASSERT_EQ(prefix, "foo");
- ExtendedOutputsSpec expected = OutputsSpec::Names { "out" };
- ASSERT_EQ(extendedOutputsSpec, expected);
- ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
-}
-
-TEST(ExtendedOutputsSpec, out_bin) {
- auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse("foo^out,bin");
- ASSERT_EQ(prefix, "foo");
- ExtendedOutputsSpec expected = OutputsSpec::Names { "out", "bin" };
- ASSERT_EQ(extendedOutputsSpec, expected);
- ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bin,out");
-}
-
-TEST(ExtendedOutputsSpec, many_carrot) {
- auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse("foo^bar^out,bin");
- ASSERT_EQ(prefix, "foo^bar");
- ExtendedOutputsSpec expected = OutputsSpec::Names { "out", "bin" };
- ASSERT_EQ(extendedOutputsSpec, expected);
- ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bar^bin,out");
-}
-
-
-#define TEST_JSON(TYPE, NAME, STR, VAL) \
- \
- TEST(TYPE, NAME ## _to_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- STR ## _json, \
- ((nlohmann::json) TYPE { VAL })); \
- } \
- \
- TEST(TYPE, NAME ## _from_json) { \
- using nlohmann::literals::operator "" _json; \
- ASSERT_EQ( \
- TYPE { VAL }, \
- (STR ## _json).get<TYPE>()); \
- }
-
-TEST_JSON(OutputsSpec, all, R"(["*"])", OutputsSpec::All { })
-TEST_JSON(OutputsSpec, name, R"(["a"])", OutputsSpec::Names { "a" })
-TEST_JSON(OutputsSpec, names, R"(["a","b"])", (OutputsSpec::Names { "a", "b" }))
-
-TEST_JSON(ExtendedOutputsSpec, def, R"(null)", ExtendedOutputsSpec::Default { })
-TEST_JSON(ExtendedOutputsSpec, all, R"(["*"])", ExtendedOutputsSpec::Explicit { OutputsSpec::All { } })
-TEST_JSON(ExtendedOutputsSpec, name, R"(["a"])", ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a" } })
-TEST_JSON(ExtendedOutputsSpec, names, R"(["a","b"])", (ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a", "b" } }))
-
-#undef TEST_JSON
-
-}
-
-namespace rc {
-using namespace nix;
-
-Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary()
-{
- switch (*gen::inRange<uint8_t>(0, std::variant_size_v<OutputsSpec::Raw>)) {
- case 0:
- return gen::just((OutputsSpec) OutputsSpec::All { });
- case 1:
- return gen::just((OutputsSpec) OutputsSpec::Names {
- *gen::nonEmpty(gen::container<StringSet>(gen::map(
- gen::arbitrary<StorePathName>(),
- [](StorePathName n) { return n.name; }))),
- });
- default:
- assert(false);
- }
-}
-
-}
-
-namespace nix {
-
-#ifndef COVERAGE
-
-RC_GTEST_PROP(
- OutputsSpec,
- prop_round_rip,
- (const OutputsSpec & o))
-{
- RC_ASSERT(o == OutputsSpec::parse(o.to_string()));
-}
-
-#endif
-
-}
diff --git a/src/libstore/tests/outputs-spec.hh b/src/libstore/tests/outputs-spec.hh
deleted file mode 100644
index ded331b33..000000000
--- a/src/libstore/tests/outputs-spec.hh
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-///@file
-
-#include <rapidcheck/gen/Arbitrary.h>
-
-#include <outputs-spec.hh>
-
-#include <tests/path.hh>
-
-namespace rc {
-using namespace nix;
-
-template<>
-struct Arbitrary<OutputsSpec> {
- static Gen<OutputsSpec> arbitrary();
-};
-
-}
diff --git a/src/libstore/tests/path.cc b/src/libstore/tests/path.cc
deleted file mode 100644
index efa35ef2b..000000000
--- a/src/libstore/tests/path.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-#include <regex>
-
-#include <nlohmann/json.hpp>
-#include <gtest/gtest.h>
-#include <rapidcheck/gtest.h>
-
-#include "path-regex.hh"
-#include "store-api.hh"
-
-#include "tests/hash.hh"
-#include "tests/libstore.hh"
-#include "tests/path.hh"
-
-namespace nix {
-
-#define STORE_DIR "/nix/store/"
-#define HASH_PART "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q"
-
-class StorePathTest : public LibStoreTest
-{
-};
-
-static std::regex nameRegex { std::string { nameRegexStr } };
-
-#define TEST_DONT_PARSE(NAME, STR) \
- TEST_F(StorePathTest, bad_ ## NAME) { \
- std::string_view str = \
- STORE_DIR HASH_PART "-" STR; \
- ASSERT_THROW( \
- store->parseStorePath(str), \
- BadStorePath); \
- std::string name { STR }; \
- EXPECT_FALSE(std::regex_match(name, nameRegex)); \
- }
-
-TEST_DONT_PARSE(empty, "")
-TEST_DONT_PARSE(garbage, "&*()")
-TEST_DONT_PARSE(double_star, "**")
-TEST_DONT_PARSE(star_first, "*,foo")
-TEST_DONT_PARSE(star_second, "foo,*")
-TEST_DONT_PARSE(bang, "foo!o")
-
-#undef TEST_DONT_PARSE
-
-#define TEST_DO_PARSE(NAME, STR) \
- TEST_F(StorePathTest, good_ ## NAME) { \
- std::string_view str = \
- STORE_DIR HASH_PART "-" STR; \
- auto p = store->parseStorePath(str); \
- std::string name { p.name() }; \
- EXPECT_TRUE(std::regex_match(name, nameRegex)); \
- }
-
-// 0-9 a-z A-Z + - . _ ? =
-
-TEST_DO_PARSE(numbers, "02345")
-TEST_DO_PARSE(lower_case, "foo")
-TEST_DO_PARSE(upper_case, "FOO")
-TEST_DO_PARSE(plus, "foo+bar")
-TEST_DO_PARSE(dash, "foo-dev")
-TEST_DO_PARSE(underscore, "foo_bar")
-TEST_DO_PARSE(period, "foo.txt")
-TEST_DO_PARSE(question_mark, "foo?why")
-TEST_DO_PARSE(equals_sign, "foo=foo")
-
-#undef TEST_DO_PARSE
-
-// For rapidcheck
-void showValue(const StorePath & p, std::ostream & os) {
- os << p.to_string();
-}
-
-}
-
-namespace rc {
-using namespace nix;
-
-Gen<StorePathName> Arbitrary<StorePathName>::arbitrary()
-{
- auto len = *gen::inRange<size_t>(
- 1,
- StorePath::MaxPathLen - std::string_view { HASH_PART }.size());
-
- std::string pre;
- pre.reserve(len);
-
- for (size_t c = 0; c < len; ++c) {
- switch (auto i = *gen::inRange<uint8_t>(0, 10 + 2 * 26 + 6)) {
- case 0 ... 9:
- pre += '0' + i;
- case 10 ... 35:
- pre += 'A' + (i - 10);
- break;
- case 36 ... 61:
- pre += 'a' + (i - 36);
- break;
- case 62:
- pre += '+';
- break;
- case 63:
- pre += '-';
- break;
- case 64:
- pre += '.';
- break;
- case 65:
- pre += '_';
- break;
- case 66:
- pre += '?';
- break;
- case 67:
- pre += '=';
- break;
- default:
- assert(false);
- }
- }
-
- return gen::just(StorePathName {
- .name = std::move(pre),
- });
-}
-
-Gen<StorePath> Arbitrary<StorePath>::arbitrary()
-{
- return gen::just(StorePath {
- *gen::arbitrary<Hash>(),
- (*gen::arbitrary<StorePathName>()).name,
- });
-}
-
-} // namespace rc
-
-namespace nix {
-
-#ifndef COVERAGE
-
-RC_GTEST_FIXTURE_PROP(
- StorePathTest,
- prop_regex_accept,
- (const StorePath & p))
-{
- RC_ASSERT(std::regex_match(std::string { p.name() }, nameRegex));
-}
-
-RC_GTEST_FIXTURE_PROP(
- StorePathTest,
- prop_round_rip,
- (const StorePath & p))
-{
- RC_ASSERT(p == store->parseStorePath(store->printStorePath(p)));
-}
-
-#endif
-
-}
diff --git a/src/libstore/tests/path.hh b/src/libstore/tests/path.hh
deleted file mode 100644
index 21cb62310..000000000
--- a/src/libstore/tests/path.hh
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-///@file
-
-#include <rapidcheck/gen/Arbitrary.h>
-
-#include <path.hh>
-
-namespace nix {
-
-struct StorePathName {
- std::string name;
-};
-
-}
-
-namespace rc {
-using namespace nix;
-
-template<>
-struct Arbitrary<StorePathName> {
- static Gen<StorePathName> arbitrary();
-};
-
-template<>
-struct Arbitrary<StorePath> {
- static Gen<StorePath> arbitrary();
-};
-
-}
diff --git a/src/libstore/tests/references.cc b/src/libstore/tests/references.cc
deleted file mode 100644
index d91d1cedd..000000000
--- a/src/libstore/tests/references.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "references.hh"
-
-#include <gtest/gtest.h>
-
-namespace nix {
-
-TEST(references, scan)
-{
- std::string hash1 = "dc04vv14dak1c1r48qa0m23vr9jy8sm0";
- std::string hash2 = "zc842j0rz61mjsp3h3wp5ly71ak6qgdn";
-
- {
- RefScanSink scanner(StringSet{hash1});
- auto s = "foobar";
- scanner(s);
- ASSERT_EQ(scanner.getResult(), StringSet{});
- }
-
- {
- RefScanSink scanner(StringSet{hash1});
- auto s = "foobar" + hash1 + "xyzzy";
- scanner(s);
- ASSERT_EQ(scanner.getResult(), StringSet{hash1});
- }
-
- {
- RefScanSink scanner(StringSet{hash1, hash2});
- auto s = "foobar" + hash1 + "xyzzy" + hash2;
- scanner(((std::string_view) s).substr(0, 10));
- scanner(((std::string_view) s).substr(10, 5));
- scanner(((std::string_view) s).substr(15, 5));
- scanner(((std::string_view) s).substr(20));
- ASSERT_EQ(scanner.getResult(), StringSet({hash1, hash2}));
- }
-
- {
- RefScanSink scanner(StringSet{hash1, hash2});
- auto s = "foobar" + hash1 + "xyzzy" + hash2;
- for (auto & i : s)
- scanner(std::string(1, i));
- ASSERT_EQ(scanner.getResult(), StringSet({hash1, hash2}));
- }
-}
-
-}
diff --git a/src/libstore/tests/test-data/machines.bad_format b/src/libstore/tests/test-data/machines.bad_format
deleted file mode 100644
index 7255a1216..000000000
--- a/src/libstore/tests/test-data/machines.bad_format
+++ /dev/null
@@ -1 +0,0 @@
-nix@scratchy.labs.cs.uu.nl - - eight
diff --git a/src/libstore/tests/test-data/machines.valid b/src/libstore/tests/test-data/machines.valid
deleted file mode 100644
index 1a6c8017c..000000000
--- a/src/libstore/tests/test-data/machines.valid
+++ /dev/null
@@ -1,3 +0,0 @@
-nix@scratchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 1 kvm
-nix@itchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 2
-nix@poochie.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 1 2 kvm benchmark c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFDQVFDWWV5R1laNTNzd1VjMUZNSHBWL1BCcXlKaFR5S1JoRkpWWVRpRHlQN2h5c1JGa0w4VDlLOGdhL2Y2L3c3QjN2SjNHSFRIUFkybENiUEdZbGNLd2h6M2ZRbFNNOEViNi95b3ZLajdvM1FsMEx5Y0dzdGJvRmcwWkZKNldncUxsR0ltS0NobUlxOGZ3TW5ZTWUxbnRQeTBUZFZjSU1tOTV3YzF3SjBMd2c3cEVMRmtHazdkeTVvYnM4a3lGZ0pORDVRSmFwQWJjeWp4Z1QzdzdMcktNZ2xzeWhhd01JNVpkMGZsQTVudW5OZ3pid3plYVhLaUsyTW0vdGJXYTU1YTd4QmNYdHpIZGlPSWdSajJlRWxaMGh5bk10YjBmcklsdmxIcEtLaVFaZ3pQdCtIVXQ2bXpRMkRVME52MGYyYnNSU0krOGpJU2pQcmdlcVVHRldMUzVIUTg2N2xSMlpiaWtyclhZNTdqbVFEZk5DRHY1VFBHZU9UekFEd2pjMDc2aFZ3VFJCd3VTZFhtaWNxTS95b3lrWitkV1dnZ25MenE5QU1tdlNZcDhmZkZDcS9CSDBZNUFXWTFHay9vS3hMVTNaOWt3ZDd2UWNFQWFCQ2dxdnVZRGdTaHE1RlhndDM3OVZESWtEL05ZSTg2QXVvajVDRmVNTzlRM2pJSlRadlh6c1VldjVoSnA2djcxSVh5ODVtbTY5R20zcXdicVE1SjVQZDU1Um56SitpaW5BNjZxTEFSc0Y4amNsSnd5ekFXclBoYU9DRVY2bjVMeVhVazhzMW9EVVR4V1pWN25rVkFTbHJ0MllGcjN5dzdjRTRXQVhsemhHcDhocmdLMVVkMUlyeDVnZWRaSnBWcy9uNWVybmJFMUxmb2x5UHUvRUFIWlh6VGd4dHVDUFNobXc9PQo=