Skip to content
Snippets Groups Projects
checkcode.sh 1.86 KiB
Newer Older
nadolski's avatar
nadolski committed
#!/bin/bash
nadolski's avatar
nadolski committed
#set -x # for debugging
nadolski's avatar
nadolski committed
if [ $# -ne 1 ] 
then                    # affiche l'usage
    echo "Missing parameter" 
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
nadolski's avatar
nadolski committed
    echo "Use: $0 overwrite for writing _new files to _ref files" 
nadolski's avatar
nadolski committed
    exit 1
fi

if [ $1 == "help" ] || [ $1 == "--help" ] 
then 
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
    exit 1
fi

if [ $1 != "help" ] && [ $1 != "--help" ] && [ $1 != "compute" ] &&
nadolski's avatar
nadolski committed
 [ $1 != "diff" ] && [ $1 != "overwrite" ]
nadolski's avatar
nadolski committed
then 
    echo "Wrong Parameter"
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
    exit 1
fi

# compute and save result in _new
if [ $1 == "compute" ]
then 
nadolski's avatar
nadolski committed
soltracy Input_checkcode.prm
nadolski's avatar
nadolski committed

CMD='mv'

$CMD nudx.out nudx_new.out
$CMD nudz.out nudz_new.out
$CMD nudp.out nudp_new.out
$CMD flat_file_error.dat flat_file_error_new.dat
$CMD linlat.out linlat_new.out
$CMD chambre.out chambre_new.out
$CMD flat_file.dat flat_file_new.dat
fi

if [ $1 == "diff" ]
then 

CMD='diff'
$CMD nudx_ref.out nudx_new.out
$CMD nudz_ref.out nudz_new.out
$CMD nudp_ref.out nudp_new.out
$CMD flat_file_error_ref.dat flat_file_error_new.dat
$CMD linlat_ref.out linlat_new.out
$CMD chambre_ref.out chambre_new.out
$CMD flat_file_ref.dat flat_file_new.dat
nadolski's avatar
nadolski committed
fi

# overwrite reference file with new files
if [ $1 == "overwrite" ]
then 

echo "$@" | fmt 
echo -n "$0: execute that command line? [yN](N) "
read ans 
case "$ans" in
    [yY]*) 
    CMD='mv'
echo "overwrite reference files"
$CMD nudx_new.out nudx_ref.out
$CMD nudz_new.out nudz_ref.out
$CMD nudp_new.out nudp_ref.out
$CMD flat_file_error_new.dat flat_file_error_ref.dat
$CMD linlat_new.out linlat_ref.out
$CMD chambre_new.out chambre_ref.out
$CMD flat_file_new.dat flat_file_ref.dat
;;
    *|"") echo "$0: NOT executing: $*" | fmt ;;
esac

fi