Page MenuHomeFreeBSD

D53750.id166404.diff
No OneTemporary

D53750.id166404.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
@@ -1165,6 +1165,8 @@
..
jot
..
+ lam
+ ..
lastcomm
..
limits
diff --git a/usr.bin/lam/Makefile b/usr.bin/lam/Makefile
--- a/usr.bin/lam/Makefile
+++ b/usr.bin/lam/Makefile
@@ -1,3 +1,8 @@
+.include <src.opts.mk>
+
PROG= lam
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
diff --git a/usr.bin/lam/lam.c b/usr.bin/lam/lam.c
--- a/usr.bin/lam/lam.c
+++ b/usr.bin/lam/lam.c
@@ -216,8 +216,6 @@
if (ferror(ip->fp)) {
err(EX_IOERR, NULL);
}
- if (ip->fp == stdin)
- fclose(stdin);
morefiles--;
return (pad(ip));
}
diff --git a/usr.bin/lam/tests/Makefile b/usr.bin/lam/tests/Makefile
new file mode 100644
--- /dev/null
+++ b/usr.bin/lam/tests/Makefile
@@ -0,0 +1,5 @@
+PACKAGE= tests
+
+ATF_TESTS_SH= lam_test
+
+.include <bsd.test.mk>
diff --git a/usr.bin/lam/tests/lam_test.sh b/usr.bin/lam/tests/lam_test.sh
new file mode 100755
--- /dev/null
+++ b/usr.bin/lam/tests/lam_test.sh
@@ -0,0 +1,59 @@
+#
+# Copyright (c) 2025 Klara, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+atf_test_case basic
+basic_head()
+{
+ atf_set "descr" "Test basic lam(1) functionality"
+}
+basic_body()
+{
+ printf '1\n2\n3\n' > a
+ printf '4\n5\n6\n' > b
+
+ atf_check -o inline:"14\n25\n36\n" lam a b
+}
+
+atf_test_case sep
+sep_head()
+{
+ atf_set "descr" "Test lam(1) -s and -S options"
+}
+sep_body()
+{
+ printf "1\n" > a
+ printf "0\n" > b
+
+ atf_check -o inline:"x1x0\n" lam -S x a b
+ atf_check -o inline:"1x0\n" lam a -S x b
+ atf_check -o inline:"x10\n" lam -S x a -s '' b
+
+ atf_check -o inline:"x10\n" lam -s x a b
+ atf_check -o inline:"x1y0\n" lam -s x a -s y b
+ atf_check -o inline:"1x0\n" lam a -s x b
+}
+
+atf_test_case stdin
+stdin_head()
+{
+ atf_set "descr" "Test lam(1) using stdin"
+}
+stdin_body()
+{
+ printf '1\n2\n3\n4\n' > a
+
+ atf_check -o inline:"11\n22\n33\n44\n" lam a - < a
+ atf_check -o inline:"11\n22\n33\n44\n" lam - a < a
+
+ atf_check -o inline:"12\n34\n" lam - - < a
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+ atf_add_test_case sep
+ atf_add_test_case stdin
+}

File Metadata

Mime Type
text/plain
Expires
Wed, May 20, 4:25 AM (6 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33337041
Default Alt Text
D53750.id166404.diff (2 KB)

Event Timeline