liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

test-liminix-rebuild.sh (2028B)


      1 #!/usr/bin/env nix-shell
      2 #! nix-shell -v -i bash -p expect socat
      3 
      4 # This is a test for liminix-rebuild. It's not a CI test because
      5 # liminix-rebuild calls nix-build so won't run inside a derivation,
      6 # meaning you have to remember to run it manually when changing
      7 # liminix-rebuild
      8 
      9 . tests/test-helpers.sh
     10 
     11 set -e
     12 
     13 while test -n "$1"; do
     14     case $1 in
     15 	--fast)
     16 	    FAST=true
     17 	    ;;
     18 	*)
     19 	    ;;
     20     esac
     21     shift
     22 done
     23 
     24 here=$(pwd)/tests/min-copy-closure
     25 top=$(pwd)
     26 
     27 work=$(mktemp -d -t "test-lim-rebuild-XXXXXX")
     28 echo $work
     29 cd $work
     30 
     31 deriv(){
     32     (cd $top && nix-build -I liminix-config=${here}/config-ext4.nix  --arg device "import ./devices/qemu-armv7l" -A $1 );
     33 }
     34 
     35 PATH=$(deriv pkgs.pkgsBuildBuild.min-copy-closure)/bin:$(deriv pkgs.pkgsBuildBuild.run-liminix-vm)/bin:$PATH
     36 
     37 rootfs=$(deriv outputs.rootfs)
     38 kernel=$(deriv outputs.zimage)
     39 uboot=$(deriv outputs.u-boot)
     40 
     41 test -d ./vm && rm -rf vm
     42 mkdir ./vm
     43 
     44 cat ${rootfs} > rootfs
     45 
     46 truncate -s 32M rootfs
     47 resize2fs rootfs
     48 
     49 dd if=rootfs of=disk-image bs=512 seek=4 conv=sync
     50 echo '4,-,L,*' | sfdisk disk-image
     51 
     52 run-liminix-vm --background vm  \
     53 	       --command-line "console=ttyAMA0 panic=10 oops=panic loglevel=8 root=/dev/vda1 rootfstype=ext4" \
     54 	       --phram-address 0x50000000 --arch arm \
     55 	       --lan "user,hostfwd=tcp::2022-:22" \
     56 	       --flag -append --flag "root=/dev/vda1" --flag -hda \
     57 	       --flag disk-image $kernel /dev/null
     58 
     59 expect ${here}/wait-until-ready.expect
     60 echo "READY"
     61 
     62 touch known_hosts
     63 export SSH_COMMAND="ssh -o UserKnownHostsFile=${work}/known_hosts -o StrictHostKeyChecking=no -p 2022 -i ${here}/id"
     64 
     65 if test -n "$FAST"; then
     66     (cd ${top} && liminix-rebuild --fast root@localhost -I liminix-config=${here}/with-figlet.nix  --argstr deviceName qemu-armv7l)
     67     cd ${work} && expect $here/wait-for-soft-restart.expect
     68 else
     69     (cd ${top} && liminix-rebuild root@localhost -I liminix-config=${here}/with-figlet.nix  --arg device "import ./devices/qemu-armv7l")
     70     cd ${work} && expect $here/wait-for-reboot.expect
     71 fi
     72 
     73 cd / ; rm -rf $work