From 76e123a01551e22791b98f09a070867915675b8d Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 28 Aug 2024 10:07:48 +0200 Subject: test just-mr: Add symlink cycle detection checks for repository roots --- test/end-to-end/just-mr/TARGETS | 1 + test/end-to-end/just-mr/install-roots-symlinks.sh | 54 ++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/test/end-to-end/just-mr/TARGETS b/test/end-to-end/just-mr/TARGETS index 872d154b..15959fb7 100644 --- a/test/end-to-end/just-mr/TARGETS +++ b/test/end-to-end/just-mr/TARGETS @@ -76,6 +76,7 @@ , "name": ["install-roots-symlinks"] , "test": ["install-roots-symlinks.sh"] , "deps": [["", "mr-tool-under-test"], ["", "tool-under-test"]] + , "keep": ["log/archive.txt", "log/file.txt"] } , "fetch-remote": { "type": ["end-to-end", "with remote"] diff --git a/test/end-to-end/just-mr/install-roots-symlinks.sh b/test/end-to-end/just-mr/install-roots-symlinks.sh index aa3ae836..81e691b4 100644 --- a/test/end-to-end/just-mr/install-roots-symlinks.sh +++ b/test/end-to-end/just-mr/install-roots-symlinks.sh @@ -40,13 +40,23 @@ readonly UPWARDS_LINK_PATH="bar/upwards" readonly UPWARDS_LINK_TARGET="../bar/baz" readonly INDIRECT_LINK_PATH="bar/indirect" readonly INDIRECT_LINK_TARGET="upwards/data.txt" +readonly CYCLE_LINK_1_PATH="bar/cycle_1" +readonly CYCLE_LINK_1_TARGET="cycle_2" +readonly CYCLE_LINK_2_PATH="bar/cycle_2" +readonly CYCLE_LINK_2_TARGET="cycle_1" mkdir -p "${DISTDIR}" +mkdir -p log +LOGDIR="$(realpath log)" +LOG_ARCHIVE_REPO="${LOGDIR}/archive.txt" +LOG_FILE_REPO="${LOGDIR}/file.txt" + ### # Set up sample archives ## +ROOT=$(pwd) mkdir -p "foo/${TEST_DIRS}" echo {} > foo/TARGETS echo -n "${TEST_DATA}" > "foo/${DATA_PATH}" @@ -80,7 +90,14 @@ tar cf "${DISTDIR}/foo-1.2.3_v2.tar" foo \ --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1970-01-01' 2>&1 foocontent_v2=$(git hash-object "${DISTDIR}/foo-1.2.3_v2.tar") echo "Foo archive v2 has content ${foocontent_v2}" -rm -rf foo + +# lastly, check that symlink cycles will fail to resolve +ln -s "${CYCLE_LINK_1_TARGET}" "foo/${CYCLE_LINK_1_PATH}" +ln -s "${CYCLE_LINK_2_TARGET}" "foo/${CYCLE_LINK_2_PATH}" +tar cf "${DISTDIR}/foo-1.2.3_cycle.tar" foo \ + --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1970-01-01' 2>&1 +foocontent_cycle=$(git hash-object "${DISTDIR}/foo-1.2.3_cycle.tar") +echo "Foo archive with cycle has content ${foocontent_cycle}" ### # Setup sample repository config @@ -134,6 +151,22 @@ cat > repos.json <&2 && exit 1 +echo "failed as expected" +# check for cycle in log file +grep "${CYCLE_LINK_2_PATH}" "${LOG_ARCHIVE_REPO}" +grep "${CYCLE_LINK_1_PATH}" "${LOG_ARCHIVE_REPO}" + +"${JUST_MR}" --norc --local-build-root "${LBR}" --distdir "${DISTDIR}" \ + -f "${LOG_FILE_REPO}" setup foo_cycle_file \ + && echo "this should fail" >&2 && exit 1 +echo "failed as expected" +# check for cycle in log file +grep "${CYCLE_LINK_1_PATH}" "${LOG_FILE_REPO}" +grep "${CYCLE_LINK_2_PATH}" "${LOG_FILE_REPO}" + echo OK -- cgit v1.2.3