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 tabs in robot files. No tabs should be present"
72 check_tabs robot-systest/testsuite
73 check_tabs robot-systest/lib
74 echo "No tabs are present in robot files. Correct!"
75
76 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of two"
77 check_two_spaces robot-systest/testsuite
78 check_two_spaces robot-systest/lib
79 echo "No presence of two spaces to separate params in robot files. Correct!"
80
81 echo "Checking param separation in robot files. Three spaces is the recommendation, instead of four or more"
82 check_four_spaces robot-systest/testsuite
83 check_four_spaces robot-systest/lib
84 echo "Only three spaces must be used between params in robot files. Correct!"
85
86 echo "Checking CRLF terminators in robot files. No CRLF should be found"
87 check_crlf_terminators robot-systest/testsuite
88 check_crlf_terminators robot-systest/lib
89 echo "No presence of CRLF terminators in robot files. Correct!"
90
91 echo "Checking spaces at the end of lines in robot files. No spaces at EOL should be found"
92 check_spaces_eol robot-systest/testsuite
93 check_spaces_eol robot-systest/lib
94 echo "No presence of spaces at EOL in robot files. Correct!"
95
96 # Other policies to be added here:
97 # - Blank lines used to separate main sections (Settings, Variables, Test Cases, Keywords)
98 # - Blank lines used to separate parts of eah section:
99 # - Variables: max 1 blank line to separate each one
100 # - Settings: 1 blank line to separate each kind of setting (all LIbrary together, all Resource together, etc.)
101 # - Test cases: 2 blank lines between test cases, max 1 blank line inside Test case, no blank line after Test Case Keyword
102
103 echo "SUCCESS"
104 exit 0
105