Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107583773
D35877.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
D35877.diff
View Options
Index: etc/mtree/BSD.tests.dist
===================================================================
--- etc/mtree/BSD.tests.dist
+++ etc/mtree/BSD.tests.dist
@@ -1102,6 +1102,8 @@
..
vmstat
..
+ wc
+ ..
xargs
..
xinstall
Index: usr.bin/wc/Makefile
===================================================================
--- usr.bin/wc/Makefile
+++ usr.bin/wc/Makefile
@@ -12,4 +12,7 @@
CFLAGS+=-DWITH_CASPER
.endif
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
Index: usr.bin/wc/tests/01_longest_line.in
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/01_longest_line.in
@@ -0,0 +1,3 @@
+This is the testfile for testing the function of wc.
+The following line are useless sentences.
+amsvpasmvpasmvpom mak svp aslpv sakp vkowa ka sp aspk alk ko
Index: usr.bin/wc/tests/02_new_lines.in
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/02_new_lines.in
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
Index: usr.bin/wc/tests/03_tot_bytes.in
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/03_tot_bytes.in
@@ -0,0 +1,4 @@
+knasovnasokvnaso aps fnasoi fasoifcnas ncpasn ca
+skan okcabs as fs
+f as
+f asokf a
Index: usr.bin/wc/tests/04_zh-TW.in
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/04_zh-TW.in
@@ -0,0 +1 @@
+utf-8中文測試與位元數測試
Index: usr.bin/wc/tests/Makefile
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/Makefile
@@ -0,0 +1,12 @@
+# $FreebBSD$
+
+PACKAGE= tests
+
+ATF_TESTS_SH= wc_test
+
+${PACKAGE}FILES+= 01_longest_line.in \
+ 02_new_lines.in \
+ 03_tot_bytes.in \
+ 04_zh-TW.in
+
+.include <bsd.test.mk>
Index: usr.bin/wc/tests/wc_test.sh
===================================================================
--- /dev/null
+++ usr.bin/wc/tests/wc_test.sh
@@ -0,0 +1,86 @@
+atf_test_case longest_line
+longest_line_head() {
+ atf_set "descr" "Test the wc longest line output" \
+ "with output -L"
+}
+
+longest_line_body() {
+ atf_check -o inline:" 61 $(atf_get_srcdir)/01_longest_line.in\n" \
+ wc -L $(atf_get_srcdir)/01_longest_line.in
+}
+
+atf_test_case new_lines
+new_lines_head() {
+ atf_set "descr" "Test the wc multiple blank newlines output" \
+ "with output -l"
+}
+
+new_lines_body() {
+ atf_check -o inline:" 9 $(atf_get_srcdir)/02_new_lines.in\n" \
+ wc -l $(atf_get_srcdir)/02_new_lines.in
+}
+
+atf_test_case total_bytes_ascii
+total_bytes_ascii_head() {
+ atf_set "descr" "Test with the wc byte count output" \
+ "with output -c"
+}
+
+total_bytes_ascii_body() {
+ atf_check -o inline:" $(stat -f %z $(atf_get_srcdir)/03_tot_bytes.in) $(atf_get_srcdir)/03_tot_bytes.in\n" \
+ wc -c $(atf_get_srcdir)/03_tot_bytes.in
+}
+
+atf_test_case total_chars_ascii
+total_chars_ascii_head() {
+ atf_set "descr" "Test with the wc char count output" \
+ "with output -m"
+}
+
+total_chars_ascii_body() {
+ atf_check -o inline:" 82 $(atf_get_srcdir)/03_tot_bytes.in\n" \
+ wc -m $(atf_get_srcdir)/03_tot_bytes.in
+}
+
+atf_test_case total_bytes_zh_TW
+total_bytes_zh_TW_head() {
+ atf_set "descr" "Test with the wc chinese byte count output" \
+ "with output -c"
+}
+
+total_bytes_zh_TW_body() {
+ atf_check -o inline:" 36 $(atf_get_srcdir)/04_zh-TW.in\n" \
+ wc -c $(atf_get_srcdir)/04_zh-TW.in
+}
+
+atf_test_case total_chars_zh_TW
+total_chars_zh_TW_head() {
+ atf_set "descr" "Test with the wc chinese char count output" \
+ "with output -m"
+}
+
+total_chars_zh_TW_body() {
+ atf_check -o inline:" 16 $(atf_get_srcdir)/04_zh-TW.in\n" \
+ sh -c "LC_ALL=zh_TW.UTF-8 wc -m $(atf_get_srcdir)/04_zh-TW.in"
+}
+
+atf_test_case total_words
+total_words_head() {
+ atf_set "descr" "Test with the wc word count output" \
+ "with output -w"
+}
+
+total_words_body() {
+ atf_check -o inline:" 15 $(atf_get_srcdir)/03_tot_bytes.in\n" \
+ wc -w $(atf_get_srcdir)/03_tot_bytes.in
+}
+
+atf_init_test_cases() {
+ atf_add_test_case longest_line
+ atf_add_test_case new_lines
+ atf_add_test_case total_bytes_ascii
+ atf_add_test_case total_chars_ascii
+ atf_add_test_case total_words
+ atf_add_test_case total_bytes_zh_TW
+ atf_add_test_case total_chars_zh_TW
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 5:56 AM (21 h, 13 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15834809
Default Alt Text
D35877.diff (4 KB)
Attached To
Mode
D35877: Add tests for wc(1)
Attached
Detach File
Event Timeline
Log In to Comment