#!/bin/bash source test-variables SUMMARY=0 if [[ "$1" == "summary" ]] ; then SUMMARY=plain elif [[ "$1" == "csv" ]] ; then SUMMARY=csv else if [[ -z $MEM_TESTABLE ]] ; then source scan-meminfo fi CONCURRENCY=`echo $1 | sed 's/[^0-9]//g'` fi if [[ -z $OUTPUT_DIR ]] ; then source scan-dmidecode fi DEFAULT_CONCURRENCY=4 [[ -z $CONCURRENCY ]] && CONCURRENCY=$DEFAULT_CONCURRENCY [[ $CONCURRENCY == 0 ]] && exit 10 if [[ -f $OUTPUT_DIR/memtester.pass ]] ; then echo -n "Memtester test already ${GRN}PASSED${OFF} on " cat $OUTPUT_DIR/memtester.pass # If SUMMARY is set to csv we leave it that way if [[ "$SUMMARY" == 0 ]] ; then SUMMARY=plain fi fi FAIL=0 if [[ $SUMMARY == 0 ]] ; then if [[ -f $OUTPUT_DIR/memtester.fail ]] ; then echo "Previuos failed test faound on " tail -1 $OUTPUT_DIR/memtester.fail echo "Running memtester test again..." fi 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 done JOBS_WAITING=$CONCURRENCY while (( $JOBS_WAITING > 0 )) ; do sleep 1 JOBS_WAITING=`jobs -r | wc -l` #echo "Jobs waiting: $JOBS_WAITING" echo $JOBS_WAITING > /run/memtester.waiting 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 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 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 #echo "summary: $SUMMARY" if [[ "$SUMMARY" != "0" ]] ; then if [[ $SUMMARY == plain ]] ; then echo "=====> MEMTESTER SUMMARY <=====" elif [[ $SUMMARY == csv ]] ; then echo "=====> MEMTESTER CSV SUMMARY <=====" echo "SERVER|PROCESS|TESTED_MEMORY|DURATION|RESULT|COMMENT" \ > $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 cat $OUTPUT_DIR/memtester.csv \ | sed "s/^\([^|]\+\)/${BLD}\1${OFF}/ ; s/OK/${GRN}OK${OFF}/ ; s/FAIL/${RED}FAIL${OFF}/ ; s/RESULT/${BLD}RESULT${OFF}/ " fi fi