Skip to content

Commit a635f5f

Browse files
committed
Remove check_version in common_functions.sh
resolves : #4949 Signed-off-by: Anna Babu Palathingal <[email protected]>
1 parent 3becd04 commit a635f5f

File tree

1 file changed

+128
-135
lines changed

1 file changed

+128
-135
lines changed

external/common_functions.sh

+128-135
Original file line numberDiff line numberDiff line change
@@ -32,214 +32,207 @@ supported_builds="full"
3232
# Supported tests
3333
supported_tests="external_custom camel criu-portable-checkpoint criu-portable-restore criu-ubi-portable-checkpoint criu-ubi-portable-restore derby elasticsearch jacoco jenkins functional-test kafka lucene-solr openliberty-mp-tck payara-mp-tck quarkus quarkus_quickstarts scala system-test tomcat tomee wildfly wycheproof netty spring zookeeper"
3434

35-
function check_version() {
36-
version=$1
37-
38-
for current_version in ${supported_versions}
39-
do
40-
if [[ "${version}" == "${current_version}" ]]; then
41-
return 1
42-
fi
43-
done
44-
45-
return 0
46-
}
47-
4835
# Set a valid version
4936
function set_version() {
50-
version=$1
51-
52-
if (check_version ${version}); then
53-
echo "ERROR: Invalid Version: ${version}"
54-
echo "Usage: $0 [${supported_versions}]"
55-
exit 1
56-
fi
37+
version=$1
38+
for current_version in ${supported_versions}
39+
do
40+
if [[ "${version}" == "${current_version}" ]]; then
41+
# Valid version found, you can perform additional actions if needed
42+
echo "Setting version to: ${version}"
43+
return
44+
fi
45+
done
46+
# If no valid version is found, display an error message
47+
echo "ERROR: Invalid Version: ${version}"
48+
echo "Usage: $0 [${supported_versions}]"
49+
exit 1
5750
}
5851

5952
function check_os() {
60-
os=$1
53+
os=$1
6154

62-
for current_os in ${supported_os}
63-
do
64-
if [[ "${os}" == "${current_os}" ]]; then
65-
return 1
66-
fi
67-
done
55+
for current_os in ${supported_os}
56+
do
57+
if [[ "${os}" == "${current_os}" ]]; then
58+
return 1
59+
fi
60+
done
6861

69-
return 0
62+
return 0
7063
}
7164

7265
# Set a valid os
7366
function set_os() {
74-
os=$1
75-
if (check_os ${os}); then
76-
echo "ERROR: Invalid OS: ${os}"
77-
echo "Usage: $0 [${supported_os}]"
78-
exit 1
79-
fi
67+
os=$1
68+
if (check_os ${os}); then
69+
echo "ERROR: Invalid OS: ${os}"
70+
echo "Usage: $0 [${supported_os}]"
71+
exit 1
72+
fi
8073
}
8174

8275
function check_test() {
83-
test=$1
76+
test=$1
8477

85-
for current_test in ${supported_tests}
86-
do
87-
if [[ "${test}" == "${current_test}" ]]; then
88-
return 1
89-
fi
90-
done
78+
for current_test in ${supported_tests}
79+
do
80+
if [[ "${test}" == "${current_test}" ]]; then
81+
return 1
82+
fi
83+
done
9184

92-
return 0
85+
return 0
9386
}
9487

9588
# Set a valid test
9689
function set_test() {
97-
test=$1
98-
if (check_test ${test}); then
99-
echo "ERROR: Invalid Test: ${test}"
100-
echo "Usage: $0 [${supported_tests}]"
101-
exit 1
102-
fi
90+
test=$1
91+
if (check_test ${test}); then
92+
echo "ERROR: Invalid Test: ${test}"
93+
echo "Usage: $0 [${supported_tests}]"
94+
exit 1
95+
fi
10396
}
10497

10598
function check_vm() {
106-
vm=$1
99+
vm=$1
107100

108-
for current_vm in ${supported_jvms}
109-
do
110-
if [[ "${vm}" == "${current_vm}" ]]; then
111-
return 1
112-
fi
113-
done
101+
for current_vm in ${supported_jvms}
102+
do
103+
if [[ "${vm}" == "${current_vm}" ]]; then
104+
return 1
105+
fi
106+
done
114107

115-
return 0
108+
return 0
116109
}
117110

