Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147409219
D49911.id154137.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D49911.id154137.diff
View Options
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
@@ -1087,6 +1087,8 @@
..
col
..
+ column
+ ..
comm
..
compress
diff --git a/usr.bin/column/Makefile b/usr.bin/column/Makefile
--- a/usr.bin/column/Makefile
+++ b/usr.bin/column/Makefile
@@ -1,3 +1,8 @@
+.include <src.opts.mk>
+
PROG= column
+HAS_TESTS=
+SUBDIR.${MK_TESTS}= tests
+
.include <bsd.prog.mk>
diff --git a/usr.bin/column/tests/Makefile b/usr.bin/column/tests/Makefile
new file mode 100644
--- /dev/null
+++ b/usr.bin/column/tests/Makefile
@@ -0,0 +1,3 @@
+ATF_TESTS_SH= column
+
+.include <bsd.test.mk>
diff --git a/usr.bin/column/tests/column.sh b/usr.bin/column/tests/column.sh
new file mode 100644
--- /dev/null
+++ b/usr.bin/column/tests/column.sh
@@ -0,0 +1,170 @@
+# SPDX-License-Identifier: ISC
+#
+# Copyright (c) 2025 Lexi Winter
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+atf_test_case "basic"
+basic_head()
+{
+ atf_set descr "Basic column(1) with default options"
+}
+
+basic_body()
+{
+ cat >input.1 <<END
+this is the first input file
+it has multiple lines
+END
+
+ cat >input.2 <<END
+here lies the second input file
+some lines
+
+are empty
+END
+
+ cat >input.3 <<END
+third of the input files am i
+and i have
+more
+lines
+than before
+END
+
+ cat >expected <<END
+this is the first input file are empty lines
+it has multiple lines third of the input files am i than before
+here lies the second input file and i have
+some lines more
+END
+
+ atf_check -o save:output column -c120 input.1 input.2 input.3
+ atf_check diff expected output
+}
+
+atf_test_case "rows"
+rows_head()
+{
+ atf_set descr "column(1) with -x (row-wise) option"
+}
+
+rows_body()
+{
+ cat >input.1 <<END
+this is the first input file
+it has multiple lines
+END
+
+ cat >input.2 <<END
+here lies the second input file
+some lines
+
+are empty
+END
+
+ cat >input.3 <<END
+third of the input files am i
+and i have
+more
+lines
+than before
+END
+
+ cat >expected <<END
+this is the first input file it has multiple lines here lies the second input file
+some lines are empty third of the input files am i
+and i have more lines
+than before
+END
+
+ atf_check -o save:output column -xc120 input.1 input.2 input.3
+ atf_check diff expected output
+}
+
+atf_test_case "basic_table"
+basic_table_head()
+{
+ atf_set descr "column(1) with -t (table) option"
+}
+
+basic_table_body()
+{
+ cat >input.1 <<END
+1 2 3 4
+foo bar baz quux
+END
+
+ cat >input.2 <<END
+fie fi fo fum
+END
+
+ cat >input.3 <<END
+where did my
+fields go
+argh
+END
+
+ cat >expected <<END
+1 2 3 4
+foo bar baz quux
+fie fi fo fum
+where did my
+fields go
+argh
+END
+
+ atf_check -o save:output column -tc120 input.1 input.2 input.3
+ atf_check diff expected output
+}
+
+atf_test_case "colonic_table"
+colonic_table_head()
+{
+ atf_set descr "column(1) with -t (table) and -s options"
+}
+
+colonic_table_body()
+{
+ cat >input <<END
+one:two.three
+four.five:six
+seven.:eight.:nine
+:ein
+::zwei
+drei..
+vier:
+
+END
+
+ cat >expected <<END
+one two three
+four five six
+seven eight nine
+ein
+zwei
+drei
+vier
+END
+
+ atf_check -o save:output column -tc120 -s:. input
+ atf_check diff expected output
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+ atf_add_test_case rows
+ atf_add_test_case basic_table
+ atf_add_test_case colonic_table
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 11, 6:18 PM (1 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29546385
Default Alt Text
D49911.id154137.diff (4 KB)
Attached To
Mode
D49911: column(1): add tests
Attached
Detach File
Event Timeline
Log In to Comment