Skip to content

Commit

Permalink
Add btest for new permission handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ekoyle committed Jul 24, 2024
1 parent 7cb08f7 commit 9bdacbf
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
38 changes: 38 additions & 0 deletions testing/baselines/tests.bundle-permissions/bundle.out
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions testing/baselines/tests.bundle-permissions/unbundle.out
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions testing/tests/bundle-permissions
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9bdacbf

Please sign in to comment.