Page MenuHomeFreeBSD

D44134.diff
No OneTemporary

D44134.diff

diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -1137,6 +1137,8 @@
..
lockf
..
+ lorder
+ ..
m4
..
mkimg
diff --git a/usr.bin/lorder/Makefile b/usr.bin/lorder/Makefile
--- a/usr.bin/lorder/Makefile
+++ b/usr.bin/lorder/Makefile
@@ -1,5 +1,9 @@
+.include <src.opts.mk>
SCRIPTS=lorder.sh
MAN= lorder.1
+HAS_TESTS=
+SUBDIR.${MK_TESTS}= tests
+
.include <bsd.prog.mk>
diff --git a/usr.bin/lorder/tests/Makefile b/usr.bin/lorder/tests/Makefile
new file mode 100644
--- /dev/null
+++ b/usr.bin/lorder/tests/Makefile
@@ -0,0 +1,4 @@
+PACKAGE= tests
+ATF_TESTS_SH= lorder_test
+
+.include <bsd.test.mk>
diff --git a/usr.bin/lorder/tests/lorder_test.sh b/usr.bin/lorder/tests/lorder_test.sh
new file mode 100644
--- /dev/null
+++ b/usr.bin/lorder/tests/lorder_test.sh
@@ -0,0 +1,111 @@
+#
+# Copyright (c) 2024 Klara, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+atf_test_case noargs
+noargs_head() {
+ atf_set descr "No arguments"
+}
+noargs_body() {
+ atf_check -s exit:1 -e match:"^usage:" \
+ lorder
+}
+
+atf_test_case onearg
+onearg_head() {
+ atf_set descr "One argument"
+}
+onearg_body() {
+ echo "void a(void) { }" >a.c
+ cc -o a.o -c a.c
+ echo "a.o a.o" >output
+ atf_check -o file:output \
+ lorder *.o
+}
+
+atf_test_case dashdash
+dashdash_head() {
+ atf_set descr "One argument"
+}
+dashdash_body() {
+ echo "void a(void) { }" >a.c
+ cc -o a.o -c a.c
+ echo "a.o a.o" >output
+ atf_check -o file:output \
+ lorder -- *.o
+}
+
+atf_test_case nonexistent
+nonexistent_head() {
+ atf_set descr "Nonexistent file"
+}
+nonexistent_body() {
+ atf_check -s not-exit:0 -e match:"No such file" -o empty \
+ lorder nonexistent.o
+}
+
+atf_test_case invalid
+invalid_head() {
+ atf_set descr "Invalid file"
+}
+invalid_body() {
+ echo "not an object file" >invalid.o
+ atf_check -s not-exit:0 -e match:"File format not" -o empty \
+ lorder invalid.o
+}
+
+atf_test_case objects
+objects_head() {
+ atf_set descr "Order objects"
+}
+objects_body() {
+ echo "void a(void) { }" >a.c
+ echo "void a(void); void b(void) { a(); }" >b.c
+ echo "void b(void); void c(void) { b(); }" >c.c
+ for n in a b c ; do
+ cc -o $n.o -c $n.c
+ echo "$n.o $n.o"
+ done >output
+ echo "b.o a.o" >>output
+ echo "c.o b.o" >>output
+ atf_check -o file:output \
+ lorder *.o
+}
+
+atf_test_case archives
+archives_head() {
+ atf_set descr "Order archives"
+}
+archives_body() {
+ echo "void a(void) { }" >a.c
+ echo "void a(void); void b(void) { a(); }" >b.c
+ echo "void b(void); void c(void) { b(); }" >c.c
+ echo "void e(void); void d(void) { e(); }" >d.c
+ echo "void d(void); void e(void) { d(); }" >e.c
+ for n in a b c d e ; do
+ cc -o $n.o -c $n.c
+ done
+ for n in a b c ; do
+ ar -crs $n.a $n.o
+ echo "$n.a $n.a"
+ done >output
+ ar -crs z.a d.o e.o
+ echo "z.a z.a" >>output
+ echo "b.a a.a" >>output
+ echo "c.a b.a" >>output
+ atf_check -o file:output \
+ lorder *.a
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case noargs
+ atf_add_test_case onearg
+ atf_add_test_case dashdash
+ atf_add_test_case nonexistent
+ atf_add_test_case invalid
+ atf_add_test_case objects
+ atf_add_test_case archives
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 24, 7:00 AM (9 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16080618
Default Alt Text
D44134.diff (3 KB)

Event Timeline