118111
# Set a valid vm
119112
function set_vm() {
120-
vm=$1
121-
if (check_vm ${vm}); then
122-
echo "ERROR: Invalid VM: ${vm}"
123-
echo "Usage: $0 [${supported_jvms}]"
124-
exit 1
125-
fi
113+
vm=$1
114+
if (check_vm ${vm}); then
115+
echo "ERROR: Invalid VM: ${vm}"
116+
echo "Usage: $0 [${supported_jvms}]"
117+
exit 1
118+
fi
126119
}
127120

128121
function check_package() {
129-
package=$1
122+
package=$1
130123

131-
for current_package in ${supported_packages}
132-
do
133-
if [[ "${package}" == "${current_package}" ]]; then
134-
return 1
135-
fi
136-
done
124+
for current_package in ${supported_packages}
125+
do
126+
if [[ "${package}" == "${current_package}" ]]; then
127+
return 1
128+
fi
129+
done
137130

138-
return 0
131+
return 0
139132
}
140133

141134
# Set a valid package
142135
function set_package() {
143-
package=$1
144-
if (check_package ${package}); then
145-
echo "ERROR: Invalid Package: ${package}"
146-
echo "Usage: $0 [${supported_packages}]"
147-
exit 1
148-
fi
136+
package=$1
137+
if (check_package ${package}); then
138+
echo "ERROR: Invalid Package: ${package}"
139+
echo "Usage: $0 [${supported_packages}]"
140+
exit 1
141+
fi
149142
}
150143

151144
function check_build() {
152-
build=$1
145+
build=$1
153146

154-
for current_build in ${supported_builds}
155-
do
156-
if [[ "${build}" == "${current_build}" ]]; then
157-
return 1
158-
fi
159-
done
147+
for current_build in ${supported_builds}
148+
do
149+
if [[ "${build}" == "${current_build}" ]]; then
150+
return 1
151+
fi
152+
done
160153

161-
return 0
154+
return 0
162155
}
163156

164157
# Set a valid build
165158
function set_build() {
166-
build=$1
167-
if (check_build ${build}); then
168-
echo "ERROR: Invalid Build: ${build}"
169-
echo "Usage: $0 [${supported_builds}]"
170-
exit 1
171-
fi
159+
build=$1
160+
if (check_build ${build}); then
161+
echo "ERROR: Invalid Build: ${build}"
162+
echo "Usage: $0 [${supported_builds}]"
163+
exit 1
164+
fi
172165
}
173166

174167
# Set a platform
175168
function set_platform() {
176-
# TO-DO: Add supported_platforms when portable tests support more platforms
177-
platform=$1
169+
# TO-DO: Add supported_platforms when portable tests support more platforms
170+
platform=$1
178171
}
179172

180173
# Set base_docker_registry_url
181174
function set_base_docker_registry_url() {
182-
base_docker_registry_url="$1"
175+
base_docker_registry_url="$1"
183176
}
184177

185178
# Set base_docker_registry_dir
186179
function set_base_docker_registry_dir() {
187-
base_docker_registry_dir="$1"
180+
base_docker_registry_dir="$1"
188181
}
189182

190183
# Reading properties of test.properties file
191184
function getProperty() {
192-
PROP_KEY=$1
193-
PROP_VALUE=`cat $PROPERTY_FILE | grep "$PROP_KEY" | cut -d'=' -f 2-`
194-
echo `sed -e 's/^"//' -e 's/"$//' <<<"$PROP_VALUE"`
185+
PROP_KEY=$1
186+
PROP_VALUE=`cat $PROPERTY_FILE | grep "$PROP_KEY" | cut -d'=' -f 2-`
187+
echo `sed -e 's/^"//' -e 's/"$//' <<<"$PROP_VALUE"`
195188
}
196189

