Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#! /bin/bash

function log() {
  echo -e "$@"
}

function err() {
  echo -e "$@" 1>&2
}

touch issues.txt

# check if the menu as a whole was run
if ! [ -f "hlt.done" ]; then
  err "ERROR: Execution of the full HLT menu failed.\nPlease check the contents of 'hlt.log' for details."
  cat >> issues.txt <<EOF
hlt
EOF
  exit 1
fi

# extract list of triggers
if ! [ -f "paths.txt" ]; then
  err "ERROR: File \"paths.txt\" does not exist (must contain the list of paths used in the integration tests)."
  cat >> issues.txt <<EOF
paths.txt
EOF
  exit 1
fi

TRIGGERS=$(cat paths.txt)

# compare the results of running each path by itself with those from the full menu
STATUS=0
for TRIGGER in $TRIGGERS; do
  if ! [ -f ${TRIGGER}.done ]; then
    err "ERROR: Execution of the trigger $TRIGGER failed.\nPlease check the contents of '$TRIGGER.log' for details."
    STATUS=1
    cat >> issues.txt <<EOF
hlt
$TRIGGER
EOF
    continue
  fi
  RESULT=$(cat "hlt.log"      | awk "/TrigReport ---------- Modules in Path: $TRIGGER ------------/"'{ while ($1 == "TrigReport") { print; getline; } }' | sed -e's|TrigReport     1 ....|TrigReport     1 xxxx|')
  SINGLE=$(cat "$TRIGGER.log" | awk "/TrigReport ---------- Modules in Path: $TRIGGER ------------/"'{ while ($1 == "TrigReport") { print; getline; } }' | sed -e's|TrigReport     1 ....|TrigReport     1 xxxx|')
  if [ "$RESULT" != "$SINGLE" ]; then
    err "ERROR: Inconsistencies found comparing the result of the trigger $TRIGGER run as part of the whole menu, or standalone.\nPlease compare the contents of 'hlt.log' and '$TRIGGER.log' for details."
    STATUS=1
    cat >> issues.txt <<EOF
hlt
$TRIGGER
EOF
  fi
  read VISIT PASS LAST <<< $(echo "$RESULT" | tail -n1 | awk '{ print $4, $5, $8; }')
  if (( PASS == 0 )); then
    if [ "$LAST" != "hltBoolFalse" ]; then
      log "WARNING: path $TRIGGER did not accept any events"
    elif (( VISIT == 0 )); then
      log "WARNING: path $TRIGGER was not fully exercised"
    fi
  fi
done

exit $STATUS