github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/integration/GET_KERNEL_QEMU (about) 1 #!/bin/bash 2 3 # This script is intended to run the tests we run at circleci, 4 # precisely as they are run there. 5 # 6 # to do so, it: 7 # o creates a directory to store local artifacts retrieved from docker 8 # see TMP= below 9 # o runs the standard test container to retrieve a the qemu, kernel, and bios image 10 # o runs go test with a default set of tests (./...) 11 # 12 # NOTE: if you want more complex behavior, don't make this script more 13 # complex. Convert it to Go. Complex shell scripts suck. 14 15 # These docker artifacts should not persist. Place them in tmp. 16 # tmp is in .gitignore 17 # I would prefer /tmp/$$. 18 # Docker really doesn't like this for some reason, even when 19 # I map it to /out inside the container. 20 TMP=`pwd`/tmp 21 mkdir -p $TMP 22 chmod 777 $TMP 23 24 # The default value is amd64, but you can override it, e.g. 25 # UROOT_TESTARCH=arm64 bash RUNLOCAL 26 export UROOT_TESTARCH=${UROOT_TESTARCH:=amd64} 27 28 case $UROOT_TESTARCH in 29 30 "amd64") 31 export UROOT_QEMU="qemu-system-x86_64" 32 export UROOT_QEMU_OPTS="-L $TMP/pc-bios -m 1G" 33 export UROOT_KERNEL=bzImage 34 export UROOT_BIOS=pc-bios 35 ;; 36 37 "arm64") 38 export UROOT_QEMU=qemu-system-aarch64 39 export UROOT_KERNEL=Image 40 export UROOT_BIOS="" 41 export UROOT_QEMU_OPTS="" 42 ;; 43 44 "arm") 45 export UROOT_QEMU=qemu-system-arm 46 export UROOT_KERNEL=zImage 47 export UROOT_BIOS="" 48 export UROOT_QEMU_OPTS='-M virt -nographic' 49 export UROOT_QEMU_TIMEOUT_X=10 50 51 ;; 52 53 *) 54 echo "$UROOT_TESTARCH is not a supported architecture (amd64, arm64, arm)" 55 exit 1 56 ;; 57 58 esac 59 60 # We no longer allow you to pick a kernel to run. 61 # Since we wish to exactly mirror what circleci does, we always use the 62 # kernel and qemu in the container. 63 # Note the docker pull only hurts a lot the first time. 64 # After you have run it once, further cp operations take a second or so. 65 # By doing it this way, we always use the latest Docker files. 66 CONTAINER=uroottest/test-image-${UROOT_TESTARCH} 67 68 DIR=/home/circleci 69 70 docker run $CONTAINER bash -c "echo \$UROOT_QEMU" 71 docker run $CONTAINER tar Ccf $DIR - $UROOT_KERNEL $UROOT_QEMU $UROOT_BIOS | tar Cxf $TMP - 72 73 ls -l $TMP 74 75 # now adjust paths and such 76 export UROOT_KERNEL=$TMP/$UROOT_KERNEL 77 export UROOT_QEMU="$TMP/$UROOT_QEMU $UROOT_QEMU_OPTS" 78 export UROOT_BIOS=$TMP/$UROOT_BIOS