Page MenuHomeFreeBSD

D43381.diff
No OneTemporary

D43381.diff

diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,14 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20240112: replaced NetBSD tests for uniq with our own
+OLD_FILES+=usr/tests/usr.bin/uniq/d_basic.in
+OLD_FILES+=usr/tests/usr.bin/uniq/d_basic.out
+OLD_FILES+=usr/tests/usr.bin/uniq/d_counts.out
+OLD_FILES+=usr/tests/usr.bin/uniq/d_input.in
+OLD_FILES+=usr/tests/usr.bin/uniq/d_show_duplicates.out
+OLD_FILES+=usr/tests/usr.bin/uniq/d_show_uniques.out
+
# 20231208: new clang import which bumps version from 16 to 17
OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_builtin_vars.h
OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_cmath.h
diff --git a/usr.bin/uniq/tests/Makefile b/usr.bin/uniq/tests/Makefile
--- a/usr.bin/uniq/tests/Makefile
+++ b/usr.bin/uniq/tests/Makefile
@@ -1,15 +1,4 @@
-
PACKAGE= tests
-
-NETBSD_ATF_TESTS_SH= uniq_test
-
-${PACKAGE}FILES+= d_basic.in
-${PACKAGE}FILES+= d_basic.out
-${PACKAGE}FILES+= d_counts.out
-${PACKAGE}FILES+= d_input.in
-${PACKAGE}FILES+= d_show_duplicates.out
-${PACKAGE}FILES+= d_show_uniques.out
-
-.include <netbsd-tests.test.mk>
+ATF_TESTS_SH= uniq_test
.include <bsd.test.mk>
diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh
new file mode 100755
--- /dev/null
+++ b/usr.bin/uniq/tests/uniq_test.sh
@@ -0,0 +1,149 @@
+#
+# Copyright (c) 2024 Klara, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+atf_check_uniq() {
+ atf_check uniq "$@" input actual
+ atf_check diff -u actual expected
+ atf_check uniq "$@" - actual <input
+ atf_check diff -u actual expected
+ atf_check -o file:expected uniq "$@" input
+ atf_check -o file:expected uniq "$@" <input
+ atf_check -o file:expected uniq "$@" - <input
+}
+
+atf_test_case basic
+basic_head() {
+ atf_set descr "basic test without options"
+}
+basic_body() {
+ printf "a\na\nb\nb\na\na\n" >input
+ printf "a\nb\na\n" >expected
+ atf_check_uniq
+}
+
+atf_test_case count
+count_head() {
+ atf_set descr "basic test showing counts"
+}
+count_body() {
+ printf "a\na\nb\nb\nb\na\na\na\na\n" >input
+ printf " 2 a\n 3 b\n 4 a\n" >expected
+ atf_check_uniq -c
+ atf_check_uniq --count
+}
+
+atf_test_case repeated
+repeated_head() {
+ atf_set descr "print repeated lines only"
+}
+repeated_body() {
+ printf "a\na\nb\na\na\n" >input
+ printf "a\na\n" >expected
+ atf_check_uniq -d
+ atf_check_uniq --repeated
+}
+
+atf_test_case count_repeated
+count_repeated_head() {
+ atf_set descr "count and print repeated lines only"
+}
+count_repeated_body() {
+ printf "a\na\nb\nb\na\n" >input
+ printf " 2 a\n 2 b\n" >expected
+ atf_check_uniq --count --repeated
+}
+
+atf_test_case all_repeated
+all_repeated_head() {
+ atf_set descr "print every instance of repeated lines"
+}
+all_repeated_body() {
+ printf "a\na\nb\na\na\n" >input
+ printf "a\na\na\na\n" >expected
+ atf_check_uniq -D
+ atf_check_uniq --all-repeated
+}
+
+atf_test_case skip_fields
+skip_fields_head() {
+ atf_set descr "skip fields"
+}
+skip_fields_body() {
+ printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input
+ printf "1 a\n3 b\n5 a\n" >expected
+ atf_check_uniq -f 1
+ atf_check_uniq --skip-fields 1
+}
+
+atf_test_case skip_fields_tab
+skip_fields_tab_head() {
+ atf_set descr "skip fields (with tabs)"
+}
+skip_fields_tab_body() {
+ printf "1\ta\n2\ta\n3\tb\n4\tb\n5\ta\n6\ta\n" >input
+ printf "1\ta\n3\tb\n5\ta\n" >expected
+ atf_check_uniq -f 1
+ atf_check_uniq --skip-fields 1
+}
+
+atf_test_case ignore_case
+ignore_case_head() {
+ atf_set descr "ignore case"
+}
+ignore_case_body() {
+ printf "a\nA\nb\nB\na\nA\n" >input
+ printf "a\nb\na\n" >expected
+ atf_check_uniq -i
+ atf_check_uniq --ignore-case
+}
+
+atf_test_case skip_chars
+skip_chars_head() {
+ atf_set descr "skip chars"
+}
+skip_chars_body() {
+ printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input
+ printf "1 a\n3 b\n5 a\n" >expected
+ atf_check_uniq -s 2
+ atf_check_uniq --skip-chars 2
+}
+
+atf_test_case unique
+unique_head() {
+ atf_set descr "print non-repeated lines only"
+}
+unique_body() {
+ printf "a\na\nb\na\na\n" >input
+ printf "b\n" >expected
+ atf_check_uniq -u
+ atf_check_uniq --unique
+}
+
+atf_test_case count_unique
+count_unique_head() {
+ atf_set descr "print non-repeated lines with count"
+}
+count_unique_body() {
+ printf "a\na\nb\n" >input
+ printf " 1 b\n" >expected
+ atf_check_uniq --unique --count
+ atf_check_uniq --count --unique
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+ atf_add_test_case count
+ atf_add_test_case repeated
+ atf_add_test_case count_repeated
+ atf_add_test_case all_repeated
+ atf_add_test_case skip_fields
+ atf_add_test_case skip_fields_tab
+ atf_add_test_case ignore_case
+ atf_add_test_case skip_chars
+ atf_add_test_case unique
+ atf_add_test_case count_unique
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 7, 10:19 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16509157
Default Alt Text
D43381.diff (4 KB)

Event Timeline