3 # Copyright (c) 2019 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 # This file should be executed from tox, as the assumend working directory
19 # is different from where this file is located.
20 # This file does not have executable flag nor shebang,
21 # to dissuade non-tox callers.
23 # "set -eu" handles failures from the following two lines.
24 BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
25 BASH_FUNCTION_DIR="$(readlink -e "${BASH_CHECKS_DIR}/../../function")"
26 source "${BASH_FUNCTION_DIR}/common.sh" || {
27 echo "Source failed." >&2
31 # Grep of interest: We want all tc01- prefixed (skip TC variations for now).
32 # Currently script assumes all variations inside to be part of either
33 # auto-generation or not checked at all (VIRL derivates).
35 # Parse grep of interest (learn path, learn suite, learn testcase name).
36 r_parse='(.*)\/(.*).robot.*(tc[[:digit:]]{2}-.*)'
38 rm -f "tc_coverage.log" || die
40 # Disabling -x: Following lines are doing too much garbage output.
44 grep_match=$(grep -RE "${r_grep}" tests/*) || die
45 # Extract data from the grep output.
46 suites_dirs=($(printf "${grep_match}" | sed -re "s/${r_parse}/\1/")) || die
47 suites_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\2/")) || die
48 testcases_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\3/")) || die
50 # Extract 2N suites from the global testcase list and normalize output.
51 suites_2n=($(printf '%s\n' "${suites_names[@]}" | \
52 grep -E "^(2n1l|2n)-" | \
53 sed -re "s/(2n1l|2n)-//"))
54 # Extract 3N suites from the global testcase list.
55 suites_3n=($(printf '%s\n' "${suites_names[@]}" | \
56 grep -vE "^(2n1l|2n|eth2p)-"))
57 # Extract vpp_device suites from the global testcase list.
58 # Code will try to map the naming to perf by normalizing output.
59 suites_dev=($(printf '%s\n' "${suites_names[@]}" | \
61 sed -re "s/eth2p-/10ge2p1x710-/" | \
62 sed -re "s/-dev/-ndrpdr/" | \
63 sed -re "s/-ethicmpv/-ethip/"))
65 # Compute intersection of arrays.
66 intersection_3n2n=($(comm -12 <(printf '%s\n' "${suites_3n[@]}" | sort) \
67 <(printf '%s\n' "${suites_2n[@]}" | sort)))
68 intersection_3ndev=($(comm -12 <(printf '%s\n' "${suites_2n[@]}" | sort) \
69 <(printf '%s\n' "${suites_dev[@]}" | sort)))
71 # Print the results in CSV format.
72 echo "Suite name;Testcase name;2n version;VPP Device version" \
74 for i in "${!suites_names[@]}"; do
75 if [[ ! "${suites_names[i]}" =~ ^(2n1l|2n|eth2p)-.* ]]; then
76 echo -n "${suites_names[i]};${testcases_names[i]}" \
78 if [[ "${intersection_3n2n[@]}" =~ "${suites_names[i]}" ]]; then
79 echo -n ";yes" >> tc_coverage.log
81 echo -n ";no" >> tc_coverage.log
83 if [[ "${intersection_3ndev[@]}" =~ "${suites_names[i]}" ]]; then
84 echo ";yes" >> tc_coverage.log
86 echo ";no" >> tc_coverage.log
93 echo "Count 2n: ${#suites_2n[@]}"
94 echo "Count 3n: ${#suites_3n[@]}"
95 echo "Count dev: ${#suites_dev[@]}"
96 echo "Coverage 2n3n: ${#intersection_3n2n[@]}"
97 echo "Coverage 3ndev: ${#intersection_3ndev[@]}"
100 warn "Testcase coverage checker: PASS"