.
[coreutils.git] / tests / tail-2 / big-4gb
blob9b53f79896f7779cb222ad9ccfb52b4a7660a596
1 #!/bin/sh
2 # Demonstrate a bug in `tail -cN' when operating on files of size 4G and larger
3 # Fixed in coreutils-4.5.2.
5 . $srcdir/../expensive
7 if test "$VERBOSE" = yes; then
8 set -x
9 tail --version
12 pwd=`pwd`
13 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
14 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
15 trap '(exit $?); exit $?' 1 2 13 15
17 framework_failure=0
18 mkdir -p $tmp || framework_failure=1
19 cd $tmp || framework_failure=1
21 # Create a file of size exactly 4GB (2^32) with 8 bytes
22 # at the beginning and another set of 8 bytes at the end.
23 # The rest will be NUL bytes. On most modern systems, the following
24 # creates a file that takes up only a few KB. Here, du -sh says 16K.
25 echo abcdefgh | tr -d '\n' > big || framework_failure=1
26 echo 87654321 | tr -d '\n' > tmp || framework_failure=1
27 # Seek 4GB - 8
28 dd bs=1 seek=4294967288 if=tmp of=big 2> err || dd_failed=1
29 if test "$dd_failed" = 1; then
30 cat err 1>&2
31 echo "$0: cannot create a file large enough for this test," 1>&2
32 echo "$0: possibly because this system doesn't support large files;" 1>&2
33 echo "$0: Consider rerunning this test on a different file system." 1>&2
34 (exit 77); exit 77
37 if test $framework_failure = 1; then
38 echo "$0: failure in testing framework" 1>&2
39 (exit 1); exit 1
42 fail=0
44 tail -c1 big > out || fail=1
45 # Append a newline.
46 echo >> out
47 cat <<\EOF > exp
49 EOF
51 cmp out exp || fail=1
52 test $fail = 1 && diff out exp 2> /dev/null
54 (exit $fail); exit $fail