Use which to get programs. Don't create file unless the program or file exists.

This commit is contained in:
Daniel Nichter
2012-01-19 10:46:48 -07:00
parent 6e2b670af6
commit 2412e01aa0
3 changed files with 75 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=18
TESTS=19
TMPFILE="$TEST_TMPDIR/parse-opts-output"
TMPDIR="$TEST_TMPDIR"
@@ -23,12 +23,23 @@ local p="$TMPDIR/collect/2011_12_05"
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
# Even if this system doesn't have all the cmds, collect should still
# create all the default files.
# have created some files for cmds that (hopefully) all systems have.
ls -1 $TMPDIR/collect | sort > $TMPDIR/collect-files
no_diff \
$TMPDIR/collect-files \
$T_LIB_DIR/samples/bash/collect001.txt \
"Default collect files"
# If this system has /proc, then some files should be collected.
# Else, those files should not exist.
if [ -f /proc/diskstats ]; then
cmd_ok \
"grep '[0-9]' $TMPDIR/collect/2011_12_05-diskstats" \
"/proc/diskstats"
else
test -f $TMPDIR/collect/2011_12_05-diskstats
is "$?" "1" "No /proc/diskstats"
fi
cmd_ok \
"grep -q '\-hostname\$' $TMPDIR/collect-files" \
"Collected hostname"
cmd_ok \
"grep -q 'Avail' $p-df" \