#!/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 [[ $SUMMARY == 0 ]] ; then 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 ..." #memtester ${MEM_TESTABLE}K 1 > $OUTPUT_DIR/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" done fi #snapshot mkdir -p $SNAPSHOT_D cp -af $OUTPUT_DIR/* $SNAPSHOT_D/ #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