Skip to content

Commit

Permalink
- Updated FS variable assignment in tests/2exec/diff_numeric.awk to b…
Browse files Browse the repository at this point in the history
…e compatible with mawk (used as default awk on Ubuntu, problem reported by Jussi Leinonen). Tested to work using gawk and mawk under Windows.

- Also updated comp2exec for easy change of particular awk program to use (only change in one place is now required). Should be easier in the future to diagnose similar problems.
  • Loading branch information
myurkin committed Mar 4, 2013
1 parent 2498da0 commit db46515
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions tests/2exec/comp2exec
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ ALLNAME=all # denotes that all output files should be compared (in suite file)
TMPREF=ref.tmp # temporary files for text processing
TMPTEST=test.tmp

# If you encounter errors of awk, try changing the following to gawk
AWK=awk

function cleanfile {
# Processes file $1 and stores the result in $2. Basic step is removing lines matching regexp $3. Additional optional
# step is cutting the end of the file starting from line matching regexp $4.
if [ -n "$4" ]; then
awk "BEGIN{p=1} /$4/{p=0} p" $1 | grep -v -E -e "$3" > $2
$AWK "BEGIN{p=1} /$4/{p=0} p" $1 | grep -v -E -e "$3" > $2
else
grep -v -E -e "$3" $1 > $2
fi
Expand All @@ -102,13 +105,13 @@ function numdiff {
# Performs comparison of two files, ignoring differences in numerical values smaller than absolute and relative
# tolerances, specified by variables atol and rtol (-log of real value). The main logic is inside awk script
# 'diff_numeric'.
diff $1 $2 | awk -f diff_numeric.awk -v abs_tol=1e-$atol -v rel_tol=1e-$rtol - >&2
diff $1 $2 | $AWK -f diff_numeric.awk -v abs_tol=1e-$atol -v rel_tol=1e-$rtol - >&2
}
function numigndiff {
# Same as numdiff, but additionally ignores certain differences in input files - see description of function cleanfile
cleanfile $1 $TMPREF "$3" "$4"
cleanfile $2 $TMPTEST "$3" "$4"
diff $TMPREF $TMPTEST | awk -f diff_numeric.awk -v abs_tol=1e-$atol -v rel_tol=1e-$rtol - >&2
diff $TMPREF $TMPTEST | $AWK -f diff_numeric.awk -v abs_tol=1e-$atol -v rel_tol=1e-$rtol - >&2
}
function igndiff {
# Performs comparison of two files, ignoring differences in lines matching regexp $3 and all the differences after the
Expand Down
4 changes: 3 additions & 1 deletion tests/2exec/diff_numeric.awk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ BEGIN {
i1=0
i2=0
number="^[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?$"
FS="[[:space:]=,{}()[\\]]"
# FS="[[:space:]=,{}()[\\]]"
# A more robust assignment of FS is used to be compatible with mawk
FS="[ \\t=,{}\\(\\)[\\]]"
if (abs_tol !~ number) abs_tol=1e-15
if (rel_tol !~ number) rel_tol=1e-8
}
Expand Down

0 comments on commit db46515

Please sign in to comment.