Home | History | Annotate | Download | only in build_scripts
      1 #!/bin/bash -f
      2 
      3 # Build lowmem exhaustion/corruption tester
      4 
      5 # Copyright (C) 2003-2006 IBM
      6 #
      7 # This program is free software; you can redistribute it and/or
      8 # modify it under the terms of the GNU General Public License as
      9 # published by the Free Software Foundation; either version 2 of the
     10 # License, or (at your option) any later version.
     11 #
     12 # This program is distributed in the hope that it will be useful, but
     13 # WITHOUT ANY WARRANTY; without even the implied warranty of
     14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 # General Public License for more details.
     16 #
     17 # You should have received a copy of the GNU General Public License
     18 # along with this program; if not, write to the Free Software
     19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     20 # 02111-1307, USA.
     21 
     22 
     23 # How much RAM do we have?
     24 RAM=`cat /proc/meminfo | grep MemTotal | awk -F " " '{print $2}'`
     25 SPACE_REQUIRED=`expr $RAM \* 2`
     26 
     27 # Do we have enough space?
     28 MEMTESTDIR="$POUNDER_TMPDIR/memtest/"
     29 rm -rf "$MEMTESTDIR"
     30 mkdir -p "$MEMTESTDIR"
     31 FREE_SPACE=`df -k -P "$MEMTESTDIR" | tail -n 1 | awk -F " " '{print $4}'`
     32 if [ "$FREE_SPACE" -lt "$SPACE_REQUIRED" ]; then
     33         echo "[memtest] Insufficient space. Free space: $FREE_SPACE kB. Space required: $SPACE_REQUIRED kB. Not building memtest."
     34         exit -1
     35 fi
     36 
     37 cd "$POUNDER_OPTDIR"
     38 
     39 # Download a script and parse out the junk we don't want.
     40 if [ ! -f "memtest.sh" ]; then
     41 	if [ $USE_CACHE -eq 1 ]; then
     42 		wget "${POUNDER_CACHE}memtest.shtml"
     43 	fi
     44 	if [ ! -f "memtest.shtml" ]; then
     45 		wget "http://people.redhat.com/dledford/memtest.shtml"
     46 	fi
     47 	IN_BLOCK=0
     48 
     49 	if [ ! -f "memtest.shtml" ]; then
     50 		echo "[memtest] Could not download memtest.shtml.  Aborting!"
     51 		exit -1
     52 	fi
     53 
     54 	(cat memtest.shtml | while read f; do
     55 		echo "$f" | grep -q BLOCKQUOTE
     56 		if [ "$?" -eq 0 ]; then
     57 			if [ "$IN_BLOCK" -eq 0 ]; then
     58 				IN_BLOCK=1
     59 			else
     60 				IN_BLOCK=0
     61 			fi
     62 		else
     63 			if [ "$IN_BLOCK" -eq 1 ]; then
     64 				echo "$f"
     65 			fi
     66 		fi
     67 	done) | sed -e 's/\/bin\/bash2/\/bin\/bash/g' > memtest.sh
     68 	chmod a+x memtest.sh
     69 	patch -p0 < "$POUNDER_SRCDIR/memtest.patch"
     70 	rm -rf memtest.shtml
     71 fi
     72