hw-test/scripts/test-memtester

120 lines
3.1 KiB
Text
Raw Normal View History

2016-12-12 22:46:52 -06:00
#!/bin/bash
2016-12-20 05:05:22 -06:00
source test-variables
SUMMARY=0
if [[ "$1" == "summary" ]] ; then
SUMMARY=plain
elif [[ "$1" == "csv" ]] ; then
SUMMARY=csv
2016-12-20 05:15:31 -06:00
else
if [[ -z $MEM_TESTABLE ]] ; then
source scan-meminfo
fi
CONCURRENCY=`echo $1 | sed 's/[^0-9]//g'`
2016-12-20 05:05:22 -06:00
fi
2016-12-20 05:15:31 -06:00
if [[ -z $OUTPUT_DIR ]] ; then
source scan-dmidecode
2016-12-13 19:52:26 -06:00
fi
2016-12-20 05:05:22 -06:00
DEFAULT_CONCURRENCY=4
[[ -z $CONCURRENCY ]] && CONCURRENCY=$DEFAULT_CONCURRENCY
2016-12-14 19:45:04 -06:00
[[ $CONCURRENCY == 0 ]] && exit 10
if [[ -f $OUTPUT_DIR/memtester.pass ]] ; then
2016-12-21 19:36:45 -06:00
echo -n "Memtester test already ${GRN}PASSED${OFF} on "
2016-12-21 19:36:00 -06:00
cat $OUTPUT_DIR/memtester.pass
# If SUMMARY is set to csv we leave it that way
if [[ "$SUMMARY" == 0 ]] ; then
SUMMARY=plain
fi
fi
2016-12-21 22:52:38 -06:00
FAIL=0
2016-12-20 05:05:22 -06:00
if [[ $SUMMARY == 0 ]] ; then
if [[ -f $OUTPUT_DIR/memtester.fail ]] ; then
2016-12-23 03:42:14 -06:00
echo -n "Previuos failed test faound on "
tail -1 $OUTPUT_DIR/memtester.fail
echo "Running memtester test again..."
fi
2016-12-20 05:05:22 -06:00
MEM_PER_PROC=`echo $(( MEM_TESTABLE / CONCURRENCY )) | sed 's/\..*$//'`
for (( PROC=1; PROC<=$CONCURRENCY; PROC=PROC+1 )) ; do
echo "Process $PROC: testing $MEM_PER_PROC kB with memtester ..."
wrapper-memtester $MEM_PER_PROC $PROC &
sleep 1
2016-12-20 05:05:22 -06:00
done
JOBS_WAITING=$CONCURRENCY
2016-12-20 05:48:03 -06:00
while (( $JOBS_WAITING > 0 )) ; do
sleep 1
2016-12-20 05:05:22 -06:00
JOBS_WAITING=`jobs -r | wc -l`
#echo "Jobs waiting: $JOBS_WAITING"
echo $JOBS_WAITING > /run/memtester.waiting
2016-12-20 05:05:22 -06:00
done
rm -f /run/memtester.waiting
for (( PROC=1; PROC<=$CONCURRENCY; PROC=PROC+1 )) ; do
if [[ -f $OUTPUT_DIR/memtester_$PROC.ret ]] ; then
RET=`cat $OUTPUT_DIR/memtester_$PROC.ret | sed 's/[^0-9]//g'`
if [[ "$RET" == "0" ]] ; then
if [[ -f $OUTPUT_DIR/memtester_$PROC.fail ]] ; then
rm -f $OUTPUT_DIR/memtester_$PROC.ret
fi
else
echo "Process $PROC returned ${RED}$RET${OFF} value"
echo $RET > $OUTPUT_DIR/memtester_$PROC.ret
FAIL=$(( FAIL + 1 ))
fi
else
echo "${RED}Error${OFF}: Process $PROC did not register return value"
exit 16
fi
done
2016-12-20 05:48:03 -06:00
fi
if [[ $FAIL == 0 ]] ; then
if [[ -f $OUTPUT_DIR/memtester.fail ]] ; then
rm -f $OUTPUT_DIR/memtester.fail
fi
date > $OUTPUT_DIR/memtester.pass
else
2016-12-21 19:36:00 -06:00
echo $FAIL > $OUTPUT_DIR/memtester.fail
date >> $OUTPUT_DIR/memtester.fail
fi
# TEST_Container variable exported by tests container process
if [[ -z $TEST_CONTAINER ]] ; then
#snapshot
mkdir -p $SNAPSHOT_D
cp -af $OUTPUT_DIR/* $SNAPSHOT_D/
fi
2016-12-20 05:48:03 -06:00
#echo "summary: $SUMMARY"
if [[ "$SUMMARY" != "0" ]] ; then
2016-12-20 05:05:22 -06:00
if [[ $SUMMARY == plain ]] ; then
2016-12-20 05:15:31 -06:00
echo "=====> MEMTESTER SUMMARY <====="
2016-12-20 05:05:22 -06:00
elif [[ $SUMMARY == csv ]] ; then
2016-12-20 05:15:31 -06:00
echo "=====> MEMTESTER CSV SUMMARY <====="
2016-12-20 05:19:00 -06:00
echo "SERVER|PROCESS|TESTED_MEMORY|DURATION|RESULT|COMMENT" \
2016-12-20 05:05:22 -06:00
> $OUTPUT_DIR/memtester.csv
fi
for (( PROC=1; PROC<=$CONCURRENCY; PROC=PROC+1 )) ; do
if [[ $SUMMARY == plain ]] ; then
if [[ -f $OUTPUT_DIR/memtester_$PROC.result ]] ; then
cat $OUTPUT_DIR/memtester_$PROC.result
fi
elif [[ $SUMMARY == csv ]] ; then
if [[ -f $OUTPUT_DIR/memtester_$PROC.csv ]] ; then
cat $OUTPUT_DIR/memtester_$PROC.csv \
>> $OUTPUT_DIR/memtester.csv
fi
fi
done
if [[ $SUMMARY == csv ]] ; then
2016-12-20 05:15:31 -06:00
cat $OUTPUT_DIR/memtester.csv \
2016-12-22 23:35:03 -06:00
| sed "s/^\([^|]\+\)/${BLD}\1${OFF}/ ; s/OK/$RES_OK/ ; s/FAIL/$RES_FAIL/ ; s/RESULT/$RES_ULT/ "
2016-12-20 05:05:22 -06:00
fi
fi
2016-12-13 19:52:26 -06:00