Skip to content

Commit

Permalink
tests: Add check for -C/--command
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Jan 19, 2025
1 parent f6819d1 commit 76563b9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions tests/fatrace-comm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -euC

mkdir -m 777 tmp
trap "rm -rf tmp" EXIT INT QUIT PIPE

LOG="$AUTOPKGTEST_TMP/fatrace.log"
echo "starting fatrace..."
fatrace --current-mount --command touch -s 2 -o $LOG &
sleep 1

echo "create files with different programs"
touch tmp/includeme
dd if=/dev/zero of=tmp/notme bs=1 count=1

echo "waiting for fatrace..."
wait

echo "checking log..."
RC=0
check_log() {
if ! grep -q "$1" $LOG; then
echo "$1 not found in log" >&2
((RC=RC+1))
fi
}

check_log "^touch([0-9]*).*includeme$"

if grep -Eq "notme|^dd" $LOG; then
echo "notme found in log" >&2
((RC=RC+1))
fi

if [ $RC -ne 0 ]; then
echo "$RC checks failed -- log:" >&2
echo "===================" >&2
cat $LOG >&2
echo "===================" >&2
fi

exit $RC
2 changes: 1 addition & 1 deletion tests/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu
MYDIR=$(dirname $(readlink -f "$0"))
export PATH=$(pwd):$PATH

for t in fatrace fatrace-currentmount fatrace-btrfs fatrace-user; do
for t in fatrace fatrace-currentmount fatrace-btrfs fatrace-user fatrace-comm; do
export AUTOPKGTEST_TMP=$(mktemp -d)
echo "===== $t ===="
"$MYDIR"/$t
Expand Down

0 comments on commit 76563b9

Please sign in to comment.