Skip to content

Commit

Permalink
tests/common: Add tests for -[am]{min,time}
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Jun 4, 2024
1 parent c6bb003 commit d6c2c94
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/common/amin.out
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/common/amin.sh
Original file line number Diff line number Diff line change
@@ -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 \)
6 changes: 6 additions & 0 deletions tests/common/atime.out
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/common/atime.sh
Original file line number Diff line number Diff line change
@@ -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 \)
6 changes: 6 additions & 0 deletions tests/common/mmin.out
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/common/mmin.sh
Original file line number Diff line number Diff line change
@@ -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 \)
6 changes: 6 additions & 0 deletions tests/common/mtime.out
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/common/mtime.sh
Original file line number Diff line number Diff line change
@@ -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 \)

0 comments on commit d6c2c94

Please sign in to comment.