diff options
author | Jim Meyering <jim@meyering.net> | 1996-10-18 04:55:16 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1996-10-18 04:55:16 +0000 |
commit | 97f0f916a206e5fc5c26ea6e2e4ecd04b849e1d1 (patch) | |
tree | 81f45c95fd3a6d8e6d6c5f0c1f93ddee3d7cbf9f /tests | |
parent | 42e52b501786f0802978685b3f61382c4ab725e4 (diff) | |
download | coreutils-97f0f916a206e5fc5c26ea6e2e4ecd04b849e1d1.tar.xz |
.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/join/Makefile.am | 33 | ||||
-rw-r--r-- | tests/join/Test.pm | 111 | ||||
-rw-r--r-- | tests/join/build-script.pl | 88 |
3 files changed, 232 insertions, 0 deletions
diff --git a/tests/join/Makefile.am b/tests/join/Makefile.am new file mode 100644 index 000000000..5a7b8068a --- /dev/null +++ b/tests/join/Makefile.am @@ -0,0 +1,33 @@ +## Process this file with automake to produce Makefile.in. + +x = join +t = t1a t1b t1c t1d t1e t1f t2a t2b t2c t3a t4a t4b t4c t4d t4e t5a t5b \ +t5c t5d t5e t5f t5g t5h t5i t5j t5k t5l t5m t6a t6b t6c t7a t8a t8b t9a + +in1 = $(t:=.in1) +in2 = $(t:=.in2) +exp = $(t:=.exp) +out = $(t:=.out) +err = $(t:=.err) + +EXTRA_DIST = build-script.pl Test.pm $x-tests $(in1) $(in2) $(exp) +noinst_SCRIPTS = $x-tests build-script + +PERL = @PERL@ +editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g' + +TESTS = $x-tests + +$x-tests: @MAINT@build-script Test.pm + ./build-script ../../src/$x > $@.n + mv $@.n $@ + chmod 755 $@ + +SUFFIXES = .pl + +.pl: + rm -f $@ $@.tmp + $(editpl) $< > $@.tmp && chmod +x $@.tmp && mv $@.tmp $@ + +MAINTAINERCLEANFILES = $x-tests $(in) $(exp) +CLEANFILES = $(out) $(err) diff --git a/tests/join/Test.pm b/tests/join/Test.pm new file mode 100644 index 000000000..32297d0ba --- /dev/null +++ b/tests/join/Test.pm @@ -0,0 +1,111 @@ +package Test; +require 5.002; +use strict; + +my $nl = "\n"; +@Test::t = ( +# test name +# flags file-1 file-2 expected output expected return code +# +['1a', '-a1', "a 1\n", "b\n", "a 1\n", 0], +['1b', '-a2', "a 1\n", "b\n", "b\n", 0], # Got "\n" +['1c', '-a1 -a2', "a 1\n", "b\n", "a 1\nb\n", 0], # Got "a 1\n\n" +['1d', '-a1', "a 1\nb\n", "b\n", "a 1\nb\n", 0], +['1e', '-a2', "a 1\nb\n", "b\n", "b\n", 0], +['1f', '-a2', "b\n", "a\nb\n", "a\nb\n", 0], + +['2a', '-a1 -e .', "a\nb\nc\n", "a x y\nb\nc\n", "a x y\nb\nc\n", 0], +['2b', '-a1 -e . -o 2.1,2.2,2.3', "a\nb\nc\n", "a x y\nb\nc\n", + "a x y\nb . .\nc . .\n", 0], +['2c', '-a1 -e . -o 2.1,2.2,2.3', "a\nb\nc\nd\n", "a x y\nb\nc\n", + "a x y\nb . .\nc . .\n. . .\n", 0], + +['3a', '-t:', "a:1\nb:1\n", "a:2:\nb:2:\n", "a:1:2:\nb:1:2:\n", 0], + +# Just like -a1 and -a2 when there are no pairable lines +['4a', '-v 1', "a 1\n", "b\n", "a 1\n", 0], +['4b', '-v 2', "a 1\n", "b\n", "b\n", 0], + +['4c', '-v 1', "a 1\nb\n", "b\n", "a 1\n", 0], +['4d', '-v 2', "a 1\nb\n", "b\n", "", 0], +['4e', '-v 2', "b\n", "a 1\nb\n", "a 1\n", 0], +['5a', '-a1 -e - -o 1.1 2.2', + "a 1\nb 2\n", "a 11\nb\n", "a 11\nb -\n", 0], +['5b', '-a1 -e - -o 1.1 2.2', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\nfeb 15", + "apr 06\naug 14\ndec -\nfeb 15\n", 0], +['5c', '-a1 -e - -o 1.1 2.2', + "aug 20\ndec 18\n", + "aug 14\ndate\nfeb 15", + "aug 14\ndec -\n", 0], +['5d', '-a1 -e - -o 1.1 2.2', "dec 18\n", "", "dec -\n", 0], +['5e', '-a2 -e - -o 1.1 2.2', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\nfeb 15\n", + "apr 06\naug 14\n- -\nfeb 15\n", 0], +['5f', '-a2 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\nfeb 15\n", + "06 apr\n14 aug\n- -\n15 feb\n", 0], +['5g', '-a1 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\nfeb 15\n", + "06 apr\n14 aug\n- dec\n15 feb\n", 0], + +['5h', '-a1 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\n", + "06 apr\n14 aug\n- dec\n- feb\n", 0], +['5i', '-a1 -e - -o 1.1 2.2', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\n", + "apr 06\naug 14\ndec -\nfeb -\n", 0], + +['5j', '-a2 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\n", + "06 apr\n14 aug\n- -\n", 0], +['5k', '-a2 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\nfeb 05\n", + "apr 06\naug 14\ndate\n", + "06 apr\n14 aug\n- -\n", 0], + +['5l', '-a1 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\n", + "apr 06\naug 14\ndate\nfeb 15\n", + "06 apr\n14 aug\n- dec\n", 0], +['5m', '-a2 -e - -o 2.2 1.1', + "apr 15\naug 20\ndec 18\n", + "apr 06\naug 14\ndate\nfeb 15\n", + "06 apr\n14 aug\n- -\n15 -\n", 0], + +['6a', '-e -', + "a 1\nb 2\nd 4\n", + "a 21\nb 22\nc 23\nf 26\n", + "a 1 21\nb 2 22\n", 0], +['6b', '-a1 -e -', + "a 1\nb 2\nd 4\n", + "a 21\nb 22\nc 23\nf 26\n", + "a 1 21\nb 2 22\nd 4\n", 0], +['6c', '-a1 -e -', + "a 21\nb 22\nc 23\nf 26\n", + "a 1\nb 2\nd 4\n", + "a 21 1\nb 22 2\nc 23\nf 26\n", 0], + +['7a', '-a1 -e . -o 2.7', "a\nb\nc\n", "a x y\nb\nc\n", ".\n.\n.\n", 0], + +['8a', '-a1 -e . -o 0,1.2', + "a\nb\nc\nd G\n", + "a x y\nb\nc\ne\n", + "a .\nb .\nc .\nd G\n", 0], +['8b', '-a1 -a2 -e . -o 0,1.2', + "a\nb\nc\nd G\n", + "a x y\nb\nc\ne\n", + "a .\nb .\nc .\nd G\ne .\n", 0], + +# From David Dyck +['9a', '', " a 1\n b 2\n", " a Y\n b Z\n", "a 1 Y\nb 2 Z\n", 0], +); + +1; diff --git a/tests/join/build-script.pl b/tests/join/build-script.pl new file mode 100644 index 000000000..58a1328f6 --- /dev/null +++ b/tests/join/build-script.pl @@ -0,0 +1,88 @@ +#! @PERL@ -w +# -*- perl -*- +# @configure_input@ + +require 5.002; + +BEGIN { push @INC, '@srcdir@' if '@srcdir@' ne '.'; } +use strict; +use Test; + +$| = 1; + +my $xx = $ARGV[0]; + +print <<EOF; +#! /bin/sh +# This script was generated automatically by build-script. +case \$# in + 0) xx='$xx';; + *) xx="\$1";; +esac +test "\$VERBOSE" && echo=echo || echo=: +\$echo testing program: \$xx +errors=0 +test "\$srcdir" || srcdir=. +test "\$VERBOSE" && \$xx --version 2> /dev/null +EOF + +my %seen; + +my $test_vector; +foreach $test_vector (@Test::t) + { + my ($test_name, $flags, $file1, $file2, $expected, $e_ret_code) + = @{$test_vector}; + die "$0: $.: duplicate test name \`$test_name'\n" + if (defined ($seen{$test_name})); + $seen{$test_name} = 1; + + my $in1 = "t$test_name.in1"; + my $in2 = "t$test_name.in2"; + my $exp_name = "t$test_name.exp"; + my $out = "t$test_name.out"; + + open (IN1, ">$in1") || die "$0: $in1: $!\n"; + print IN1 $file1; + close (IN1) || die "$0: $in1: $!\n"; + + open (IN2, ">$in2") || die "$0: $in2: $!\n"; + print IN2 $file2; + close (IN2) || die "$0: $in2: $!\n"; + + open (EXP, ">$exp_name") || die "$0: $exp_name: $!\n"; + print EXP $expected; + close (EXP) || die "$0: $exp_name: $!\n"; + + my $err_output = "t$test_name.err"; + my $cmd = "\$xx $flags \$srcdir/$in1 \$srcdir/$in2 > $out 2> $err_output"; + $exp_name = "\$srcdir/$exp_name"; + print <<EOF ; +$cmd +code=\$? +if test \$code != $e_ret_code ; then + \$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2 + errors=`expr \$errors + 1` +else + cmp $out $exp_name + case \$? in + 0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files + 1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2; + errors=`expr \$errors + 1` ;; + 2) \$echo Test $test_name may have failed. 1>&2; + \$echo The command \"cmp $out $exp_name\" failed. 1>&2 ; + errors=`expr \$errors + 1` ;; + esac +fi +test -s $err_output || rm -f $err_output +EOF + } +print <<EOF2 ; +if test \$errors = 0 ; then + \$echo Passed all tests. 1>&2 +else + \$echo Failed \$errors tests. 1>&2 +fi +test \$errors = 0 || errors=1 +exit \$errors +EOF2 |