2009-12-16 12:34:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DEBUG="$1"
|
2009-12-17 18:38:35 +00:00
|
|
|
VERSION=2.54
|
2009-12-16 20:27:09 +00:00
|
|
|
TMP_DIR="ppss"
|
2009-12-17 18:16:02 +00:00
|
|
|
PPSS=ppss
|
|
|
|
PPSS_DIR=ppss_dir
|
2009-12-16 12:34:03 +00:00
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
|
|
|
|
for x in $REMOVEFILES
|
|
|
|
do
|
|
|
|
if [ -e ./$x ]
|
|
|
|
then
|
|
|
|
rm -r ./$x
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-12-16 20:27:09 +00:00
|
|
|
parseJobStatus () {
|
|
|
|
|
|
|
|
TMP_FILE="$1"
|
|
|
|
|
|
|
|
RES=`grep "Status:" "$JOBLOG/$TMP_FILE"`
|
|
|
|
STATUS=`echo "$RES" | awk '{ print $2 }'`
|
|
|
|
echo "$STATUS"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-12-16 12:34:03 +00:00
|
|
|
oneTimeSetUp () {
|
|
|
|
|
|
|
|
NORMALTESTFILES=`echo test-{a..z}`
|
|
|
|
SPECIALTESTFILES="\'file-!@#$%^&*()_+=-0987654321~\' \'file-/\<>?:;'{}[]\' file-/\/\:\/!@#$%^&*()_+=-0987654321~ file-/\<>?:;'{}[] http://www.google.nl ftp://storage.nl"
|
2009-12-17 18:16:02 +00:00
|
|
|
JOBLOG=./$PPSS_DIR/job_log
|
2009-12-16 12:34:03 +00:00
|
|
|
INPUTFILENORMAL=test-normal.input
|
|
|
|
INPUTFILESPECIAL=test-special.input
|
2009-12-17 18:16:02 +00:00
|
|
|
LOCALOUTPUT=ppss_dir/PPSS_LOCAL_OUTPUT
|
2009-12-16 12:34:03 +00:00
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
REMOVEFILES="$INPUTFILENORMAL $INPUTFILESPECIAL $PPSS_DIR test-ppss-*"
|
2009-12-16 12:34:03 +00:00
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
for x in $NORMALTESTFILES
|
|
|
|
do
|
|
|
|
echo "$x" >> "$INPUTFILENORMAL"
|
|
|
|
done
|
|
|
|
|
|
|
|
for x in $SPECIALTESTFILES
|
|
|
|
do
|
|
|
|
echo $x >> "$INPUTFILESPECIAL"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
testVersion () {
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=`./$PPSS -v`
|
2009-12-16 12:34:03 +00:00
|
|
|
|
|
|
|
for x in $RES
|
|
|
|
do
|
|
|
|
echo "$x" | grep [0-9] >> /dev/null
|
|
|
|
if [ "$?" == "0" ]
|
|
|
|
then
|
|
|
|
assertEquals "Version mismatch!" "$VERSION" "$x"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
rename-ppss-dir () {
|
|
|
|
|
|
|
|
TEST="$1"
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
if [ -e "$PPSS_DIR" ] && [ -d "$PPSS_DIR" ] && [ ! -z "$TEST" ]
|
2009-12-16 12:34:03 +00:00
|
|
|
then
|
2009-12-17 18:16:02 +00:00
|
|
|
mv "$PPSS_DIR" test-ppss-"$TEST"
|
2009-12-16 12:34:03 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
oneTimeTearDown () {
|
|
|
|
|
|
|
|
if [ ! "$DEBUG" == "debug" ]
|
|
|
|
then
|
|
|
|
cleanup
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-12-16 20:27:09 +00:00
|
|
|
createDirectoryWithSomeFiles () {
|
|
|
|
|
|
|
|
A="File with Spaces"
|
|
|
|
B="File\With\Slashes"
|
|
|
|
|
|
|
|
mkdir "/tmp/$TMP_DIR"
|
|
|
|
for x in "$A" "$B"
|
|
|
|
do
|
|
|
|
TMP_FILE="/tmp/$TMP_DIR/$x"
|
|
|
|
touch "$TMP_FILE"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
testSpacesInFilenames () {
|
|
|
|
|
|
|
|
createDirectoryWithSomeFiles
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'ls -alh ' >> /dev/null ; } 2>&1 )
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
if [ ! "$?" == "0" ]
|
|
|
|
then
|
|
|
|
echo "RES IS $RES"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "SUCCESS" $JOBLOG/* >> /dev/null 2>&1
|
|
|
|
assertEquals "Found error with space in filename $TMP_FILE" "0" "$?"
|
|
|
|
|
|
|
|
rm -rf "/tmp/$TMP_DIR"
|
|
|
|
rename-ppss-dir $FUNCNAME
|
|
|
|
}
|
|
|
|
|
2009-12-16 12:34:03 +00:00
|
|
|
testSpecialCharacterHandling () {
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -f "$INPUTFILESPECIAL" -c 'echo ' >> /dev/null ; } 2>&1 )
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
if [ ! "$?" == "0" ]
|
|
|
|
then
|
|
|
|
echo "RES IS $RES"
|
|
|
|
fi
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=`find ppss_dir/PPSS_LOCAL_OUTPUT | wc -l | sed 's/\ //g'`
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "To many lock files..." "7" "$RES"
|
|
|
|
|
|
|
|
RES1=`ls -1 $JOBLOG`
|
|
|
|
RES2=`ls -1 $LOCALOUTPUT`
|
|
|
|
|
|
|
|
assertEquals "RES1 $RES1 is not the same as RES2 $RES2" "$RES1" "$RES2"
|
|
|
|
|
|
|
|
rename-ppss-dir $FUNCNAME
|
|
|
|
}
|
|
|
|
|
2009-12-16 20:27:09 +00:00
|
|
|
testSkippingOfProcessedItems () {
|
|
|
|
|
|
|
|
createDirectoryWithSomeFiles
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'echo ' >> /dev/null ; } 2>&1 )
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'echo ' >> /dev/null ; } 2>&1 )
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
grep -i skip ./$PPSS_dir/* >> /dev/null 2>&1
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "Skipping of items went wrong." 0 "$?"
|
|
|
|
|
|
|
|
rename-ppss-dir $FUNCNAME-1
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -f $INPUTFILESPECIAL -c 'echo ' >> /dev/null ; } 2>&1 )
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
RES=$( { ./$PPSS -f $INPUTFILESPECIAL -c 'echo ' >> /dev/null ; } 2>&1 )
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
assertNull "PPSS retured some errors..." "$RES"
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
grep -i skip ./$PPSS_dir/* >> /dev/null 2>&1
|
2009-12-16 20:27:09 +00:00
|
|
|
assertEquals "Skipping of items went wrong." 0 "$?"
|
|
|
|
|
|
|
|
rm -rf "/tmp/$TMP_DIR"
|
|
|
|
rename-ppss-dir $FUNCNAME-2
|
|
|
|
}
|
|
|
|
|
2009-12-16 12:34:03 +00:00
|
|
|
testExistLogFiles () {
|
|
|
|
|
2009-12-17 18:16:02 +00:00
|
|
|
./$PPSS -f "$INPUTFILENORMAL" -c 'echo "$ITEM"' >> /dev/null
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
|
|
|
|
for x in $NORMALTESTFILES
|
|
|
|
do
|
|
|
|
assertTrue "[ -e $JOBLOG/$x ]"
|
|
|
|
done
|
|
|
|
|
|
|
|
rename-ppss-dir $FUNCNAME
|
|
|
|
}
|
|
|
|
|
|
|
|
getStatusOfJob () {
|
|
|
|
|
|
|
|
EXPECTED="$1"
|
|
|
|
|
|
|
|
if [ "$EXPECTED" == "SUCCESS" ]
|
|
|
|
then
|
2009-12-17 18:16:02 +00:00
|
|
|
./$PPSS -f "$INPUTFILENORMAL" -c 'echo ' >> /dev/null
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
elif [ "$EXPECTED" == "FAILURE" ]
|
|
|
|
then
|
2009-12-17 18:16:02 +00:00
|
|
|
./$PPSS -f "$INPUTFILENORMAL" -c 'thiscommandfails ' >> /dev/null
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for x in $NORMALTESTFILES
|
|
|
|
do
|
2009-12-16 20:27:09 +00:00
|
|
|
STATUS=`parseJobStatus "$x"`
|
2009-12-16 12:34:03 +00:00
|
|
|
assertEquals "FAILED WITH STATUS $STATUS." "$EXPECTED" "$STATUS"
|
|
|
|
done
|
|
|
|
|
|
|
|
rename-ppss-dir "$FUNCNAME-$EXPECTED"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
testErrorHandlingOK () {
|
|
|
|
|
|
|
|
getStatusOfJob SUCCESS
|
|
|
|
}
|
|
|
|
|
|
|
|
testErrorHandlingFAIL () {
|
|
|
|
|
|
|
|
getStatusOfJob FAILURE
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. ./shunit2
|