build: allow cros-compilation on chromeOS
[xfstests-dev.git] / tools / compare-failures
1 #!/bin/bash
2
3 # Compare test failures across runs
4 #
5 # Takes multiple "results" files as arguments, comprised of the
6 # stdout from a ./check run, each containing a Failures: line.
7 #
8 # Outputs a table of failures for comparison across runs
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 filter_names() {
29         sed -e s/btrfs/b/ \
30             -e s/cifs/c/g \
31             -e s/f2fs/f/g \
32             -e s/generic/g/g \
33             -e s/overlay/o/g \
34             -e s/shared/s/g \
35             -e s/udf/u/g \
36             -e s/xfs/x/g
37 }
38
39 # ALLFAILURES:   A B C D E F G
40 # THESEFAILURES: A   C D     G
41
42 # We want to print the header (ALLFAILURES) and then
43 # if a run didn't fail a particular test, print spaces instead
44
45 # All tests that failed in any run, all on one line, unique
46 ALLFAILURES=`grep -h ^Failures: $* \
47                 | tr " " "\n" \
48                 | sort | uniq \
49                 | filter_names \
50                 | tr "\n" " " \
51                 | sed -e "s/^Failures: //g"`
52
53 # Header
54 echo "Failures:"
55 echo $ALLFAILURES
56 echo $ALLFAILURES | sed -e "s/./-/g"
57
58 # Per-file failures
59 for FILE in $*; do
60         THESEFAILURES=`grep ^Failures: $FILE | filter_names`
61         for FAILURE in $ALLFAILURES; do
62                 CELL=`echo $THESEFAILURES \
63                       | grep -wo "$FAILURE" || echo $FAILURE | sed -e "s/./ /g"`
64                 echo -n "$CELL "
65         done
66         echo $FILE
67 done