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 echo "Checking tabs in robot files. No tabs should be present"
61 check_tabs robot-systest/testsuite
62 check_tabs robot-systest/lib
63 echo "No tabs are present in robot files. Correct!"
64
65 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of two"
66 check_two_spaces robot-systest/testsuite
67 check_two_spaces robot-systest/lib
68 echo "No presence of two spaces to separate params in robot files. Correct!"
69
70 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of four or more"
71 check_four_spaces robot-systest/testsuite
72 check_four_spaces robot-systest/lib
73 echo "Only three spaces must be used between params in robot files. Correct!"
74
75 echo "Checking CRLF terminators in robot files. No CRLF should be found"
76 check_crlf_terminators robot-systest/testsuite
77 check_crlf_terminators robot-systest/lib
78 echo "No presence of CRLF terminators in robot files. Correct!"
79
80 echo "SUCCESS"
81 exit 0
82