Fix TREX linting
[ci-management.git] / jjb / vpp / include-raw-vpp-csit-functional.sh
1 #!/bin/bash
2 set -xeu -o pipefail
3
4 # Get CSIT branch from which to test from
5 # running build-root/scripts/csit-test-branch
6 if [ -x build-root/scripts/csit-test-branch ]; then
7     CSIT_BRANCH=`build-root/scripts/csit-test-branch`;
8 fi
9
10 # check CSIT_BRANCH value
11 if [ "$CSIT_BRANCH" == "" ]; then
12     echo "CSIT_BRANCH not provided => 'latest' will be used"
13     CSIT_BRANCH="latest"
14 fi
15
16 # clone csit
17 git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit
18
19 # if the git clone fails, complain clearly and exit
20 if [ $? != 0 ]; then
21     echo "Failed to run: git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit"
22     exit 1
23 fi
24
25 cp build-root/*.deb csit/
26 if [ -e dpdk/vpp-dpdk-dkms*.deb ]
27 then
28     cp dpdk/vpp-dpdk-dkms*.deb csit/
29 else
30     cp /w/dpdk/vpp-dpdk-dkms*.deb csit/
31 fi
32
33 # Check for CSIT_REF test file
34 if [ -e CSIT_REF ]; then
35     source CSIT_REF
36 fi
37
38 # If also testing a specific csit refpoint look for CSIT_REF
39 if [[ -v CSIT_REF ]]; then
40     (cd csit ; git fetch ssh://rotterdam-jobbuilder@gerrit.fd.io:29418/csit $CSIT_REF && git checkout FETCH_HEAD)
41 else
42     cd csit
43     if [ "$CSIT_BRANCH" == "latest" ]; then
44         # set required CSIT branch_id based on VPP master branch; by default use 'oper'
45         case "$VPP_BRANCH" in
46             master )
47                 BRANCH_ID="oper"
48                 ;;
49             stable/1710 )
50                 BRANCH_ID="oper-rls1710"
51                 ;;
52             stable/1801 )
53                 BRANCH_ID="oper-rls1801"
54                 ;;
55             stable/1804 )
56                 BRANCH_ID="oper-rls1804"
57                 ;;
58             stable/1807 )
59                 BRANCH_ID="oper-rls1807"
60                 ;;
61             * )
62                 BRANCH_ID="oper"
63         esac
64
65         # get the latest verified version of the required branch
66         CSIT_BRANCH=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
67
68         if [ "${CSIT_BRANCH}" == "" ]; then
69             echo "No verified CSIT branch found - exiting"
70             exit 1
71         fi
72
73         # remove 'origin/' from the branch name
74         CSIT_BRANCH=$(echo ${CSIT_BRANCH#origin/})
75     fi
76     # checkout the required csit branch
77     git checkout ${CSIT_BRANCH}
78
79     if [ $? != 0 ]; then
80         echo "Failed to checkout the required CSIT branch: ${CSIT_BRANCH}"
81         exit 1
82     fi
83 fi
84
85 # execute csit bootstrap script if it exists
86 if [ -e bootstrap.sh ]
87 then
88     # make sure that bootstrap.sh is executable
89     chmod +x bootstrap.sh
90     # run the script
91     ./bootstrap.sh *.deb
92 else
93     echo 'ERROR: No bootstrap.sh found'
94     exit 1
95 fi
96
97 # vim: ts=4 ts=4 sts=4 et :