• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# usage: suite_times [ status.log ]
4#
5# Parses a "status.log" file for a suite job, and for each test that
6# ran, report these timeline data from the log:
7#   1. hostname of the DUT that the test ran on
8#   2. time_t value of the time that the test started running
9#   3. total run time of the test on the DUT
10#   4. number of seconds between this test's start time and the
11#       start time of the last prior test on the same DUT
12#   5. name of the test
13#
14# This script is meant as a simple building block.  Below are
15# some sample uses.
16#
17# Print average inter-test time:
18#   suite_times | awk '{if ($4) {sum += $4; cnt++}} END {print sum / cnt}'
19#
20# Print average test run time:
21#   suite_times | awk '{sum += $3} END {print sum / NR}'
22#
23# Print time line for a host:
24#   suite_times | grep $HOST
25
26
27PROCESS_SUITE='
28  $1 == "START" && $2 != "----" {
29    host = gensub(".*/(.*)/.*", "\\1", 1, $2)
30    test = $3
31    start_ts = gensub(".*=", "", 1, $4)
32    old_ts = hosttimes[host]
33    if (!old_ts) { old_ts = start_ts }
34    start_rel = start_ts - old_ts
35    hosttimes[host] = start_ts
36  }
37
38  $1 == "GOOD" {
39    end_ts = gensub(".*=", "", 1, $4)
40    runtime = end_ts - start_ts
41    printf "%s %d %4d %4d %s\n", host, start_ts, runtime, start_rel, test
42  }
43'
44
45if [ $# -eq 0 ]; then
46  STATUS_LOG=status.log
47elif [ $# -eq 1 ]; then
48  STATUS_LOG="$1"
49else
50  echo "usage: $(basename $0) [ status.log ]" >&2
51  exit 1
52fi
53
54awk "$PROCESS_SUITE" "$STATUS_LOG"
55