chkbit/scripts/run_tests

47 lines
975 B
Plaintext
Raw Normal View History

2024-08-15 23:30:29 +02:00
#!/bin/bash
set -e
export TZ='UTC'
script_dir=$(dirname "$(realpath "$0")")
base_dir=$(dirname "$script_dir")
2024-08-18 21:36:22 +02:00
test_dir="/tmp/chkbit"
function chkbit() { "$base_dir/chkbit" "$@"; }
2024-08-15 23:30:29 +02:00
2024-08-18 21:36:22 +02:00
if [[ ! -d $test_dir ]]; then
2024-08-15 23:30:29 +02:00
echo "must run run_test_prep first"
exit 1
fi
# setup
$script_dir/build
2024-08-18 21:36:22 +02:00
cd $test_dir
2024-08-15 23:30:29 +02:00
2024-08-18 21:36:22 +02:00
chkbit -u root
2024-08-18 16:05:33 +02:00
# todo: validate (300 files, 1 symlink dir followed, 1 symlink file ignored)
2024-08-16 23:10:58 +02:00
2024-08-18 21:36:22 +02:00
echo "- test damage"
rm -rf $test_dir/test_dmg
mkdir $test_dir/test_dmg
cd $test_dir/test_dmg
echo "-- create test and set the modified time"
echo foo1 > test; touch -t 201501010001 test
# says new:
chkbit -u .
echo "-- update test & old modified (expect 'old')"
echo foo2 > test; touch -t 201501010000 test
chkbit -u .
echo "-- update test & new modified (expect 'upd')"
echo foo3 > test; touch -t 201501010002 test
chkbit -u .
echo "-- Now update test with the same modified to simulate damage (expect DMG)"
echo foo4 > test; touch -t 201501010002 test
chkbit -u .