| #!/bin/bash |
| |
| # Tests CPU/DMA hitting on memory |
| |
| # Copyright (C) 2003-2006 IBM |
| # |
| # This program is free software; you can redistribute it and/or |
| # modify it under the terms of the GNU General Public License as |
| # published by the Free Software Foundation; either version 2 of the |
| # License, or (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, but |
| # WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| # General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program; if not, write to the Free Software |
| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| # 02111-1307, USA. |
| |
| |
| # Can we find the script? |
| if [ ! -f "$POUNDER_OPTDIR/memtest.sh" ]; then |
| echo "Can't find memtest.sh; did you run Install?" > /dev/tty |
| exit -1 |
| fi |
| |
| # How much RAM do we have? |
| RAM=`cat /proc/meminfo | grep MemTotal | awk -F " " '{print $2}'` |
| SPACE_REQUIRED=`expr $RAM \* 2` |
| |
| # Do we have enough space? |
| MEMTESTDIR="$POUNDER_TMPDIR/memtest/" |
| rm -rf "$MEMTESTDIR" |
| mkdir -p "$MEMTESTDIR" |
| FREE_SPACE=`df -k -P "$MEMTESTDIR" | tail -1 | awk -F " " '{print $4}'` |
| if [ "$FREE_SPACE" -lt "$SPACE_REQUIRED" ]; then |
| echo "Insufficient space; not running memtest." |
| exit -1 |
| fi |
| |
| # Did we see any failures? |
| LOGFILE=/proc/$$/fd/1 |
| OLD_ERRORS=`egrep -ic "(err|fail|invalid|cannot|denied|diff)" $LOGFILE` |
| |
| # Run the test |
| cd "$POUNDER_OPTDIR" |
| NR_PASSES=2 TEST_DIR="$MEMTESTDIR" SOURCE_FILE="$POUNDER_OPTDIR/linux-2.6.18.tar.gz" ./memtest.sh |
| |
| # Now clean up |
| rm -rf "$POUNDER_TMPDIR/memtest/" |
| |
| # Did we see any failures? |
| NEW_ERRORS=`egrep -ic "(err|fail|invalid|denied|cannot|diff)" $LOGFILE` |
| ERRORS=$((NEW_ERRORS - OLD_ERRORS)) |
| if [ $ERRORS -eq 255 ]; then |
| ERRORS=254 |
| fi |
| exit $ERRORS |
| |