Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / devops-stages / stage-test.sh
1 #!/bin/sh
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 # implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # python3 -m rflint testsuites
16
17 check_tabs () {
18 folder="$1"
19 tabs="y"
20 ! grep -r " " ${folder} && tabs=""
21 [ -n "${tabs}" ] && \
22 echo "There are tabs in ${folder}" && \
23 echo "Please replace by spaces" && \
24 exit 1
25 }
26
27 check_two_spaces () {
28 folder="$1"
29 two_spaces="y"
30 ! grep -r "[^ ] [^ ]" ${folder} && two_spaces=""
31 [ -n "${two_spaces}" ] && \
32 echo "Some files in ${folder} are using two spaces to separate params" && \
33 echo "Use this command to change it:" && \
34 echo " sed -i 's/\([^ ]\) \([^ ]\)/\\\1 \\\2/g' <FILENAME>" && \
35 exit 1
36 }
37
38 check_four_spaces () {
39 folder="$1"
40 four_spaces="y"
41 ! grep -r "[^# \.] " ${folder} && four_spaces=""
42 [ -n "${four_spaces}" ] && \
43 echo "Some files in ${folder} are using four spaces or more to separate params" && \
44 echo "You can try this command to change it:" && \
45 echo " sed -i 's/\([^# \.]\) */\\\1 /g' <FILENAME>" && \
46 exit 1
47 }
48
49 check_crlf_terminators () {
50 folder="$1"
51 crlf_terminators="y"
52 ! (find ${folder} -not -type d -exec file "{}" ";" | grep CRLF) && crlf_terminators=""
53 [ -n "${crlf_terminators}" ] && \
54 echo "Some files in ${folder} have CRLF at the end of some lines" && \
55 echo "Use this command to change it:" && \
56 echo " dos2unix <FILENAME>" && \
57 exit 1
58 }
59
60 check_spaces_eol () {
61 folder="$1"
62 spaces_eol="y"
63 ! grep -ri " $" ${folder} && spaces_eol=""
64 [ -n "${spaces_eol}" ] && \
65 echo "Some files in ${folder} have spaces at the end of some lines" && \
66 echo "Use this command to change it:" && \
67 echo " sed -i 's/ *$//g' <FILENAME>" && \
68 exit 1
69 }
70
71 echo "Checking syntax of Robot tests"
72
73 echo "Checking tabs in robot files. No tabs should be present"
74 check_tabs robot-systest/testsuite
75 check_tabs robot-systest/lib
76 echo "No tabs are present in robot files. Correct!"
77
78 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of two"
79 check_two_spaces robot-systest/testsuite
80 check_two_spaces robot-systest/lib
81 echo "No presence of two spaces to separate params in robot files. Correct!"
82
83 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of four or more"
84 check_four_spaces robot-systest/testsuite
85 check_four_spaces robot-systest/lib
86 echo "Only three spaces must be used between params in robot files. Correct!"
87
88 echo "Checking CRLF terminators in robot files. No CRLF should be found"
89 check_crlf_terminators robot-systest/testsuite
90 check_crlf_terminators robot-systest/lib
91 echo "No presence of CRLF terminators in robot files. Correct!"
92
93 echo "Checking spaces at the end of lines in robot files. No spaces at EOL should be found"
94 check_spaces_eol robot-systest/testsuite
95 check_spaces_eol robot-systest/lib
96 echo "No presence of spaces at EOL in robot files. Correct!"
97
98 # Other policies to be added here:
99 # - Blank lines used to separate main sections (Settings, Variables, Test Cases, Keywords)
100 # - Blank lines used to separate parts of eah section:
101 # - Variables: max 1 blank line to separate each one
102 # - Settings: 1 blank line to separate each kind of setting (all LIbrary together, all Resource together, etc.)
103 # - Test cases: 2 blank lines between test cases, max 1 blank line inside Test case, no blank line after Test Case Keyword
104
105 echo "Launching tox"
106 TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto
107