check_crc.sh revision 9a936616
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
16set -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.
32BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
33BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")"
34source "${BASH_FUNCTION_DIR}/common.sh" || {
35    echo "Source failed." >&2
36    exit 1
37}
38source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
39common_dirs || die
40set_perpatch_vpp_dir || die
41activate_virtualenv "${VPP_DIR}" || die
42# TODO: Create bash functions for the following one-liners?
43make json-api-files || die "Generation of .api.json files failed."
44python3 csit/resources/tools/integrated/check_crc.py
45# RuntimeError causes nonzero return code, to vote -1.
46