summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-02-23 15:18:16 +0100
committerJim Meyering <jim@meyering.net>2007-02-23 15:18:16 +0100
commitcb121d8f3683e81cf51c8f0c7a28dfa58ae68fa8 (patch)
tree211be79c1a1135f705555d4ef5fecb7028da8523 /tests
parent3a9070dce7e3722c050c3e2793dd14e2e6a05d67 (diff)
downloadcoreutils-cb121d8f3683e81cf51c8f0c7a28dfa58ae68fa8.tar.xz
With -Dlint, make shuf free all heap-allocated storage.
* src/shuf.c (main): Move declaration of input_lines to function scope, and initialize to NULL, so we can free it. [lint]: Free all malloc'd memory. * tests/misc/shuf: Also test shuf's -e and -i options.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/shuf14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/misc/shuf b/tests/misc/shuf
index 760bd4921..a2d5891b2 100755
--- a/tests/misc/shuf
+++ b/tests/misc/shuf
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that shuf randomizes its input.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -51,8 +51,18 @@ cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
sort -n out > out1
cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
+# Exercise shuf's -i option.
+shuf -i 1-100 > out || fail=1
+cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
+sort -n out > out1
+cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
+
+# Exercise shuf's -e option.
+t=`shuf -e a b c d e | sort | fmt`
+test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; }
+
# Before coreutils-6.3, this would infloop.
-# "seq 1860" produces 8193 bytes of output.
+# "seq 1860" produces 8193 (8K + 1) bytes of output.
seq 1860 | shuf > /dev/null || fail=1
(exit $fail); exit $fail