#!/bin/bash set -e export TZ='UTC' script_dir=$(dirname "$(realpath "$0")") base_dir=$(dirname "$script_dir") test_dir="/tmp/chkbit" function chkbit() { "$base_dir/chkbit" "$@"; } if [[ ! -d $test_dir ]]; then echo "must run run_test_prep first" exit 1 fi # setup $script_dir/build cd $test_dir chkbit -u root # todo: validate (300 files, 1 symlink dir followed, 1 symlink file ignored) 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 .