diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-09-09 15:09:45 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-09-16 10:01:34 +0200 |
commit | a1b45eef0a50da931a2c46fe842631d27ca4be56 (patch) | |
tree | 7240cac7a16435669125c6448188ddde11535d66 /test | |
parent | 0a9ff3a87edcf6dd8fe0a1f68083f25c90f513b6 (diff) | |
download | justbuild-a1b45eef0a50da931a2c46fe842631d27ca4be56.tar.gz |
test stage-links: Check also actions with non-contained symlinks
Diffstat (limited to 'test')
-rw-r--r-- | test/end-to-end/symlinks/stage-links.sh | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/test/end-to-end/symlinks/stage-links.sh b/test/end-to-end/symlinks/stage-links.sh index 25c9d15e..b8173105 100644 --- a/test/end-to-end/symlinks/stage-links.sh +++ b/test/end-to-end/symlinks/stage-links.sh @@ -16,15 +16,17 @@ set -eu readonly JUST="${PWD}/bin/tool-under-test" +readonly OUT="${TMPDIR}/out" +mkdir -p "${OUT}" touch ROOT cat > TARGETS <<EOF -{ "input": +{ "input-non-upwards": { "type": "generic" , "out_dirs": ["."] , "cmds": ["touch foo", "ln -s foo bar", "ln -s iNeXIstENt baz"] } -, "stage-links": +, "stage-non-upwards-links": { "type": "generic" , "out_dirs": ["."] , "cmds": @@ -32,7 +34,18 @@ cat > TARGETS <<EOF , "test -L baz || (printf \"\n\nwrong staging: baz must be a symlink\n\n\" && exit 1)" , "! test -e iNeXIstENt" ] - , "deps": ["input"] + , "deps": ["input-non-upwards"] + } +, "input-non-contained": + { "type": "generic" + , "out_dirs": ["."] + , "cmds": ["ln -s ../iNeXIstENt baz"] + } +, "stage-non-contained-links": + { "type": "generic" + , "out_dirs": ["."] + , "cmds": ["test -L baz || (printf \"\n\nwrong staging: baz must be a symlink\n\n\" && exit 1)"] + , "deps": ["input-non-contained"] } } EOF @@ -49,8 +62,59 @@ if [ "${REMOTE_EXECUTION_PROPERTIES:-}" != "" ]; then REMOTE_EXECUTION_ARGS="${REMOTE_EXECUTION_ARGS} ${REMOTE_EXECUTION_PROPS}" fi -echo "test staging locally" -${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} stage-links +FAILED="" + +# Check that actions with non-upwards symlinks succeed +echo +echo "test input non-upwards locally" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} input-non-upwards 2>&1 +${JUST} install -L '["env", "PATH='"${PATH}"'"]' ${ARGS} input-non-upwards \ + -o "${OUT}" 2>&1 && ls -alR "${OUT}" && rm -rf "${OUT}/*" || FAILED=YES + +echo +echo "test input non-upwards remotely" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} input-non-upwards 2>&1 +${JUST} install -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} input-non-upwards \ + -o "${OUT}" 2>&1 && ls -alR "${OUT}" && rm -rf "${OUT}/*" || FAILED=YES + +echo +echo "test staging non-upwards locally" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} stage-non-upwards-links 2>&1 || FAILED=YES + +echo +echo "test staging non-upwards remotely" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} stage-non-upwards-links 2>&1 || FAILED=YES + +# Check that actions with non-contained upwards symlinks fail +echo +echo "test input non-contained locally" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} input-non-contained 2>&1 \ + && echo "this should have failed" && FAILED=YES +${JUST} install -L '["env", "PATH='"${PATH}"'"]' ${ARGS} input-non-contained -o "${OUT}" 2>&1 \ + && echo "this should have failed" && FAILED=YES \ + && ls -alR "${OUT}" && rm -rf "${OUT}/*" || echo "failed as expected" + +echo +echo "test input non-contained remotely" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} input-non-contained 2>&1 \ + && echo "this should have failed" && FAILED=YES || echo "failed as expected" +${JUST} install -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} input-non-contained -o "${OUT}" 2>&1 \ + && echo "this should have failed" && FAILED=YES \ + && ls -alR "${OUT}" && rm -rf "${OUT}/*" || echo "failed as expected" + +echo +echo "test staging non-contained locally" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} stage-non-contained-links 2>&1 \ + && echo "this should have failed" && FAILED=YES || echo "failed as expected" + +echo +echo "test staging non-contained remotely" +${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} stage-non-contained-links 2>&1 \ + && echo "this should have failed" && FAILED=YES || echo "failed as expected" + +if [ ! -z "${FAILED}" ]; then + exit 1 +fi -echo "test staging remotely" -${JUST} build -L '["env", "PATH='"${PATH}"'"]' ${ARGS} ${REMOTE_EXECUTION_ARGS} stage-links +echo +echo OK |