2021-03-24 13:44:20 +00:00
|
|
|
if ! canUseSandbox; then exit 99; fi
|
|
|
|
if ! [[ $busybox =~ busybox ]]; then exit 99; fi
|
2017-05-02 13:35:35 +00:00
|
|
|
|
2020-06-25 16:26:34 +00:00
|
|
|
unset NIX_STORE_DIR
|
|
|
|
unset NIX_STATE_DIR
|
|
|
|
|
2020-08-12 16:32:36 +00:00
|
|
|
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
|
|
|
|
2021-06-11 06:37:59 +00:00
|
|
|
EXTRA_SYSTEM_FEATURES=()
|
|
|
|
if [[ -n "$CONTENT_ADDRESSED" ]]; then
|
|
|
|
EXTRA_SYSTEM_FEATURES=("ca-derivations")
|
|
|
|
fi
|
|
|
|
|
2020-08-12 16:32:36 +00:00
|
|
|
builders=(
|
|
|
|
# system-features will automatically be added to the outer URL, but not inner
|
|
|
|
# remote-store URL.
|
2021-06-11 06:37:59 +00:00
|
|
|
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=$(join_by "%20" foo ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," foo ${EXTRA_SYSTEM_FEATURES[@]})"
|
|
|
|
"$TEST_ROOT/machine2 - - 1 1 $(join_by "," bar ${EXTRA_SYSTEM_FEATURES[@]})"
|
|
|
|
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=$(join_by "%20" baz ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," baz ${EXTRA_SYSTEM_FEATURES[@]})"
|
2020-08-12 16:32:36 +00:00
|
|
|
)
|
|
|
|
|
2020-12-09 09:37:39 +00:00
|
|
|
chmod -R +w $TEST_ROOT/machine* || true
|
|
|
|
rm -rf $TEST_ROOT/machine* || true
|
|
|
|
|
2020-06-25 16:26:34 +00:00
|
|
|
# Note: ssh://localhost bypasses ssh, directly invoking nix-store as a
|
|
|
|
# child process. This allows us to test LegacySSHStore::buildDerivation().
|
2020-08-12 16:32:36 +00:00
|
|
|
# ssh-ng://... likewise allows us to test RemoteStore::buildDerivation().
|
2020-08-16 17:38:12 +00:00
|
|
|
nix build -L -v -f $file -o $TEST_ROOT/result --max-jobs 0 \
|
2020-06-25 16:26:34 +00:00
|
|
|
--arg busybox $busybox \
|
|
|
|
--store $TEST_ROOT/machine0 \
|
2020-08-12 16:32:36 +00:00
|
|
|
--builders "$(join_by '; ' "${builders[@]}")"
|
2017-05-02 13:35:35 +00:00
|
|
|
|
2020-06-25 16:26:34 +00:00
|
|
|
outPath=$(readlink -f $TEST_ROOT/result)
|
2017-05-02 13:35:35 +00:00
|
|
|
|
2020-08-12 13:24:39 +00:00
|
|
|
grep 'FOO BAR BAZ' $TEST_ROOT/machine0/$outPath
|
|
|
|
|
|
|
|
set -o pipefail
|
2020-08-12 16:32:36 +00:00
|
|
|
|
|
|
|
# Ensure that input1 was built on store1 due to the required feature.
|
2020-08-12 13:24:39 +00:00
|
|
|
nix path-info --store $TEST_ROOT/machine1 --all \
|
|
|
|
| grep builder-build-remote-input-1.sh \
|
|
|
|
| grep -v builder-build-remote-input-2.sh \
|
|
|
|
| grep -v builder-build-remote-input-3.sh
|
2017-05-02 13:35:35 +00:00
|
|
|
|
2020-08-12 16:32:36 +00:00
|
|
|
# Ensure that input2 was built on store2 due to the required feature.
|
2020-08-12 13:24:39 +00:00
|
|
|
nix path-info --store $TEST_ROOT/machine2 --all \
|
|
|
|
| grep -v builder-build-remote-input-1.sh \
|
|
|
|
| grep builder-build-remote-input-2.sh \
|
|
|
|
| grep -v builder-build-remote-input-3.sh
|
|
|
|
|
|
|
|
# Ensure that input3 was built on store3 due to the required feature.
|
|
|
|
nix path-info --store $TEST_ROOT/machine3 --all \
|
|
|
|
| grep -v builder-build-remote-input-1.sh \
|
|
|
|
| grep -v builder-build-remote-input-2.sh \
|
|
|
|
| grep builder-build-remote-input-3.sh
|