diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-14 12:25:39 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-14 18:17:07 +0100 |
commit | 5cc68806ab31fa3fe89da58407bf67901e628b97 (patch) | |
tree | b176cb8ff644df952ac1cdf0f548271b25817ada | |
parent | a26432b923c1595c0489897ca23b1c8f0eeca6bc (diff) | |
download | justbuild-5cc68806ab31fa3fe89da58407bf67901e628b97.tar.gz |
end-to-end: Extend existing add-to-cas test...
...to check that --resolve-special option correctly stores entries.
-rwxr-xr-x | test/end-to-end/remote-execution/add-to-cas.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/end-to-end/remote-execution/add-to-cas.sh b/test/end-to-end/remote-execution/add-to-cas.sh index 51cd14b1..14c63c52 100755 --- a/test/end-to-end/remote-execution/add-to-cas.sh +++ b/test/end-to-end/remote-execution/add-to-cas.sh @@ -22,6 +22,11 @@ readonly JUST_MR="${PWD}/bin/mr-tool-under-test" readonly CLIENT_A="${TEST_TMPDIR}/local-build-root-A" readonly CLIENT_B="${TEST_TMPDIR}/local-build-root-B" readonly CLIENT_SYMLINK_CHECK="${TEST_TMPDIR}/local-build-root-symlink-check" +readonly RESOLVE_SPECIAL_CHECK_A="${TEST_TMPDIR}/local-build-root-resolve-special-A" +readonly RESOLVE_SPECIAL_CHECK_B="${TEST_TMPDIR}/local-build-root-resolve-special-B" +readonly RESOLVE_SPECIAL_CHECK_C="${TEST_TMPDIR}/local-build-root-resolve-special-C" +readonly RESOLVE_SPECIAL_CHECK_D="${TEST_TMPDIR}/local-build-root-resolve-special-D" +readonly RESOLVE_SPECIAL_CHECK_E="${TEST_TMPDIR}/local-build-root-resolve-special-E" readonly TOOLS_DIR="${TEST_TMPDIR}/tools" readonly OUT_A="${TEST_TMPDIR}/out/client-A" readonly OUT_B="${TEST_TMPDIR}/out/client-B" @@ -141,4 +146,63 @@ echo grep World "${OUT_B}/out.txt" echo +# Extension: Using option --resolve-special +NUM=5 +TREE_ROOT="${ROOT}/tree" +mkdir -p "${TREE_ROOT}" +( + # create dirs and links structure + DIR="${TREE_ROOT}" + for i in `seq 1 $NUM`; do + TO="." + for j in `seq $i $NUM`; do + TO="${TO}/$j" + # multiple links pointing to same place + for k in `seq 1 $NUM`; do + x=$(($j + ($k - 1) * $NUM)) + ln -s "${TO}" "${DIR}/link$x" + done + done + DIR="${DIR}/$i" + mkdir "${DIR}" + done + # create 1 single file + echo content > "${DIR}/data" +) + +# whether symlinks ignored, resolved inside tree or resolved completely: +# expect 6 trees and 2 blobs (1 for data, 1 for exec properties description) +"${JUST}" add-to-cas --local-build-root "${RESOLVE_SPECIAL_CHECK_A}" --resolve-special=ignore "${TREE_ROOT}" 2>&1 +[ "$(find "${RESOLVE_SPECIAL_CHECK_A}/protocol-dependent/generation-0" -type f | grep cast | wc -l)" = $(($NUM + 1)) ] +[ "$(find "${RESOLVE_SPECIAL_CHECK_A}/protocol-dependent/generation-0" -type f | grep casf | wc -l)" = 2 ] + +"${JUST}" add-to-cas --local-build-root "${RESOLVE_SPECIAL_CHECK_B}" --resolve-special=tree-all "${TREE_ROOT}" 2>&1 +[ "$(find "${RESOLVE_SPECIAL_CHECK_B}/protocol-dependent/generation-0" -type f | grep cast | wc -l)" = $(($NUM + 1)) ] +[ "$(find "${RESOLVE_SPECIAL_CHECK_B}/protocol-dependent/generation-0" -type f | grep casf | wc -l)" = 2 ] + +"${JUST}" add-to-cas --local-build-root "${RESOLVE_SPECIAL_CHECK_C}" --resolve-special=all "${TREE_ROOT}" 2>&1 +[ "$(find "${RESOLVE_SPECIAL_CHECK_C}/protocol-dependent/generation-0" -type f | grep cast | wc -l)" = $(($NUM + 1)) ] +[ "$(find "${RESOLVE_SPECIAL_CHECK_C}/protocol-dependent/generation-0" -type f | grep casf | wc -l)" = 2 ] + +( + # create upward symlinks + DIR="${TREE_ROOT}" + for i in `seq 1 $NUM`; do + ln -s "../link" "${DIR}/link" + DIR="${DIR}/$i" + done + # link the outmost entry to the data + ln -s "${DIR}/data" "${ROOT}/link" +) + +# upward symlinks cannot be resolved inside tree... +"${JUST}" add-to-cas --local-build-root "${RESOLVE_SPECIAL_CHECK_D}" \ + --resolve-special=tree-all "${TREE_ROOT}" 2>&1 && echo expected to fail || : +echo failed as expected +echo +# ...but they can get resolved outside of it; expect same number of CAS entries +"${JUST}" add-to-cas --local-build-root "${RESOLVE_SPECIAL_CHECK_E}" --resolve-special=all "${TREE_ROOT}" 2>&1 +[ "$(find "${RESOLVE_SPECIAL_CHECK_E}/protocol-dependent/generation-0" -type f | grep cast | wc -l)" = $(($NUM + 1)) ] +[ "$(find "${RESOLVE_SPECIAL_CHECK_E}/protocol-dependent/generation-0" -type f | grep casf | wc -l)" = 2 ] + echo OK |