On Wed, Feb 24, 2021 at 03:18:10PM +0800, Bai Jing wrote:
Signed-off-by: Bai Jing 799286817@qq.com
tests/openeuler_docker | 114 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 tests/openeuler_docker
ignore it
Thanks, Baijing
diff --git a/tests/openeuler_docker b/tests/openeuler_docker new file mode 100755 index 000000000..f79610b34 --- /dev/null +++ b/tests/openeuler_docker @@ -0,0 +1,114 @@ +#!/bin/sh +# - dockerfile_url
+. $LKP_SRC/lib/debug.sh
+[ -n "$dockerfile_url" ] || die "dockerfile_url is empty"
+cd $BENCHMARK_ROOT
+fit_repo() +{
- yum reinstall -y git
- git clone "$dockerfile_url" || exit 0
- file_dir=$(find ./ -type f -name "*Dockerfile*" | xargs grep -E '^FROM centos:(centos|)[78]')
- [ -n "$file_dir" ] || exit 0
+}
+openeuler_ready() +{
- docker load < $BENCHMARK_ROOT/openeuler_docker/openeuler-20.03-lts-v1.tar
+}
+centos_docker() +{
- flag=0
- for file in $(find ./ -type f -name "*Dockerfile*" | xargs grep -E '^FROM centos:(centos|)[78]' | awk -F: '{print $1}')
- do
image=$(echo "$file" | awk -F '/' '{print $3}' | tr 'A-Z' 'a-z')
if [ -f "build.sh" ] && [ -x "build.sh" ]; then
./build.sh > /dev/null 2> /dev/null && handle_dockerfile
else
docker_build > /dev/null 2> /dev/null && handle_dockerfile
fi
- done
+}
+handle_FROM() +{
- sed -i "s/^FROM .*/FROM openeuler-20.03-lts:v1/g" "$file"
+}
+handle_epel() +{
- grep -qw "epel-release" "$file" && {
sed -i "s/epel-release/bash/g" "$file"
- }
+}
+handle_epelrpm() +{
- grep -qw "https://.*epel-release.*rpm" "$file" && {
sed -i "s|https://.*epel-release.*rpm|bash|g" "$file"
- }
+}
+handle_groupadd() +{
- grep -qw "groupadd*" "$file" && {
sed -i '/groupadd*/i\ yum -y install shadow && \\' "$file"
- }
+}
+handle_epel_repo() +{
- grep -qwE '.* wget .*(epel|CentOS-Base).repo' "$file" && {
sed 's|^|#|g' "$file"
- }
+}
+handle_dockerfile() +{
- flag=1
- handle_FROM
- handle_epel
- handle_groupadd
- docker_build "-openeuler"
- [ $? -ne 0 ] || docker_run "-openeuler"
+}
+docker_build() +{
- docker build -f "$file" -t "${image}$1" .
- [ $? -ne 0 ] && {
[ "$flag" == "1" ] && echo "${image}$1.build.fail: 1"
return 1
- }
- [ "$flag" == "1" ] && echo "${image}$1.build.success: 1"
- flag=0
+}
+docker_run() +{
- docker run -d --name "${image}" "${image}$1"
- docker_stats=$(docker inspect ${image} | grep Running | awk -F ' ' '{print $2}' | tr -d ',')
- [ $docker_stats == false ] && {
echo "${image}.run.fail: 1"
return 1
- }
- echo "${image}.run.success: 1"
+}
+docker_test() +{
- fit_repo
- openeuler_ready
- centos_docker
+}
+docker_test
2.23.0