From 353d5c931c4f4afc6094a96c139fb947cfb47bd6 Mon Sep 17 00:00:00 2001
From: zhoushuiqing <zhoushuiqing321@outlook.com>
Date: Thu, 23 Jun 2022 15:17:23 +0800
Subject: [PATCH] tests: add tests about find -newer.. and xargs -d with escapechars
 
 Add two tests, one test is about find -anewer, -cnewer
 and newerXY, the other is about xargs -d delim  , the delim is a escape
 character, like \a,\n.

---
 tests/find/newer-args.sh         | 36 ++++++++++++++++++++++
 tests/local.mk                   |  2 ++
 tests/xargs/delim-escapechars.sh | 52 ++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 tests/find/newer-args.sh
 create mode 100644 tests/xargs/delim-escapechars.sh

diff --git a/tests/find/newer-args.sh b/tests/find/newer-args.sh
new file mode 100644
index 00000000..9d6080ac
--- /dev/null
+++ b/tests/find/newer-args.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Test -anewer -cnewer -newerXY with different timestamp files.
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; fu_path_prepend_
+print_ver_ find
+
+for d in 1 2 3; do
+    touch filetest$d \
+        && sleep 1s \
+        || skip_ "creating files with different timestamp failed"
+done
+
+
+for x in -anewer -cnewer -newerac -newerca -newerma -newermc; do
+    echo "./filetest3" > exp || framework_failure_
+    rm -f out || framework_failure
+    find . $x filetest2 -name "filetest*" > out || fail=1
+    compare exp out || fail=1
+done
+
+Exit $fail
\ No newline at end of file
diff --git a/tests/local.mk b/tests/local.mk
index 4e8efd41..783e3f60 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -120,8 +120,10 @@ all_tests = \
   tests/find/refuse-noop.sh \
   tests/find/debug-missing-arg.sh \
   tests/find/used.sh \
+  tests/find/newer-args.sh \
   tests/xargs/conflicting_opts.sh \
   tests/xargs/verbose-quote.sh \
+  tests/xargs/delim-escapechars.sh \
   $(all_root_tests)
 
 $(TEST_LOGS): $(PROGRAMS)
diff --git a/tests/xargs/delim-escapechars.sh b/tests/xargs/delim-escapechars.sh
new file mode 100644
index 00000000..2d599c00
--- /dev/null
+++ b/tests/xargs/delim-escapechars.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Test xargs -d delim with escapechars. like \a , \b, \f , \n , \r, \t ,\v , \\ 
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; fu_path_prepend_
+print_ver_ xargs
+
+touch file1 file2 inputfile || skip_ "creating files failed"
+
+printf "file1\nfile2\n" > exp || framework_failure
+
+printf "file1\afile2" > inputfile || framework_failure
+xargs -a inputfile -d \\a ls > out || fail 1
+
+printf "file1\bfile2" > inputfile || framework_failure
+xargs -a inputfile -d \\b ls > out || fail 1
+
+printf "file1\ffile2" > inputfile || framework_failure
+xargs -a inputfile -d \\f ls > out || fail 1
+
+printf "file1\nfile2" > inputfile || framework_failure
+xargs -a inputfile -d \\n ls > out || fail 1
+
+printf "file1\rfile2" > inputfile || framework_failure
+xargs -a inputfile -d \\r ls > out || fail 1
+
+printf "file1\tfile2" > inputfile || framework_failure
+xargs -a inputfile -d \\t ls > out || fail 1
+
+printf "file1\vfile2" > inputfile || framework_failure
+xargs -a inputfile -d \\v ls > out || fail 1
+
+printf "file1\\\file2" > inputfile || framework_failure
+xargs -a inputfile -d \\ ls > out || fail 1
+
+compare exp out || fail=1
+
+Exit $fail
\ No newline at end of file
-- 
2.33.0

