[svn] / ecrypt / trunk / scripts / run  

svn: ecrypt/trunk/scripts/run

File: [svn] / ecrypt / trunk / scripts / run (download)
Revision: 50, Thu Aug 4 20:12:18 2005 UTC (7 years, 9 months ago) by cdecanni
File size: 4630 byte(s)
* the script recursively crawls through the directory tree.
#!/bin/sh

vectors=unverified.test-vectors;

mk ()
{
    make comp="$comp" opt="$opt" arch="$arch" var="$var" $1; 
}

run ()
{ 
    if [ -e ./reports/info_$id ]; then
	echo "info_$id exists. continuing";
	return;
    fi

    if [ -e ./reports/errors_$id ]; then
	echo "errors_$id exists. continuing";
	return;
    fi

    if [ -e ./reports/speed_$id ]; then
	echo "speed_$id exists. continuing";
	return;
    fi

    echo "compiling $id";
	      
    make comp="$comp" clean &> /dev/null;

    cat > ./reports/info_current <<EOF
DATE:
-------------------------------------------------------------------------------
$(date)

CPU:
-------------------------------------------------------------------------------
$(cat /proc/cpuinfo)

COMPILER:
-------------------------------------------------------------------------------
$(mk version 2>&1)

COMPILATION:
-------------------------------------------------------------------------------
make comp="$comp" opt="$opt" arch="$arch" var="$var"

$(mk 2>&1)

EXECUTABLE:
-------------------------------------------------------------------------------
EOF

    if mk -q &> /dev/null; then
	hash=$(mk hash 2> /dev/null);
    else
	echo "none" >> ./reports/info_current;
	mv ./reports/info_current ./reports/errors_$id;
	echo "compilation failed (see ./reports/errors_$id)";
	return;
    fi

    matches=$(cd ./reports; grep -l "$hash" {info,speed}_*-*-* 2> /dev/null);

    echo "$hash" >> ./reports/info_current;

    if [ -n "$matches" ]; then
	echo "executable has been checked before (see $(echo $matches))";
	mv ./reports/info_current ./reports/info_$id;
	return;
    fi

    test=$(mk command);

    echo "generating test vectors";

    $test -v | grep -v "Elapsed time\|There were" > ./reports/vectors_$id;

    if diff -waq ./reports/vectors_$id $vectors > /dev/null; then
	echo "vectors match. deleting vectors_$id";
	rm -f ./reports/vectors_$id;
    else
	if diff -wad ./reports/vectors_$id $vectors \
	    | grep '<' > /dev/null; then
	    echo "error: vectors do not match. check ./reports/vectors_$id";
	    mv ./reports/info_current ./reports/info_$id;
	    return;
	else
	    echo "warning: vectors are incomplete but match";
	    rm -f ./reports/vectors_$id;
	fi
    fi

    while true; do
	cpu_speed=$(awk '/cpu MHz/ { print $4; exit; }' /proc/cpuinfo);
	
	echo "running speed measurements on $cpu_speed MHz CPU";

	cat > ./reports/speed_$id <<EOF
$($test -c $cpu_speed -s -k -p)

*******************************************************************************

$(cat ./reports/info_current)
EOF

	current_speed=$(awk '/cpu MHz/ { print $4; exit; }' /proc/cpuinfo);

	if [ "$cpu_speed" = "$current_speed" ]; then
	    break;
	else
	    echo "warning: CPU speed changed. restarting";
	fi
    done

    rm -f ./reports/info_current
}

dir=$1;

if [ -z "$dir" ]; then
    dir=.;
fi

echo "entering directory $dir";

# first recursively process all subdirectories

for i in "$dir"/*; do
    if [ -d "$i" ]; then
	$0 "$i";
    fi
done

cd "$dir";

if [ ! -e unverified.test-vectors ]; then
    exit;
fi

mkdir -p reports;

if true; then
    comp=gcc;

    for cpu in \
	i386 i486 i586 pentium-mmx i686 pentium2 pentium3 \
	pentium-m pentium4 prescott nocona \
	k6 k6-2 athlon athlon-4 k8; do 
      arch="-march=$cpu"; opt=; var=;
      
      if mk check &> /dev/null; then
	  for level in 0 1 2 3 s; do  
	      opt="-fomit-frame-pointer -O$level"; var=;
	      
	      if mk check &> /dev/null; then
		  for variant in 1 2 3 4 5 6 7 8 9 10; do	      
		      var="$variant";
		      
		      if mk check &> /dev/null; then
			  id="$comp-$variant-$level-$cpu";
			  run;
		      fi
		  done
	      fi
	  done
      fi
    done

    mk clean;
fi

if true; then
    comp=icc;

    for cpu in K W N P B; do 
	arch="-x$cpu"; opt=; var=;

	if mk check &> /dev/null; then
	    for level in 0 1 2 3 s; do
		opt="-O$level"; var=;
		
		if mk check &> /dev/null; then
		    for variant in 1 2 3 4 5 6 7 8 9 10; do
			var="$variant";
			
			if mk check &> /dev/null; then
			    id="$comp-$variant-$level-$cpu";
			    run;
			fi
		    done
		fi
	    done
	fi
    done

    mk clean;
fi

if true; then
    comp=msvc;

    for cpu in 3 4 5 6 7 B; do 
	arch="/G$cpu"; opt=; var=;

	if mk check &> /dev/null; then
	    for variant in 1 2 3 4 5 6 7 8 9 10; do
		var="$variant"; opt=;

		if mk check &> /dev/null; then
		    opt="/Ox";

		    if mk check &> /dev/null; then
			id="$comp-$variant-x-$cpu";
			run;
		    fi

		    opt="/Ox /Gr";

		    if mk check &> /dev/null; then
			id="$comp-$variant-xr-$cpu";
			run;
		    fi
		fi
	    done
	fi
    done

    make comp="$comp" clean;
fi

eSTREAM Project

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help