@@ -106,6 +106,43 @@ test_docker_run_usage() {
106106 docker run ${IMAGE_NAME} & > /dev/null
107107}
108108
109+ test_scl_usage () {
110+ local run_cmd=" $1 "
111+ local expected=" $2 "
112+ local cid_file=" $3 "
113+
114+ info " Testing the image SCL enable"
115+ out=$( docker run --rm ${IMAGE_NAME} /bin/bash -c " ${run_cmd} " 2>&1 )
116+ if ! echo " ${out} " | grep -q " ${expected} " ; then
117+ echo " ERROR[/bin/bash -c " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
118+ return 1
119+ fi
120+ out=$( docker run --rm -i ${IMAGE_NAME} /bin/bash -i <<< " ${run_cmd}" 2>&1 )
121+ if ! echo " ${out} " | grep -q " ${expected} " ; then
122+ echo " ERROR[-i /bin/bash -c " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
123+ return 1
124+ fi
125+ out=$( docker run --rm -i ${IMAGE_NAME} /bin/bash -l <<< " ${run_cmd}" 2>&1 )
126+ if ! echo " ${out} " | grep -q " ${expected} " ; then
127+ echo " ERROR[-i /bin/bash -l " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
128+ return 1
129+ fi
130+ out=$( docker run --rm -i ${IMAGE_NAME} /bin/sh -ic " ${run_cmd} " 2>&1 )
131+ if ! echo " ${out} " | grep -q " ${expected} " ; then
132+ echo " ERROR[/bin/sh -c " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
133+ return 1
134+ fi
135+ out=$( docker exec $( cat ${cid_file} ) /bin/bash -c " ${run_cmd} " 2>&1 )
136+ if ! echo " ${out} " | grep -q " ${expected} " ; then
137+ echo " ERROR[exec /bin/bash -c " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
138+ return 1
139+ fi
140+ out=$( docker exec $( cat ${cid_file} ) /bin/sh -ic " ${run_cmd} " 2>&1 )
141+ if ! echo " ${out} " | grep -q " ${expected} " ; then
142+ echo " ERROR[exec /bin/sh -ic " ${run_cmd} " ] Expected '${expected} ', got '${out} '"
143+ return 1
144+ fi
145+ }
109146
110147test_connection () {
111148 info " Testing the HTTP connection (http://$( container_ip) :${test_port} ) ${CONTAINER_ARGS} ..."
@@ -136,6 +173,8 @@ test_application() {
136173 # Wait for the container to write it's CID file
137174 wait_for_cid
138175
176+ test_scl_usage " python --version" " Python 3.3.2" " ${cid_file} "
177+ check_result $?
139178 test_connection
140179 check_result $?
141180 cleanup_app
@@ -146,20 +185,19 @@ test_application() {
146185# it from Docker hub
147186sti_args=" --force-pull=false"
148187
188+ # Verify the 'usage' script is working properly when running the base image with 'sti usage ...'
189+ test_sti_usage
190+ check_result $?
191+
192+ # Verify the 'usage' script is working properly when running the base image with 'docker run ...'
193+ test_docker_run_usage
194+ check_result $?
149195
150196for app in ${WEB_APPS[@]} ; do
151197 prepare ${app}
152198 run_sti_build ${app}
153199 check_result $?
154200
155- # Verify the 'usage' script is working properly when running the base image with 'sti usage ...'
156- test_sti_usage
157- check_result $?
158-
159- # Verify the 'usage' script is working properly when running the base image with 'docker run ...'
160- test_docker_run_usage
161- check_result $?
162-
163201 # test application with default user
164202 test_application
165203
0 commit comments