6 # test name, options, input, expected output, expected return code
8 ['obs-plus-c1', '+2c', 'abcd', 'bcd', 0],
9 ['obs-plus-c2', '+8c', 'abcd', '', 0],
10 ['obs-c3', '-1c', 'abcd', 'd', 0],
11 ['obs-c4', '-9c', 'abcd', 'abcd', 0],
12 ['obs-c5', '-12c', 'x' . ('y' x 12) . 'z', ('y' x 11) . 'z', 0],
15 ['obs-l1', '-1l', 'x', 'x', 0],
16 ['obs-l2', '-1l', "x\ny\n", "y\n", 0],
17 ['obs-l3', '-1l', "x\ny", "y", 0],
18 ['obs-plus-l4', '+1l', "x\ny\n", "x\ny\n", 0],
19 ['obs-plus-l5', '+2l', "x\ny\n", "y\n", 0],
21 # Same as -l tests, but without the `l'.
22 ['obs-1', '-1', 'x', 'x', 0],
23 ['obs-2', '-1', "x\ny\n", "y\n", 0],
24 ['obs-3', '-1', "x\ny", "y", 0],
25 ['obs-plus-4', '+1', "x\ny\n", "x\ny\n", 0],
26 ['obs-plus-5', '+2', "x\ny\n", "y\n", 0],
28 # This is equivalent to +10c
29 ['obs-plus-x1', '+c', 'x' . ('y' x 10) . 'z', 'yyz', 0],
30 # This is equivalent to +10l
31 ['obs-plus-x2', '+l', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0],
32 # With no number, this is like -10l
33 ['obs-l', '-l', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
35 ['obs-b', '-b', "x\n" x (512 * 10 / 2 + 1), "x\n" x (512 * 10 / 2), 0],
38 # `tail: cannot open `+cl' for reading: No such file or directory'
39 ['err-1', '+cl', '', '', 1],
41 # This should get `tail: l: invalid number of bytes'
42 ['err-2', '-cl', '', '', 1],
45 # `tail: cannot open `+2cz' for reading: No such file or directory'
46 ['err-3', '+2cz', '', '', 1],
48 # This should get `tail: invalid option -- 2'
49 ['err-4', '-2cX', '', '', 1],
51 # Since the number is larger than 2^64, this should provoke
52 # the diagnostic: `tail: 99999999999999999999: invalid number of bytes'
53 # on all systems... probably, for now, maybe.
54 ['err-5', '-c99999999999999999999', '', '', 1],
55 ['err-6', '-c', '', '', 1],
58 ['minus-1', '-', '', '', 0],
59 ['minus-2', '-', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
61 ['c-2', '-c 2', "abcd\n", "d\n", 0],
62 ['c-2-minus', '-c 2 --', "abcd\n", "d\n", 0],
63 ['c2', '-c2', "abcd\n", "d\n", 0],
64 ['c2-minus', '-c2 --', "abcd\n", "d\n", 0],
66 ['n-1', '-n 10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
67 ['n-2', '-n -10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
68 ['n-3', '-n +10', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0],
70 # Accept +0 as synonym for +1.
71 ['n-4', '-n +0', "y\n" x 5, "y\n" x 5, 0],
72 ['n-4a', '-n +1', "y\n" x 5, "y\n" x 5, 0],
74 # Note that -0 is *not* a synonym for -1.
75 ['n-5', '-n -0', "y\n" x 5, '', 0],
76 ['n-5a', '-n -1', "y\n" x 5, "y\n", 0],
77 ['n-5b', '-n 0', "y\n" x 5, '', 0],
79 # With textutils-1.22, this failed.
80 ['f-pipe-1', '-f -n 1', "a\nb\n", "b\n", 0],
88 my ($test_name, $flags, $in, $exp, $ret) = @$t;
90 if ($test_name =~ /^(obs-plus-|minus-)/)
92 $Test::env{$test_name} = ['_POSIX2_VERSION=199209'];
94 if ($test_name =~ /^(err-6|c-2)$/)
96 $Test::env{$test_name} = ['_POSIX2_VERSION=200112'];
98 if ($test_name =~ /^f-pipe-/)
100 $Test::env{$test_name} = ['POSIXLY_CORRECT=1'];
103 # If you run the minus* tests with a FILE arg they'd hang.
104 # If you run the err-1 or err-3 tests with a FILE, they'd misinterpret
105 # the arg unless we are using the obsolete form.
106 if ($test_name =~ /^(minus|err-[13])/)
108 $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
110 elsif ($test_name =~ /^f-/)
112 # Using redirection or a file would make this hang.
113 $Test::input_via{$test_name} = {PIPE => 0};
117 $Test::input_via{$test_name} = {REDIR => 0, FILE => 0, PIPE => 0}