From d6c2c94896c4e9f49e187f6c7b0f0d376a2d02ac Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 4 Jun 2024 13:54:16 -0400 Subject: tests/common: Add tests for -[am]{min,time} --- tests/common/amin.out | 6 ++++++ tests/common/amin.sh | 15 +++++++++++++++ tests/common/atime.out | 6 ++++++ tests/common/atime.sh | 15 +++++++++++++++ tests/common/mmin.out | 6 ++++++ tests/common/mmin.sh | 15 +++++++++++++++ tests/common/mtime.out | 6 ++++++ tests/common/mtime.sh | 15 +++++++++++++++ 8 files changed, 84 insertions(+) create mode 100644 tests/common/amin.out create mode 100644 tests/common/amin.sh create mode 100644 tests/common/atime.out create mode 100644 tests/common/atime.sh create mode 100644 tests/common/mmin.out create mode 100644 tests/common/mmin.sh create mode 100644 tests/common/mtime.out create mode 100644 tests/common/mtime.sh (limited to 'tests/common') diff --git a/tests/common/amin.out b/tests/common/amin.out new file mode 100644 index 0000000..af57325 --- /dev/null +++ b/tests/common/amin.out @@ -0,0 +1,6 @@ +-amin 1: ./one_minute_ago +-amin +1: ./one_hour_ago +-amin +1: ./two_minutes_ago +-amin -1: ./in_one_hour +-amin -1: ./in_one_minute +-amin -1: ./thirty_seconds_ago diff --git a/tests/common/amin.sh b/tests/common/amin.sh new file mode 100644 index 0000000..c4d53fb --- /dev/null +++ b/tests/common/amin.sh @@ -0,0 +1,15 @@ +cd "$TEST" + +now=$(epoch_time) + +"$XTOUCH" -at "@$((now - 60 * 60))" one_hour_ago +"$XTOUCH" -at "@$((now - 121))" two_minutes_ago +"$XTOUCH" -at "@$((now - 61))" one_minute_ago +"$XTOUCH" -at "@$((now - 30))" thirty_seconds_ago +"$XTOUCH" -at "@$((now + 60))" in_one_minute +"$XTOUCH" -at "@$((now + 60 * 60))" in_one_hour + +bfs_diff -mindepth 1 \ + \( -amin -1 -exec printf -- '-amin -1: %s\n' {} \; -o -true \) \ + \( -amin 1 -exec printf -- '-amin 1: %s\n' {} \; -o -true \) \ + \( -amin +1 -exec printf -- '-amin +1: %s\n' {} \; -o -true \) diff --git a/tests/common/atime.out b/tests/common/atime.out new file mode 100644 index 0000000..5ed206b --- /dev/null +++ b/tests/common/atime.out @@ -0,0 +1,6 @@ +-atime 1: ./yesterday +-atime +1: ./last_week +-atime +1: ./two_days_ago +-atime -1: ./now +-atime -1: ./one_hour_ago +-atime -1: ./tomorrow diff --git a/tests/common/atime.sh b/tests/common/atime.sh new file mode 100644 index 0000000..c2e4031 --- /dev/null +++ b/tests/common/atime.sh @@ -0,0 +1,15 @@ +cd "$TEST" + +now=$(epoch_time) + +"$XTOUCH" -at "@$((now - 60 * 60 * 24 * 7))" last_week +"$XTOUCH" -at "@$((now - 60 * 60 * 49))" two_days_ago +"$XTOUCH" -at "@$((now - 60 * 60 * 25))" yesterday +"$XTOUCH" -at "@$((now - 60 * 60))" one_hour_ago +"$XTOUCH" -at "@$((now))" now +"$XTOUCH" -at "@$((now + 60 * 60 * 24))" tomorrow + +bfs_diff -mindepth 1 \ + \( -atime -1 -exec printf -- '-atime -1: %s\n' {} \; -o -true \) \ + \( -atime 1 -exec printf -- '-atime 1: %s\n' {} \; -o -true \) \ + \( -atime +1 -exec printf -- '-atime +1: %s\n' {} \; -o -true \) diff --git a/tests/common/mmin.out b/tests/common/mmin.out new file mode 100644 index 0000000..4c79a16 --- /dev/null +++ b/tests/common/mmin.out @@ -0,0 +1,6 @@ +-mmin 1: ./one_minute_ago +-mmin +1: ./one_hour_ago +-mmin +1: ./two_minutes_ago +-mmin -1: ./in_one_hour +-mmin -1: ./in_one_minute +-mmin -1: ./thirty_seconds_ago diff --git a/tests/common/mmin.sh b/tests/common/mmin.sh new file mode 100644 index 0000000..38e3337 --- /dev/null +++ b/tests/common/mmin.sh @@ -0,0 +1,15 @@ +cd "$TEST" + +now=$(epoch_time) + +"$XTOUCH" -mt "@$((now - 60 * 60))" one_hour_ago +"$XTOUCH" -mt "@$((now - 121))" two_minutes_ago +"$XTOUCH" -mt "@$((now - 61))" one_minute_ago +"$XTOUCH" -mt "@$((now - 30))" thirty_seconds_ago +"$XTOUCH" -mt "@$((now + 60))" in_one_minute +"$XTOUCH" -mt "@$((now + 60 * 60))" in_one_hour + +bfs_diff -mindepth 1 \ + \( -mmin -1 -exec printf -- '-mmin -1: %s\n' {} \; -o -true \) \ + \( -mmin 1 -exec printf -- '-mmin 1: %s\n' {} \; -o -true \) \ + \( -mmin +1 -exec printf -- '-mmin +1: %s\n' {} \; -o -true \) diff --git a/tests/common/mtime.out b/tests/common/mtime.out new file mode 100644 index 0000000..91f0114 --- /dev/null +++ b/tests/common/mtime.out @@ -0,0 +1,6 @@ +-mtime 1: ./yesterday +-mtime +1: ./last_week +-mtime +1: ./two_days_ago +-mtime -1: ./now +-mtime -1: ./one_hour_ago +-mtime -1: ./tomorrow diff --git a/tests/common/mtime.sh b/tests/common/mtime.sh new file mode 100644 index 0000000..7ba127e --- /dev/null +++ b/tests/common/mtime.sh @@ -0,0 +1,15 @@ +cd "$TEST" + +now=$(epoch_time) + +"$XTOUCH" -mt "@$((now - 60 * 60 * 24 * 7))" last_week +"$XTOUCH" -mt "@$((now - 60 * 60 * 49))" two_days_ago +"$XTOUCH" -mt "@$((now - 60 * 60 * 25))" yesterday +"$XTOUCH" -mt "@$((now - 60 * 60))" one_hour_ago +"$XTOUCH" -mt "@$((now))" now +"$XTOUCH" -mt "@$((now + 60 * 60 * 24))" tomorrow + +bfs_diff -mindepth 1 \ + \( -mtime -1 -exec printf -- '-mtime -1: %s\n' {} \; -o -true \) \ + \( -mtime 1 -exec printf -- '-mtime 1: %s\n' {} \; -o -true \) \ + \( -mtime +1 -exec printf -- '-mtime +1: %s\n' {} \; -o -true \) -- cgit v1.2.3