197190
# Used for external_custom tests
198191
function set_external_custom_test_info(){
199-
test=$1
200-
check_external_custom_test=$2
201-
github_url="${EXTERNAL_CUSTOM_REPO}"
202-
test_command="${EXTERNAL_TEST_CMD}"
203-
test_results="testResults"
204-
tag_version="${EXTERNAL_REPO_BRANCH}"
205-
environment_variable="MODE=java"
206-
ubuntu_packages="git"
207-
maven_version="3.8.5"
192+
test=$1
193+
check_external_custom_test=$2
194+
github_url="${EXTERNAL_CUSTOM_REPO}"
195+
test_command="${EXTERNAL_TEST_CMD}"
196+
test_results="testResults"
197+
tag_version="${EXTERNAL_REPO_BRANCH}"
198+
environment_variable="MODE=java"
199+
ubuntu_packages="git"
200+
maven_version="3.8.5"
208201
}
209202

210203
# Set the valid OSes for the current architectures.
211204
function set_test_info() {
212-
test=$1
213-
check_external_custom_test=$2
214-
cd ../
215-
path_to_file=$(pwd)
216-
echo ${path_to_file}
217-
PROPERTY_FILE=${path_to_file}/${test}/test.properties
218-
github_url=$(getProperty "github_url")
219-
test_options=$(getProperty "test_options")
220-
test_results=$(getProperty "test_results")
221-
ant_version=$(getProperty "ant_version")
222-
ant_contrib_version=$(getProperty "ant_contrib_version")
223-
ivy_version=$(getProperty "ivy_version")
224-
jdk_install=$(getProperty "jdk_install")
225-
tag_version=$(getProperty "tag_version")
226-
gradle_version=$(getProperty "gradle_version")
227-
sbt_version=$(getProperty "sbt_version")
228-
bazel_version=$(getProperty "bazel_version")
229-
openssl_version=$(getProperty "openssl_version")
230-
python_version=$(getProperty "python_version")
231-
criu_version=$(getProperty "criu_version")
232-
maven_version=$(getProperty "maven_version")
233-
environment_variable=$(getProperty "environment_variable")
234-
localPropertyFile=$(getProperty "localPropertyFile")
235-
ubuntu_packages=$(getProperty "ubuntu_packages")
236-
ubi_packages=$(getProperty "ubi_packages")
205+
test=$1
206+
check_external_custom_test=$2
207+
cd ../
208+
path_to_file=$(pwd)
209+
echo ${path_to_file}
210+
PROPERTY_FILE=${path_to_file}/${test}/test.properties
211+
github_url=$(getProperty "github_url")
212+
test_options=$(getProperty "test_options")
213+
test_results=$(getProperty "test_results")
214+
ant_version=$(getProperty "ant_version")
215+
ant_contrib_version=$(getProperty "ant_contrib_version")
216+
ivy_version=$(getProperty "ivy_version")
217+
jdk_install=$(getProperty "jdk_install")
218+
tag_version=$(getProperty "tag_version")
219+
gradle_version=$(getProperty "gradle_version")
220+
sbt_version=$(getProperty "sbt_version")
221+
bazel_version=$(getProperty "bazel_version")
222+
openssl_version=$(getProperty "openssl_version")
223+
python_version=$(getProperty "python_version")
224+
criu_version=$(getProperty "criu_version")
225+
maven_version=$(getProperty "maven_version")
226+
environment_variable=$(getProperty "environment_variable")
227+
localPropertyFile=$(getProperty "localPropertyFile")
228+
ubuntu_packages=$(getProperty "ubuntu_packages")
229+
ubi_packages=$(getProperty "ubi_packages")
237230
}
238231

239232
function cleanup_images() {
240-
# Delete any old containers that have exited.
241-
docker rm $(docker ps -a | grep "Exited" | awk '{ print $1 }') 2>/dev/null
233+
# Delete any old containers that have exited.
234+
docker rm $(docker ps -a | grep "Exited" | awk '{ print $1 }') 2>/dev/null
242235

243-
# Delete any old images for our target_repo on localhost.
244-
docker rmi -f $(docker images | grep -e "adoptopenjdk" | awk '{ print $3 }' | sort | uniq) 2>/dev/null
236+
# Delete any old images for our target_repo on localhost.
237+
docker rmi -f $(docker images | grep -e "adoptopenjdk" | awk '{ print $3 }' | sort | uniq) 2>/dev/null
245238
}

0 commit comments

Comments
 (0)