blob: 9f72eba44dcb4edd9be1feafcddb7cd9621fe69a [file] [log] [blame]
Chris Kay32d73bc2021-12-09 14:37:06 +00001#!/usr/bin/env awk
2
Jimmy Brissoncb545bd2021-01-06 13:52:58 -06003#
Chris Kay32d73bc2021-12-09 14:37:06 +00004# Copyright (c) 2021-2022 Arm Limited. All rights reserved.
Jimmy Brissoncb545bd2021-01-06 13:52:58 -06005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
Chris Kay32d73bc2021-12-09 14:37:06 +00008
Jimmy Brissoncb545bd2021-01-06 13:52:58 -06009# This is a script to categorize tests within this repo by type. This script is
10# intended to be run with the output of `find group -type f`, run from within
11# the root directory of this repo piped into it. See the bash script with the
12# same name for an usage example.
13
14BEGIN {
15 # We're breaking records upon the "/" character so that we can have an
16 # aggregation that's keyed by test group, if we want to.
17 FS = "/";
Chris Kay32d73bc2021-12-09 14:37:06 +000018
19 categories[0] = "\"L1\"";
20 categories[1] = "\"L2\"";
21 categories[2] = "\"L3\"";
22 categories[3] = "\"Release\"";
23 categories[4] = "\"Disabled\"";
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060024}
25
26# Here we filter out any records without exactly 3 fields (i.e. 3-level paths)
27# and categorize the rest.
28NF == 3 {
Chris Kay32d73bc2021-12-09 14:37:06 +000029 if (/-l1/) {
30 category = 0;
31 } else if (/-l2/) {
32 category = 1;
33 } else if (/-l3/) {
34 category = 2;
35 } else if (/-unstable/) {
36 category = 4;
37 } else {
38 category = 3;
39 }
40
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060041 # Each of these categorizes a test into a category, based on a regular
42 # expression. When you add another test category, you should also add
43 # printing to the print group loop below.
Chris Kay32d73bc2021-12-09 14:37:06 +000044 if (/linux/ || /uboot/ || /edk2/ || /:fvp-([a-z0-9.]-)*spm/ || /:juno-([a-z0-9.]-)*scmi/) {
45 integration[category] += 1;
46 } else if (/tftf/) {
47 component[category] += 1;
48 } else if (/coverity/ || /misra/ || /scan_build/) {
49 static[category] += 1;
50 } else if (/:nil/ || /norun/) {
51 build[category] += 1;
52 } else {
53 print $0 " No test category; excluding from data" >> "/dev/stderr";
54 }
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060055}
56
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060057END {
Chris Kay32d73bc2021-12-09 14:37:06 +000058 for (category = 0; category in categories; category++) {
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060059 # This prints a single test group, by name. When you add another
60 # category (with another map), add another field to this print.
Chris Kay32d73bc2021-12-09 14:37:06 +000061 printf("%s %d %d %d %d\n",
62 categories[category],
63 build[category],
64 static[category],
65 component[category],
66 integration[category]);
67 }
Jimmy Brissoncb545bd2021-01-06 13:52:58 -060068}