Skip to content
Snippets Groups Projects
Commit 3a41aff5 authored by lche0021's avatar lche0021
Browse files

bug fix, more useful help message, and run smoke_test on all softwares specified by -a

parent f3241424
No related branches found
No related tags found
2 merge requests!464Fix listdeps,!442Smoke test
#!/bin/bash #!/bin/bash
# each application will create a folder under OUTPUT_DIR # 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 if [ -z $OUTPUT_DIR ]; then
NUM_MODULE=${2:-30} 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 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_success=0
declare -i num_failed=0 declare -i num_failed=0
declare -i num_notest=0 declare -i num_notest=0
declare -i minor_error=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 # function generate_software_usage {
echo $REPORT # SOFTWARE_USAGE_PATH=software_usage.txt
echo '' > $REPORT # if [ ! -f $SOFTWARE_USAGE_PATH ]; then
USAGE_REPORT=software_usage.txt # ./software_usage $SOFTWARE_USAGE_PATH
if [ ! -f $USAGE_REPORT ]; then # fi
./software_usage $USAGE_REPORT # }
fi
generate_output_directory
declare -a modules
failed_modules=()
IFS_orig=$IFS IFS_orig=$IFS
IFS=$'\n' 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) name=$(cut -f1 -d' ' <<< $m)
ver=$(cut -f2 -d' ' <<< $m) ver=$(cut -f2 -d' ' <<< $m)
printf "\n\n=========================\n" printf "\n\n=========================\n"
if [ -z $name ]; then if [ -z $name ]; then
continue continue
fi fi
echo "Testing $name/$ver ... " echo "Testing $name/$ver ... "
module purge
module load $name/$ver module load $name/$ver
mkdir -p $OUTPUT_DIR/$name mkdir -p $OUTPUT_DIR/$name
echo '' > $OUTPUT_DIR/$name/$ver echo '' > $OUTPUT_DIR/$name/$ver
...@@ -54,32 +121,35 @@ for i in $(head -n $NUM_MODULE $USAGE_REPORT); do ...@@ -54,32 +121,35 @@ for i in $(head -n $NUM_MODULE $USAGE_REPORT); do
num_notest+=1 num_notest+=1
else else
ALL_EXEC=$(find $TESTCASE_DIR/$name -maxdepth 1 -executable -type f) ALL_EXEC=$(find $TESTCASE_DIR/$name -maxdepth 1 -executable -type f)
module_failed=1 module_failed=false
for t_case in ${ALL_EXEC}; do for t_case in ${ALL_EXEC}; do
if [ $i == 'bintest' ] && ! $BINTEST;then break;fi if [ $i == 'bintest' ] && ! $BINTEST;then break;fi
orig_dir=$PWD orig_dir=$PWD
cd $(dirname $t_case) # in case the testcase need to compile some source from the directory 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=$? exitcode=$?
cd $orig_dir cd $orig_dir
if [ $exitcode -eq 0 ]; then if [ $exitcode -eq 0 ]; then
num_success+=1 num_success+=1
else else
if [ $exitcode -eq 1 ]; then if [ $exitcode -eq 1 ]; then
minor_error+=1 minor_error+=1
else else
num_failed+=1 num_failed+=1
module_failed=0 module_failed=true
fi fi
echo "$m return non-zero exitcode $exitcode for testcase $t_case" 2>&1 | tee -a $REPORT echo "$m return non-zero exitcode $exitcode for testcase $t_case" 2>&1 | tee -a $REPORT
fi fi
done done
if [ module_failed ]; then if $module_failed ; then
echo "$name/$ver" >> $OUTPUT_DIR/failed_modules.txt echo "$name/$ver failed"
echo "$name/$ver" >> $FAILED_MODULE_LOGS
fi fi
fi fi
module purge module unload $name/$ver
printf "Done" printf "Done"
done done
IFS=$IFS_orig IFS=$IFS_orig
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment