From 71e4fa60cd00c42c6af3c45e8149d8c0cd29f6e0 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 14 Nov 2021 12:28:52 +0000 Subject: Build all versions based on shortname, fix shebang, tag catalina latest --- tests/test.sh | 136 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 60 insertions(+), 76 deletions(-) (limited to 'tests') diff --git a/tests/test.sh b/tests/test.sh index e66f04f..b26931a 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/docker +#!/usr/bin/bash # ____ __ ____ ______ __ # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / @@ -120,13 +120,17 @@ NO_CACHE="${NO_CACHE:=--no-cache}" TEST_BUILDS=( -'docker-osx:latest' -'docker-osx:naked' -'docker-osx:naked-auto' -'docker-osx:big-sur' -'docker-osx:monterey' -'docker-osx:auto' -#'docker-osx:auto-big-sur' + 'docker-osx:naked' + 'docker-osx:naked-auto' + 'docker-osx:auto' +) + +VERSION_BUILDS=( + 'high-sierra' + 'mojave' + 'catalina' + 'big-sur' + 'monterey' ) install_docker () { @@ -196,23 +200,10 @@ enable_kvm () { echo 1 | tee /sys/module/kvm/parameters/ignore_msrs } - clone_repo () { git clone --branch="${1}" "${2}" Docker-OSX } - -docker-osx:latest () { - docker build ${NO_CACHE} \ - --build-arg BRANCH="${BRANCH}" \ - --build-arg RANKMIRRORS=true \ - --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ - -f ./Dockerfile \ - -t docker-osx:latest . - docker tag docker-osx:latest sickcodes/docker-osx:latest -} - - docker-osx:naked () { docker build ${NO_CACHE} \ --squash \ @@ -223,7 +214,6 @@ docker-osx:naked () { docker tag docker-osx:naked sickcodes/docker-osx:naked } - docker-osx:naked-auto () { docker build ${NO_CACHE} \ --squash \ @@ -234,26 +224,6 @@ docker-osx:naked-auto () { docker tag docker-osx:naked-auto sickcodes/docker-osx:naked-auto } - -docker-osx:big-sur () { - docker build ${NO_CACHE} \ - --build-arg VERSION=11 \ - --build-arg RANKMIRRORS=true \ - --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ - -f ./Dockerfile \ - -t docker-osx:big-sur . - docker tag docker-osx:big-sur sickcodes/docker-osx:big-sur -} - -docker-osx:monterey () { - docker build ${NO_CACHE} \ - --build-arg RANKMIRRORS=true \ - --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ - -f ./Dockerfile.monterey \ - -t docker-osx:monterey . - docker tag docker-osx:monterey sickcodes/docker-osx:monterey -} - docker-osx:auto () { docker build ${NO_CACHE} \ --build-arg RANKMIRRORS=true \ @@ -263,14 +233,26 @@ docker-osx:auto () { docker tag docker-osx:auto sickcodes/docker-osx:auto } -docker-osx:auto-big-sur () { +# docker-osx:auto-big-sur () { +# docker build ${NO_CACHE} \ +# --build-arg RANKMIRRORS=true \ +# --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ +# --build-arg IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' \ +# -f ./Dockerfile.auto \ +# -t docker-osx:auto-big-sur . +# docker tag docker-osx:auto-big-sur sickcodes/docker-osx:auto-big-sur +# } + +docker-osx:version () { + SHORTNAME="${1}" docker build ${NO_CACHE} \ + --build-arg BRANCH="${BRANCH}" \ --build-arg RANKMIRRORS=true \ + --build-arg SHORTNAME="${SHORTNAME}" \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ - --build-arg IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' \ - -f ./Dockerfile.auto \ - -t docker-osx:auto-big-sur . - docker tag docker-osx:auto-big-sur sickcodes/docker-osx:auto-big-sur + -f ./Dockerfile \ + -t "docker-osx:${SHORTNAME}" . + docker tag "docker-osx:${SHORTNAME}" "sickcodes/docker-osx:${SHORTNAME}" } reset_docker_hard () { @@ -288,42 +270,44 @@ EOF systemctl enable --now docker } -tee -a ~/.bashrc < Date: Sun, 14 Nov 2021 18:16:53 +0000 Subject: Add static expected screenshots of installation images to ./tests/ --- tests/big-sur_master.png | Bin 0 -> 200793 bytes tests/catalina_master.png | Bin 0 -> 323513 bytes tests/high-sierra_master.png | Bin 0 -> 335861 bytes tests/mojave_master.png | Bin 0 -> 323843 bytes tests/monterey_master.png | Bin 0 -> 198807 bytes tests/test.sh | 6 +++--- 6 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tests/big-sur_master.png create mode 100644 tests/catalina_master.png create mode 100644 tests/high-sierra_master.png create mode 100644 tests/mojave_master.png create mode 100644 tests/monterey_master.png (limited to 'tests') diff --git a/tests/big-sur_master.png b/tests/big-sur_master.png new file mode 100644 index 0000000..b3e0636 Binary files /dev/null and b/tests/big-sur_master.png differ diff --git a/tests/catalina_master.png b/tests/catalina_master.png new file mode 100644 index 0000000..9749507 Binary files /dev/null and b/tests/catalina_master.png differ diff --git a/tests/high-sierra_master.png b/tests/high-sierra_master.png new file mode 100644 index 0000000..9a5a8c7 Binary files /dev/null and b/tests/high-sierra_master.png differ diff --git a/tests/mojave_master.png b/tests/mojave_master.png new file mode 100644 index 0000000..4a9c8b6 Binary files /dev/null and b/tests/mojave_master.png differ diff --git a/tests/monterey_master.png b/tests/monterey_master.png new file mode 100644 index 0000000..15c33b6 Binary files /dev/null and b/tests/monterey_master.png differ diff --git a/tests/test.sh b/tests/test.sh index b26931a..2ba1ed0 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -178,7 +178,7 @@ install_scrotcat () { make -C ./imcat sudo cp ./imcat/imcat /usr/bin/imcat touch /usr/bin/scrotcat - tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' + tee /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' chmod +x /usr/bin/scrotcat } @@ -285,8 +285,8 @@ yes | apt install -y --no-install-recommends tzdata -y install_scrotcat yes | install_vnc export_display_99 -echo start_xvfb -start_vnc +start_xvfb +# start_vnc enable_kvm reset_docker_hard echo killall Xvfb -- cgit v1.2.3 From 9ca9372da1b8c12eda08a7a47d0bc4f1c7ddb805 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 14 Nov 2021 18:35:09 +0000 Subject: Add diff of screenshots to test suite, works good --- tests/boot-images.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test.sh | 5 +++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/boot-images.sh (limited to 'tests') diff --git a/tests/boot-images.sh b/tests/boot-images.sh new file mode 100644 index 0000000..6b914b9 --- /dev/null +++ b/tests/boot-images.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Author: Sick.Codes https://twitter.com/sickcodes +# Contact: https://github.com/sickcodes, https://sick.codes +# Copyright: sickcodes (C) 2021 +# License: GPLv3+ +# Title: Docker-OSX (Mac on Docker) +# Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes +# +# Status: Used internally to run each image and take screenshots until they match the pngs in this folder. +# + +# note to self: # to get master images, boot each image, then screen shot using DISPLAY=:99 in the test.sh script +# scrot -o high-sierra_master.png +# scrot -o mojave_master.png +# scrot -o catalina_master.png +# scrot -o big-sur_master.png +# scrot -o monterey_master.png +# pull off remote server to the tests folder +# REMOTE_SERVER= +# scp root@"${REMOTE_SERVER}":~/*_master.png . + +export DISPLAY=:99 + +TESTS=( + high-sierra + mojave + catalina + big-sur + monterey +) + +# test each docker image to see if they boot to their unique respective installation screens. + +for TEST in "${TESTS[@]}"; do + # run the image detached + docker run --rm -d \ + --device /dev/kvm \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=:99" \ + "sickcodes/docker-osx:${TEST}" + + # imcat the expected test screenshot to ./"${TEST}_master.txt" + imcat ~/Docker-OSX/tests/${TEST}_master.png > ./"${TEST}_master.txt" + + # run until the screen matches the expected screen + while :; do + sleep 5 + # screenshot the Xvfb + scrotcat > ./"${TEST}.txt" + # diff the low res txt files created from imcat + diff "./${TEST}.txt" ./"${TEST}_master.txt" && break + scrotcat + done + + # kill any containers + docker kill "$(docker ps --format "{{.ID}}")" + + # ensure all containers are dead + until [[ "$(docker ps | wc -l)" = 1 ]]; do + sleep 1 + docker ps | xargs docker kill + done + +done + +exit 0 diff --git a/tests/test.sh b/tests/test.sh index 2ba1ed0..84ec774 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -12,7 +12,7 @@ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes # -# Status: Work in progress. +# Status: Used internally to auto build, run and test images on DO. # help_text="Usage: ./test.sh --branch --repo @@ -303,6 +303,9 @@ for TEST_BUILD in "${TEST_BUILDS[@]}"; do "${TEST_BUILD}" done +# boot each image and test +bash ./tests/boot-images.sh || exit 1 + if [[ "${DOCKER_USERNAME}" ]] && [[ "${DOCKER_PASSWORD}" ]]; then docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" \ && for SHORTNAME in "${VERSION_BUILDS[@]}"; do -- cgit v1.2.3