Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/util Merge the sort tests from regress/ into the exist...
details: https://anonhg.NetBSD.org/src/rev/e14cc1a07715
branches: trunk
changeset: 756789:e14cc1a07715
user: jmmv <jmmv%NetBSD.org@localhost>
date: Sun Aug 01 16:42:58 2010 +0000
description:
Merge the sort tests from regress/ into the existing atfified sort tests.
While doing this put the sort tests into a separate directory to follow
the convention of tests/util/.
diffstat:
tests/util/Makefile | 6 +-
tests/util/sort/Makefile | 15 +
tests/util/sort/d_any_char_dflag_out.txt | Bin
tests/util/sort/d_any_char_fflag_out.txt | Bin
tests/util/sort/d_any_char_iflag_out.txt | Bin
tests/util/sort/d_any_char_in.txt | Bin
tests/util/sort/t_sort.sh | 1067 ++++++++++++++++++++++++++++++
tests/util/t_sort.sh | 371 ----------
8 files changed, 1085 insertions(+), 374 deletions(-)
diffs (truncated from 1498 to 300 lines):
diff -r c42c741cc86b -r e14cc1a07715 tests/util/Makefile
--- a/tests/util/Makefile Sun Aug 01 15:42:19 2010 +0000
+++ b/tests/util/Makefile Sun Aug 01 16:42:58 2010 +0000
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile,v 1.9 2010/07/18 10:11:00 jmmv Exp $
+# $NetBSD: Makefile,v 1.10 2010/08/01 16:42:58 jmmv Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util
-TESTS_SUBDIRS= awk bzip2 config cut df grep id m4 make mtree ps sdiff sh xlint
+TESTS_SUBDIRS= awk bzip2 config cut df grep id m4 make mtree ps sdiff sh sort \
+ xlint
TESTS_SH= t_basename
TESTS_SH+= t_cp
@@ -13,7 +14,6 @@
TESTS_SH+= t_expr
TESTS_SH+= t_gzip
TESTS_SH+= t_pax
-TESTS_SH+= t_sort
TESTS_SH+= t_tar
.include <bsd.test.mk>
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/util/sort/Makefile Sun Aug 01 16:42:58 2010 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2010/08/01 16:42:58 jmmv Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/util/sort
+
+TESTS_SH= t_sort
+
+FILESDIR= ${TESTSDIR}
+FILES= d_any_char_dflag_out.txt
+FILES+= d_any_char_fflag_out.txt
+FILES+= d_any_char_iflag_out.txt
+FILES+= d_any_char_in.txt
+
+.include <bsd.test.mk>
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/d_any_char_dflag_out.txt
Binary file tests/util/sort/d_any_char_dflag_out.txt has changed
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/d_any_char_fflag_out.txt
Binary file tests/util/sort/d_any_char_fflag_out.txt has changed
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/d_any_char_iflag_out.txt
Binary file tests/util/sort/d_any_char_iflag_out.txt has changed
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/d_any_char_in.txt
Binary file tests/util/sort/d_any_char_in.txt has changed
diff -r c42c741cc86b -r e14cc1a07715 tests/util/sort/t_sort.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/util/sort/t_sort.sh Sun Aug 01 16:42:58 2010 +0000
@@ -0,0 +1,1067 @@
+# $NetBSD: t_sort.sh,v 1.1 2010/08/01 16:42:58 jmmv Exp $
+#
+# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+atf_test_case basic
+basic_head()
+{
+ atf_set "descr" "Basic functionality test"
+ atf_set "use.fs" "true"
+}
+basic_body()
+{
+ cat >in <<EOF
+z b m f
+y c o e
+x a n h
+x a n g
+EOF
+
+ cat >expout <<EOF
+x a n g
+x a n h
+y c o e
+z b m f
+EOF
+
+ atf_check -o file:expout sort in
+}
+
+atf_test_case empty_file
+empty_file_head()
+{
+ atf_set "descr" "Tests sorting an empty file"
+ atf_set "use.fs" "true"
+}
+empty_file_body()
+{
+ touch empty
+ atf_check -o empty sort -S empty
+ atf_check sort -S -c empty
+ atf_check sort -S -c -u empty
+}
+
+atf_test_case end_of_options
+end_of_options_head()
+{
+ atf_set "descr" "Determination of end of option list"
+ atf_set "use.fs" "true"
+}
+end_of_options_body()
+{
+ echo x >-k
+ atf_check -o file:-k -x "sort -S -- -k </dev/null"
+ atf_check -s not-exit:1 -e ignore -x "sort -S - -c </dev/null"
+}
+
+atf_test_case missing_newline
+missing_newline_head()
+{
+ atf_set "descr" "Tests with missing new line in input file"
+ atf_set "use.fs" "true"
+}
+missing_newline_body()
+{
+ printf '%s' x >in
+ atf_check -o inline:'x\n' sort in
+}
+
+atf_test_case null_bytes
+null_bytes_head()
+{
+ atf_set "descr" "Tests the behavior of null bytes"
+ atf_set "use.fs" "true"
+}
+null_bytes_body()
+{
+ printf '\0b\n\0a\n' >in
+ atf_check -o inline:'\0a\n\0b\n' sort -S in
+}
+
+atf_test_case long_records
+long_records_head()
+{
+ atf_set "descr" "Tests long lines and keys"
+ atf_set "use.fs" "true"
+}
+long_records_body()
+{
+ awk 'BEGIN { x="x"
+ for(i=1; i<=12; i++) x = x x
+ for(i=15; i<=25; i++) print x i
+}' >in
+
+ awk 'BEGIN { x="x"
+ for(i=1; i<=12; i++) x = x x
+ for(i=25; i>=15; i--) print x i
+}' >out
+
+ atf_check -o file:out sort -r in
+ atf_check -o file:out sort -k 1,1r -k 1 in
+}
+
+atf_test_case long_file
+long_file_head()
+{
+ atf_set "descr" "Tests with a long file to try to force intermediate" \
+ "files"
+ atf_set "use.fs" "true"
+}
+long_file_body()
+{
+ awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in
+ sort -S -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out
+ atf_check -o file:out sort -u -r in
+}
+
+atf_test_case any_char
+any_char_head()
+{
+ atf_set "descr" "Tests with files containing non-printable/extended" \
+ "characters"
+}
+any_char_body()
+{
+ atf_check -o file:$(atf_get_srcdir)/d_any_char_dflag_out.txt \
+ sort -d -k 2 $(atf_get_srcdir)/d_any_char_in.txt
+
+ atf_check -o file:$(atf_get_srcdir)/d_any_char_fflag_out.txt \
+ sort -f -k 2 $(atf_get_srcdir)/d_any_char_in.txt
+
+ atf_check -o file:$(atf_get_srcdir)/d_any_char_iflag_out.txt \
+ sort -i -k 2 $(atf_get_srcdir)/d_any_char_in.txt
+}
+
+atf_test_case bflag
+bflag_head()
+{
+ atf_set "descr" "Tests the -b flag"
+ atf_set "use.fs" "true"
+}
+bflag_body()
+{
+ cat >in <<EOF
+ b
+ a
+EOF
+
+ atf_check -o file:in sort -b in
+ atf_check -o file:in -x "sort -b <in"
+ atf_check -s exit:1 -o ignore -e ignore -x "sort in | sort -c -r"
+}
+
+atf_test_case cflag
+cflag_head()
+{
+ atf_set "descr" "Tests the -c flag"
+ atf_set "use.fs" "true"
+}
+cflag_body()
+{
+ cat >in <<EOF
+b
+a
+EOF
+
+ atf_check -s exit:1 -e ignore sort -S -c in
+}
+
+atf_test_case kflag_one_field
+kflag_one_field_head()
+{
+ atf_set "descr" "Tests the -k flag with one field"
+ atf_set "use.fs" "true"
+}
+kflag_one_field_body()
+{
+ cat >in <<EOF
+z b m f
+y c o e
+x a n h
+x a n g
+EOF
+
+ cat >expout <<EOF
+x a n g
+x a n h
+z b m f
+y c o e
+EOF
+
+ atf_check -o file:expout sort -k2.1 in
+}
+
+atf_test_case kflag_two_fields
+kflag_two_fields_head()
+{
+ atf_set "descr" "Tests the -k flag with two fields"
+ atf_set "use.fs" "true"
+}
+kflag_two_fields_body()
+{
+ cat >in <<EOF
+z b m f
+y c o e
+x a n h
+x a n g
+EOF
+
+ cat >expout <<EOF
+x a n h
+x a n g
+z b m f
+y c o e
+EOF
+ atf_check -o file:expout sort -k2.1,2.0 in
+}
+
+atf_test_case kflag_many_fields
+kflag_many_fields_head()
+{
+ atf_set "descr" "Tests the -k flag with many fields"
Home |
Main Index |
Thread Index |
Old Index