Commit b012700f authored by Robert Schmidt's avatar Robert Schmidt Committed by Jaroslava Fiedlerova

Fix analyze-timing.sh for mawk compatibility

The awk script in analyze-timing.sh used syntax that works with gawk but fails
on systems where mawk is the default implementation, producing errors such as:

awk: /dev/fd/3: line 6: syntax error at or near ,
-- test command finished with SIGPIPE

Concretely, the match(text, pattern, variable) function does not exist
in mawk, as it cannot capture matches in variables. Work around by
substituing strings, and force a numeric comparison.
parent 3e797743
...@@ -28,6 +28,13 @@ while [ $# -gt 0 ]; do ...@@ -28,6 +28,13 @@ while [ $# -gt 0 ]; do
# RC to signal error). In both cases, the result is logged in an array to # RC to signal error). In both cases, the result is logged in an array to
# output at the end of the script. # output at the end of the script.
# #
# To search for the number, first substr() returns what has been matched
# (PATTERN + number), and sub() deletes PATTERN and whitespace, resulting in
# the number (measurement). To force number into a numeric context, we add 0,
# as awk would otherwise compare a string to a number (example:
# gawk 'BEGIN { meas = "117"; if (meas > 96) { } else { print "fail";}}'
# printfs "fail").
#
# Example: pattern "PHY proc tx", condition "< 200" # Example: pattern "PHY proc tx", condition "< 200"
# The awk script tries to match every line for "PHY proc tx _NUMBER_" (where # The awk script tries to match every line for "PHY proc tx _NUMBER_" (where
# number is a decimal), and compares _NUMBER_ against condition "< 200", # number is a decimal), and compares _NUMBER_ against condition "< 200",
...@@ -35,14 +42,16 @@ while [ $# -gt 0 ]; do ...@@ -35,14 +42,16 @@ while [ $# -gt 0 ]; do
# If the condition holds, will set "CHECK PHY proc tx _NUMBER_ < 200 SUCCESS". # If the condition holds, will set "CHECK PHY proc tx _NUMBER_ < 200 SUCCESS".
# If the condition fails, will set "CHECK PHY proc tx _NUMBER_ < 200 FAIL". # If the condition fails, will set "CHECK PHY proc tx _NUMBER_ < 200 FAIL".
SCRIPT+=' SCRIPT+='
match($0, /'${PATTERN}' +([0-9]+(\.[0-9]+)?)/, n) { match($0, /'${PATTERN}' +([0-9]+(\.[0-9]+)?)/) {
if (n[1] '${COND}') { meas = substr($0, RSTART, RLENGTH);
sub(/'${PATTERN}' +/, "", meas);
if ((meas+0) '${COND}') {
r = "SUCCESS"; r = "SUCCESS";
} else { } else {
r = "FAIL"; r = "FAIL";
RC = 1; RC = 1;
} }
RESULTS['${NUM}']=sprintf("CHECK %-35s %7.2f %-8s %s", "'${PATTERN}'", n[1], " '${COND}'", r); RESULTS['${NUM}']=sprintf("CHECK %-35s %7.2f %-8s %s", "'${PATTERN}'", meas, " '${COND}'", r);
} }
' '
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment