From 9bdacbf711bbc8f55d406616e560f13315731734 Mon Sep 17 00:00:00 2001 From: Eldon Koyle Date: Wed, 24 Jul 2024 14:05:02 -0600 Subject: [PATCH] Add btest for new permission handling Add a btest for the new permission handling. This is using output of ls and tar. I'm not positive this will work with variants other than GNU. If this doesn't work, I'm not sure how to accomplish this portably short of writing scripts to print out the desired information. --- .../tests.bundle-permissions/bundle.out | 38 +++++++++++++++++++ .../tests.bundle-permissions/unbundle.out | 20 ++++++++++ testing/tests/bundle-permissions | 33 ++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 testing/baselines/tests.bundle-permissions/bundle.out create mode 100644 testing/baselines/tests.bundle-permissions/unbundle.out create mode 100644 testing/tests/bundle-permissions diff --git a/testing/baselines/tests.bundle-permissions/bundle.out b/testing/baselines/tests.bundle-permissions/bundle.out new file mode 100644 index 0000000..6b5a4b9 --- /dev/null +++ b/testing/baselines/tests.bundle-permissions/bundle.out @@ -0,0 +1,38 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +drwxr-xr-x root/root ./ +drwxr-xr-x root/root ./baz/ +-rw-r--r-- root/root ./baz/__load__.zeek +-rw-r--r-- root/root ./baz/zkg.meta +-rw-r--r-- root/root ./manifest.txt +drwxr-xr-x root/root ./rot13/ +-rw-r--r-- root/root ./rot13/CHANGES +-rw-r--r-- root/root ./rot13/CMakeLists.txt +-rw-r--r-- root/root ./rot13/COPYING.edit-me +-rw-r--r-- root/root ./rot13/Makefile +-rw-r--r-- root/root ./rot13/README +-rw-r--r-- root/root ./rot13/VERSION +-rwxr-xr-x root/root ./rot13/configure +-rw-r--r-- root/root ./rot13/configure.plugin +drwxr-xr-x root/root ./rot13/scripts/ +drwxr-xr-x root/root ./rot13/scripts/Demo/ +drwxr-xr-x root/root ./rot13/scripts/Demo/Rot13/ +-rw-r--r-- root/root ./rot13/scripts/Demo/Rot13/__load__.zeek +-rw-r--r-- root/root ./rot13/scripts/__load__.zeek +-rw-r--r-- root/root ./rot13/scripts/__preload__.zeek +-rw-r--r-- root/root ./rot13/scripts/init.zeek +-rw-r--r-- root/root ./rot13/scripts/types.zeek +drwxr-xr-x root/root ./rot13/src/ +-rw-r--r-- root/root ./rot13/src/Plugin.cc +-rw-r--r-- root/root ./rot13/src/Plugin.h +-rw-r--r-- root/root ./rot13/src/rot13.bif +drwxr-xr-x root/root ./rot13/testing/ +drwxr-xr-x root/root ./rot13/testing/Baseline/ +drwxr-xr-x root/root ./rot13/testing/Baseline/tests.main/ +-rw-r--r-- root/root ./rot13/testing/Baseline/tests.main/output +drwxr-xr-x root/root ./rot13/testing/Baseline/tests.rot13/ +-rw-r--r-- root/root ./rot13/testing/Baseline/tests.rot13/output +-rw-r--r-- root/root ./rot13/testing/btest.cfg +drwxr-xr-x root/root ./rot13/testing/tests/ +-rw-r--r-- root/root ./rot13/testing/tests/main +-rw-r--r-- root/root ./rot13/testing/tests/rot13 +-rw-r--r-- root/root ./rot13/zkg.meta diff --git a/testing/baselines/tests.bundle-permissions/unbundle.out b/testing/baselines/tests.bundle-permissions/unbundle.out new file mode 100644 index 0000000..a25a2d8 --- /dev/null +++ b/testing/baselines/tests.bundle-permissions/unbundle.out @@ -0,0 +1,20 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +state/clones/package/rot13: +total 52 +drwxr-x--- 5 esk esk 4096 omitted build +-rw-r--r-- 1 esk esk 0 omitted CHANGES +-rw-r--r-- 1 esk esk 241 omitted CMakeLists.txt +-rwxr-xr-x 1 esk esk 5329 omitted configure +-rw-r--r-- 1 esk esk 380 omitted configure.plugin +-rw-r--r-- 1 esk esk 1707 omitted COPYING.edit-me +-rw-r--r-- 1 esk esk 704 omitted Makefile +-rw-r--r-- 1 esk esk 84 omitted README +drwxr-xr-x 3 esk esk 4096 omitted scripts +drwxr-xr-x 2 esk esk 4096 omitted src +drwxr-xr-x 4 esk esk 4096 omitted testing +-rw-r--r-- 1 esk esk 4 omitted VERSION +-rw-r--r-- 1 esk esk 122 omitted zkg.meta + +state/script_dir/packages/rot13: +total 4 +-rw-r--r-- 1 esk esk 186 omitted __load__.zeek diff --git a/testing/tests/bundle-permissions b/testing/tests/bundle-permissions new file mode 100644 index 0000000..dd1db47 --- /dev/null +++ b/testing/tests/bundle-permissions @@ -0,0 +1,33 @@ +# @TEST-EXEC: bash %INPUT + +# @TEST-EXEC: zkg purge +# @TEST-EXEC: umask 0027 && zkg bundle test.bundle --manifest manifest.txt + +# FIXME: this may be specific to gnu tar output format +# @TEST-EXEC: tar tvf test.bundle | grep -v git | tr -s ' ' | cut -f 1,2,6 -d ' ' > bundle.out +# @TEST-EXEC: btest-diff bundle.out +# @TEST-EXEC: umask 0027 && zkg --config=my_zkg.config unbundle --force --replace test.bundle + +# FIXME: this may be a gnu-specific option, and output may differ based on ls implementation +# @TEST-EXEC: ls -l --time-style=+omitted state/script_dir/packages/rot13 state/clones/package/rot13 | grep -v 'git\|dist' > unbundle.out +# @TEST-EXEC: btest-diff unbundle.out + +# make sure the on-disk permissions will differ +chmod -R g-w,o-rwx packages/rot13 + +echo "$(pwd)/packages/rot13" >> sources/one/bob/zkg.index +cd sources/one +git commit -am 'add rot13 package' +cd ../.. + +echo "[bundle]" > manifest.txt +default_branch_name=$( cd packages/baz && git rev-parse --abbrev-ref HEAD ) +echo "baz = ${default_branch_name}" >> manifest.txt +default_branch_name=$( cd packages/rot13 && git rev-parse --abbrev-ref HEAD ) +echo "rot13 = ${default_branch_name}" >> manifest.txt + +cat << EOF > my_zkg.config +[paths] +state_dir = $(pwd)/state + +EOF