inside.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/sh
  2. # mount all kinds of things
  3. mount tmpfs -t tmpfs /etc
  4. # we need our own /dev/rfkill, and don't want device access
  5. mount tmpfs -t tmpfs /dev
  6. mount tmpfs -t tmpfs /tmp
  7. # some sockets go into /var/run, and / is read-only
  8. mount tmpfs -t tmpfs /var/run
  9. mount proc -t proc /proc
  10. mount sysfs -t sysfs /sys
  11. # needed for tracing
  12. mount debugfs -t debugfs /sys/kernel/debug
  13. # reboot on any sort of crash
  14. sysctl kernel.panic_on_oops=1
  15. sysctl kernel.panic=1
  16. # get extra command line variables from /proc/cmdline
  17. TESTDIR=$(sed 's/.*testdir=\([^ ]*\) .*/\1/' /proc/cmdline)
  18. EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline)
  19. ARGS=$(sed 's/.*ARGS=//' /proc/cmdline)
  20. # create /dev entries we need
  21. mknod -m 660 /dev/ttyS0 c 4 64
  22. mknod -m 660 /dev/random c 1 8
  23. mknod -m 660 /dev/urandom c 1 9
  24. mknod -m 666 /dev/null c 1 3
  25. test -f /sys/class/misc/rfkill/dev && \
  26. mknod -m 660 /dev/rfkill c $(cat /sys/class/misc/rfkill/dev | tr ':' ' ')
  27. ln -s /proc/self/fd/0 /dev/stdin
  28. ln -s /proc/self/fd/1 /dev/stdout
  29. ln -s /proc/self/fd/2 /dev/stderr
  30. # create dummy sudo - everything runs as uid 0
  31. mkdir /tmp/bin
  32. cat > /tmp/bin/sudo << EOF
  33. #!/bin/bash
  34. exec "\$@"
  35. EOF
  36. chmod +x /tmp/bin/sudo
  37. # and put it into $PATH, as well as our extra-$PATH
  38. export PATH=/tmp/bin:$EPATH:$PATH
  39. # some tests assume adm/admin group(s) exist(s)
  40. echo 'adm:x:0:' > /etc/group
  41. echo 'admin:x:0:' >> /etc/group
  42. # root should exist
  43. echo 'root:x:0:0:root:/tmp:/bin/bash' > /etc/passwd
  44. # local network is needed for some tests
  45. ip link set lo up
  46. # create logs mountpoint and mount the logshare
  47. mkdir /tmp/logs
  48. mount -t 9p -o trans=virtio,rw logshare /tmp/logs
  49. # check if we're rebooting due to a kernel panic ...
  50. if grep -q 'Kernel panic' /tmp/logs/console ; then
  51. echo "KERNEL CRASHED!" >/dev/ttyS0
  52. else
  53. # finally run the tests
  54. export USER=0
  55. export LOGDIR=/tmp/logs
  56. export DBFILE=$LOGDIR/results.db
  57. export PREFILL_DB=y
  58. # some tests need CRDA, install a simple uevent helper
  59. # and preload the 00 domain it will have asked for already
  60. echo $TESTDIR/vm/uevent.sh > /sys/kernel/uevent_helper
  61. COUNTRY=00 crda
  62. cd $TESTDIR
  63. ./run-all.sh $ARGS >/dev/ttyS0 2>&1
  64. if test -d /sys/kernel/debug/gcov ; then
  65. cp -ar /sys/kernel/debug/gcov /tmp/logs/
  66. # these are broken as they're updated while being read ...
  67. find /tmp/logs/gcov/ -wholename '*kernel/gcov/*' -print0 | xargs -0 rm
  68. fi
  69. #bash </dev/ttyS0 >/dev/ttyS0 2>&1
  70. fi
  71. # and shut down the machine again
  72. halt -f -p