...
 
Commits (4)
This diff is collapsed.
#!/bin/bash
# NUM_MODULE does not necessarily corresponds to the output of `ls -l $TESTCASE_DIR | wc -l` because
# 1. one folder is created for each software but NUM_MODULE pick combinations of from software/version
# 1. one folder is created for each software but NUM_MODULE pick combinations of from software/version
# 2. if a software does not modify PATH variable then there is no bintest generated for them, the number of those softwares are printed at the end
NUM_MODULE=${1:-100}
TESTCASE_DIR='./tests'
USAGE_REPORT=software_usage.txt
if [ ! -f $USAGE_REPORT ]; then
software_usage $USAGE_REPORT
fi
APPLICATION_LIST='./application_list.txt'
# USAGE_REPORT=software_usage.txt
# if [ ! -f $USAGE_REPORT ]; then
# software_usage $USAGE_REPORT
# fi
echo '#!/bin/bash
name=$( realpath $0 | xargs dirname | xargs basename )
ver=${1:-"default"}
......@@ -18,7 +18,7 @@ bin_dirs=$(module show $name/$ver 2>&1 | sed -n "s/.* PATH \(.*\)/\1/p")
NAME_EXEC_EXIST=false
for bin in $bin_dirs; do
for i in $(find $bin -maxdepth 1 -executable -type f ); do
if [[ $(basename $i) == $name ]]; then
if [[ $(basename $i) == $name ]]; then
$i --version;
exit $?
fi
......@@ -27,15 +27,15 @@ done
' > $TESTCASE_DIR/bintest
echo "Starting generate bintest for $NUM_MODULE softwares"
echo "Starting generate bintest for $NUM_MODULE softwares"
declare -i NUM_LIB=0
declare -i GENERATED_NUM=0
IFS_orig=$IFS
IFS=$'\n'
for i in $(head -n $NUM_MODULE $USAGE_REPORT); do
m=$(sed -n 's/\(.*\)\/\(.*\) - \(.*\)/\1 \2/p' <<< $i)
for i in $(head -n $NUM_MODULE $APPLICATION_LIST); do
m=$(sed -n 's/\(.*\)\/\(.*\)/\1 \2/p' <<< $i)
name=$(cut -f1 -d' ' <<< $m)
ver=$(cut -f2 -d' ' <<< $m)
MODIFIED_PATH=$(module show $name/$ver 2>&1 | sed -n 's/.* PATH \(.*\)/\1/p')
......
#!/bin/bash
TARGET_MODULEPATH="/usr/local/Modules/modulefiles"
OUTPUT_PATH="application_list.txt"
echo "" > $OUTPUT_PATH
MODULEPATH=$TARGET_MODULEPATH module avail -t 2>&1 | python -c "
import sys
with open('$OUTPUT_PATH', 'w') as fout:
for line in sys.stdin:
linelist = line.split('/')
if len(linelist) != 2:
continue
linelist[-1] = linelist[-1].replace('(default)','')
fout.write('/'.join(linelist))
"
\ No newline at end of file
#!/bin/bash
# each application will create a folder under OUTPUT_DIR
OUTPUT_DIR=${1:-output_dir}
declare -i NUM_MODULE
declare -i DEFAULT_NUM_MODULE
declare -i TIMEOUT
declare -i DEFAULT_TIMEOUT
DEFAULT_OUTPUT_DIR='./output_dir'
DEFAULT_NUM_MODULE=100
DEFAULT_TESTCASE_DIR='./tests'
DEFAULT_TIMEOUT=10
DEFAULT_APPLICATION_LIST='./application_list.txt'
function usage {
echo "Run smoke test"
echo "Usage: $0"
echo " -a <list of applications to test>. This should point to a file with lines of '<name>/<version>', it can be generated using either generate_modules_list or software_usage.default: $DEFAULT_APPLICATION_LIST"
echo " -n <number of modules to test>. Specify a large number to test all softwares, default: $DEFAULT_NUM_MODULE"
echo " -o <output directory>, Output file will be generated at OUTPUT_DIR/report.txt, default: $DEFAULT_OUTPUT_DIR"
echo " -t <testcases directories>.Testcases will be loaded from this directory. default: $DEFAULT_TESTCASE_DIR"
echo " -T <timout period in seconds>, default: $DEFAULT_TIMEOUT"
exit 1
}
while getopts ":n:a:o:t:T:" opt; do
case "$opt" in
a)
APPLICATION_LIST=$OPTARG
;;
o)
OUTPUT_DIR="$OPTARG"
;;
n)
NUM_MODULE=$OPTARG
;;
t)
TESTCASE_DIR=$OPTARG
;;
T)
TIMEOUT=$OPTARG
;;
*)
usage
;;
esac
done
if [ -z $APPLICATION_LIST ]; then
APPLICATION_LIST=$(realpath $DEFAULT_APPLICATION_LIST)
fi
# select top 50 most used module by default
NUM_MODULE=${2:-30}
if [ -z $OUTPUT_DIR ]; then
OUTPUT_DIR=$(realpath $DEFAULT_OUTPUT_DIR)
fi
if [ -z $NUM_MODULE ]; then
NUM_MODULE=$DEFAULT_NUM_MODULE
fi
if [ -z $TESTCASE_DIR ]; then
TESTCASE_DIR=$(realpath $DEFAULT_TESTCASE_DIR)
fi
if [ -z $TIMEOUT]; then
TIMEOUT=$DEFAULT_TIMEOUT
fi
declare -i TIMELIMIT
BINTEST=true
TIMELIMIT=10
TESTCASE_DIR=$(realpath './tests')
OUTPUT_DIR=$(realpath $OUTPUT_DIR)
REPORT=$OUTPUT_DIR/'report.txt'
REPORT="$OUTPUT_DIR/report.txt"
FAILED_MODULE_LOGS="$OUTPUT_DIR/failed_modules.txt"
echo '' > $FAILED_MODULE_LOGS
echo '' > $REPORT
declare -i num_success=0
declare -i num_failed=0
declare -i num_notest=0
declare -i minor_error=0
function generate_output_directory {
mkdir -p $OUTPUT_DIR
touch $REPORT
echo '' > $REPORT
echo "Test report created at $REPORT"
}
mkdir -p $OUTPUT_DIR
touch $REPORT
echo $REPORT
echo '' > $REPORT
USAGE_REPORT=software_usage.txt
if [ ! -f $USAGE_REPORT ]; then
./software_usage $USAGE_REPORT
fi
# function generate_software_usage {
# SOFTWARE_USAGE_PATH=software_usage.txt
# if [ ! -f $SOFTWARE_USAGE_PATH ]; then
# ./software_usage $SOFTWARE_USAGE_PATH
# fi
# }
generate_output_directory
declare -a modules
failed_modules=()
IFS_orig=$IFS
IFS=$'\n'
for i in $(head -n $NUM_MODULE $USAGE_REPORT); do
m=$(sed -n 's/\(.*\)\/\(.*\) - \(.*\)/\1 \2/p' <<< $i)
for i in $(head -n $NUM_MODULE $APPLICATION_LIST); do
# m=$(sed -n 's/\(.*\)\/\(.*\) - \(.*\)/\1 \2/p' <<< $i)
m=$(sed -n 's/\(.*\)\/\(.*\)/\1 \2/p' <<< $i)
name=$(cut -f1 -d' ' <<< $m)
ver=$(cut -f2 -d' ' <<< $m)
printf "\n\n=========================\n"
if [ -z $name ]; then
continue
fi
echo "Testing $name/$ver ... "
module purge
module load $name/$ver
mkdir -p $OUTPUT_DIR/$name
echo '' > $OUTPUT_DIR/$name/$ver
......@@ -54,32 +121,35 @@ for i in $(head -n $NUM_MODULE $USAGE_REPORT); do
num_notest+=1
else
ALL_EXEC=$(find $TESTCASE_DIR/$name -maxdepth 1 -executable -type f)
module_failed=1
module_failed=false
for t_case in ${ALL_EXEC}; do
if [ $i == 'bintest' ] && ! $BINTEST;then break;fi
orig_dir=$PWD
cd $(dirname $t_case) # in case the testcase need to compile some source from the directory
timeout $TIMELIMIT $t_case $ver &> $OUTPUT_DIR/$name/$ver
timeout $TIMEOUT $t_case $ver &> $OUTPUT_DIR/$name/$ver
exitcode=$?
cd $orig_dir
if [ $exitcode -eq 0 ]; then
num_success+=1
else
if [ $exitcode -eq 1 ]; then
if [ $exitcode -eq 1 ]; then
minor_error+=1
else
num_failed+=1
module_failed=0
module_failed=true
fi
echo "$m return non-zero exitcode $exitcode for testcase $t_case" 2>&1 | tee -a $REPORT
fi
done
if [ module_failed ]; then
echo "$name/$ver" >> $OUTPUT_DIR/failed_modules.txt
if $module_failed ; then
echo "$name/$ver failed"
echo "$name/$ver" >> $FAILED_MODULE_LOGS
fi
fi
module purge
module unload $name/$ver
printf "Done"
done
IFS=$IFS_orig
......