Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the test work w/ non-default hooks directory #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test-integration:
@echo
@echo "==> Running integration tests (must be run as root)"
./hack/check_root.sh
bats $(BATS_OPTS) test/
env HOOKS_DIR=$(HOOK_DIR) bats $(BATS_OPTS) test/

.PHONY: test-unit
test-unit:
Expand Down
14 changes: 7 additions & 7 deletions test/00-simple.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ load helpers
tmpFile=$(mktemp)
echo "Temporary file: ${tmpFile}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand All @@ -49,7 +49,7 @@ load helpers
tmpFile=$(mktemp)
echo "Temporary file: ${tmpFile}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand All @@ -71,7 +71,7 @@ load helpers
tmpFile=$(mktemp)
echo "Temporary file: ${tmpFile}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand Down Expand Up @@ -100,7 +100,7 @@ load helpers
echo "Temporary file 1: ${tmpFile1}"
echo "Temporary file 2: ${tmpFile2}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile1} ${ALPINE} ls /
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile1} ${ALPINE} ls /
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
sleep 2
Expand All @@ -113,7 +113,7 @@ load helpers
echo "Podman output: ${lines[*]}"
[ "$status" -ne 0 ]

run podman run --net=host --annotation io.containers.trace-syscall="if:${tmpFile1};of:${tmpFile2}" ${ALPINE} ping -c3 $PINGABLE_HOST
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall="if:${tmpFile1};of:${tmpFile2}" ${ALPINE} ping -c3 $PINGABLE_HOST
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
sleep 2 # sleep two seconds to let the hook finish writing the file
Expand All @@ -138,7 +138,7 @@ load helpers
tmpFile=$(mktemp)
echo "Temporary file : ${tmpFile}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} mkdir /foo
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} mkdir /foo
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand All @@ -152,7 +152,7 @@ load helpers
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]

run podman run --net=host --annotation io.containers.trace-syscall="if:${BLOCK_MKDIR};of:${tmpFile}" ${ALPINE} mkdir /foo
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall="if:${BLOCK_MKDIR};of:${tmpFile}" ${ALPINE} mkdir /foo
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand Down
2 changes: 1 addition & 1 deletion test/01-syslog.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load helpers
tmpFile=$(mktemp)
echo "Temporary file: ${tmpFile}"

run podman run --net=host --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
run podman run --net=host $HOOKS_DIR_OPT --annotation io.containers.trace-syscall=of:${tmpFile} ${ALPINE} ls
echo "Podman output: ${lines[*]}"
[ "$status" -eq 0 ]
# sleep two seconds to let the hook finish writing the file
Expand Down
6 changes: 6 additions & 0 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ BLOCK_MKDIR=$(realpath $(dirname ${BASH_SOURCE[0]})/fixtures/block-mkdir.json)

# Hostname that should be ping'able from any environment in which we run tests
PINGABLE_HOST=github.com

# Without giving HOOKS_DIR, the option will not appear, which avoids writing
# default hooks directory in the command.
if [ ! -z $HOOKS_DIR ]; then
HOOKS_DIR_OPT="--hooks-dir=$HOOKS_DIR"
fi