798d29a7f0376f94c8bb904d9208eb83b481c421
[csit.git] / resources / libraries / bash / entry / check_crc.sh
1 #!/usr/bin/env bash
2
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:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15
16 set -exuo pipefail
17
18 # This entry script does not change CSIT branch,
19 # use "with_oper_for_vpp.sh" wrapper for that.
20 #
21 # Assumptions:
22 # + There is a directory holding VPP repo with patch under test checked out.
23 # + It contains csit subdirectory with CSIT code to use (this script is there).
24 # + Everything needed to generate .api.json files is already installed locally.
25 # Consequences:
26 # + At the end, VPP repo has parent commit checked out and built.
27 # + Directories build_root, build and csit are reset during the run.
28 # + The following directory (relative to VPP repo) is (re)created:
29 # ++ build-root/install-vpp-native/vpp/share/vpp/api
30
31 # "set -eu" handles failures from the following two lines.
32 BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
33 BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")"
34 source "${BASH_FUNCTION_DIR}/common.sh" || {
35     echo "Source failed." >&2
36     exit 1
37 }
38 source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
39 common_dirs || die
40 set_perpatch_vpp_dir || die
41 activate_virtualenv "${VPP_DIR}" || die
42 # TODO: Create bash functions for the following one-liners?
43 make json-api-files || die "Generation of .api.json files failed."
44 python3 csit/resources/tools/integrated/check_crc.py
45 # RuntimeError causes nonzero return code, to vote -1.