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.
This commit is contained in:
committed by
Jaroslava Fiedlerova
parent
3e79774386
commit
b012700fe4
@@ -28,6 +28,13 @@ while [ $# -gt 0 ]; do
|
||||
# RC to signal error). In both cases, the result is logged in an array to
|
||||
# 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"
|
||||
# The awk script tries to match every line for "PHY proc tx _NUMBER_" (where
|
||||
# number is a decimal), and compares _NUMBER_ against condition "< 200",
|
||||
@@ -35,14 +42,16 @@ while [ $# -gt 0 ]; do
|
||||
# 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".
|
||||
SCRIPT+='
|
||||
match($0, /'${PATTERN}' +([0-9]+(\.[0-9]+)?)/, n) {
|
||||
if (n[1] '${COND}') {
|
||||
match($0, /'${PATTERN}' +([0-9]+(\.[0-9]+)?)/) {
|
||||
meas = substr($0, RSTART, RLENGTH);
|
||||
sub(/'${PATTERN}' +/, "", meas);
|
||||
if ((meas+0) '${COND}') {
|
||||
r = "SUCCESS";
|
||||
} else {
|
||||
r = "FAIL";
|
||||
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);
|
||||
}
|
||||
'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user