github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/contrib/cirrus/check_image.sh (about) 1 #!/bin/bash 2 3 set -eo pipefail 4 5 source $(dirname $0)/lib.sh 6 7 EVIL_UNITS="$($CIRRUS_WORKING_DIR/$PACKER_BASE/systemd_banish.sh --list)" 8 9 req_env_var PACKER_BUILDER_NAME TEST_REMOTE_CLIENT EVIL_UNITS OS_RELEASE_ID 10 11 NFAILS=0 12 echo "Validating VM image" 13 14 MIN_SLASH_GIGS=30 15 read SLASH_DEVICE SLASH_FSTYPE SLASH_SIZE JUNK <<<$(findmnt --df --first-only --noheadings / | cut -d '.' -f 1) 16 SLASH_SIZE_GIGS=$(echo "$SLASH_SIZE" | sed -r -e 's/G|g//') 17 item_test "Minimum available disk space" $SLASH_SIZE_GIGS -gt $MIN_SLASH_GIGS || let "NFAILS+=1" 18 19 MIN_MEM_MB=2000 20 read JUNK TOTAL USED MEM_FREE JUNK <<<$(free -tm | tail -1) 21 item_test 'Minimum available memory' $MEM_FREE -ge $MIN_MEM_MB || let "NFAILS+=1" 22 23 # We're testing a custom-built podman; make sure there isn't a distro-provided 24 # binary anywhere; that could potentially taint our results. 25 item_test "remove_packaged_podman_files() did it's job" -z "$(type -P podman)" || let "NFAILS+=1" 26 27 # Integration Tests require varlink in Fedora 28 item_test "The varlink executable is present" -x "$(type -P varlink)" || let "NFAILS+=1" 29 30 MIN_ZIP_VER='3.0' 31 VER_RE='.+([[:digit:]]+\.[[:digit:]]+).+' 32 ACTUAL_VER=$(zip --version 2>&1 | egrep -m 1 "Zip$VER_RE" | sed -r -e "s/$VER_RE/\\1/") 33 item_test "minimum zip version" "$MIN_ZIP_VER" = $(echo -e "$MIN_ZIP_VER\n$ACTUAL_VER" | sort -V | head -1) || let "NFAILS+=1" 34 35 for REQ_UNIT in google-accounts-daemon.service \ 36 google-clock-skew-daemon.service \ 37 google-instance-setup.service \ 38 google-network-daemon.service \ 39 google-shutdown-scripts.service \ 40 google-startup-scripts.service 41 do 42 item_test "required $REQ_UNIT enabled" \ 43 "$(systemctl list-unit-files --no-legend $REQ_UNIT)" = "$REQ_UNIT enabled" || let "NFAILS+=1" 44 done 45 46 for evil_unit in $EVIL_UNITS 47 do 48 # Exits zero if any unit matching pattern is running 49 unit_status=$(systemctl is-active $evil_unit &> /dev/null; echo $?) 50 item_test "No $evil_unit unit is present or active:" "$unit_status" -ne "0" || let "NFAILS+=1" 51 done 52 53 if [[ "$OS_RELEASE_ID" == "ubuntu" ]] && [[ -x "/usr/lib/cri-o-runc/sbin/runc" ]] 54 then 55 SAMESAME=$(diff --brief /usr/lib/cri-o-runc/sbin/runc /usr/bin/runc &> /dev/null; echo $?) 56 item_test "On ubuntu /usr/bin/runc is /usr/lib/cri-o-runc/sbin/runc" "$SAMESAME" -eq "0" || let "NFAILS+=1" 57 fi 58 59 if [[ "$OS_RELEASE_ID" == "ubuntu" ]] 60 then 61 item_test "On ubuntu, no periodic apt crap is enabled" -z "$(egrep $PERIODIC_APT_RE /etc/apt/apt.conf.d/*)" 62 fi 63 64 echo "Checking items specific to ${PACKER_BUILDER_NAME}${BUILT_IMAGE_SUFFIX}" 65 case "$PACKER_BUILDER_NAME" in 66 xfedora*) 67 echo "Kernel Command-line: $(cat /proc/cmdline)" 68 item_test \ 69 "On ${PACKER_BUILDER_NAME} images, the /sys/fs/cgroup/unified directory does NOT exist" \ 70 "!" "-d" "/sys/fs/cgroup/unified" || let "NFAILS+=1" 71 ;; 72 *) echo "No vm-image specific items to check" 73 esac 74 75 echo "Total failed tests: $NFAILS" 76 exit $NFAILS