~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/split/suffix-length.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Show that split -a works.
 
3
 
 
4
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 
5
 
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
 
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
 
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
20
print_ver_ split
 
21
 
 
22
a_z='a b c d e f g h i j k l m n o p q r s t u v w x y z'
 
23
 
 
24
# Generate a 27-byte file
 
25
printf %s $a_z 0 |tr -d ' ' > in || framework_failure_
 
26
 
 
27
files=
 
28
for i in $a_z; do
 
29
  files="${files}xa$i "
 
30
done
 
31
files="${files}xba"
 
32
 
 
33
for f in $files; do
 
34
  printf "creating file '%s'"'\n' $f
 
35
done > exp || framework_failure_
 
36
 
 
37
echo split: output file suffixes exhausted \
 
38
  > exp-too-short || framework_failure_
 
39
 
 
40
 
 
41
# This should fail.
 
42
split -b 1 -a 1 in 2> err && fail=1
 
43
test -f xa || fail=1
 
44
test -f xz || fail=1
 
45
test -f xaa && fail=1
 
46
test -f xaz && fail=1
 
47
rm -f x*
 
48
compare exp-too-short err || fail=1
 
49
 
 
50
# With a longer suffix, it must succeed.
 
51
split --verbose -b 1 -a 2 in > err || fail=1
 
52
compare exp err || fail=1
 
53
 
 
54
# Ensure that xbb is *not* created.
 
55
test -f xbb && fail=1
 
56
 
 
57
# Ensure that the 27 others files *were* created, and with expected contents.
 
58
n=1
 
59
for f in $files; do
 
60
  expected_byte=$(cut -b $n in)
 
61
  b=$(cat $f) || fail=1
 
62
  test "$b" = "$expected_byte" || fail=1
 
63
  n=$(expr $n + 1)
 
64
done
 
65
 
 
66
# Ensure that -a is independent of -[bCl]
 
67
split -a2 -b1000 < /dev/null || fail=1
 
68
split -a2 -l1000 < /dev/null || fail=1
 
69
split -a2 -C1000 < /dev/null || fail=1
 
70
 
 
71
# Ensure that -a fails early with a -n that is too large
 
72
rm -f x*
 
73
split -a2 -n1000 < /dev/null && fail=1
 
74
test -f xaa && fail=1
 
75
 
 
76
Exit $fail