vm-run.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. cd "$(dirname $0)"
  3. if [ -z "$TESTDIR" ] ; then
  4. TESTDIR=$(pwd)/../
  5. fi
  6. LOGS=/tmp/hwsim-test-logs
  7. # increase the memory size if you want to run with valgrind, 512 MB works
  8. MEMORY=192
  9. # Some ubuntu systems (notably 12.04) have issues with this - since the guest
  10. # mounts as read-only it should be safe to not specify ,readonly. Override in
  11. # vm-config if needed (see below)
  12. ROTAG=,readonly
  13. # set this to ttyS0 to see kvm messages (if something doesn't work)
  14. KVMOUT=ttyS1
  15. # you can set EPATH if you need anything extra in $PATH inside the VM
  16. #EPATH=/some/dir
  17. # extra KVM arguments, e.g., -s for gdbserver
  18. #KVMARGS=-s
  19. # number of channels each hwsim device supports
  20. CHANNELS=1
  21. test -f vm-config && . vm-config
  22. test -f ~/.wpas-vm-config && . ~/.wpas-vm-config
  23. if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
  24. echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)"
  25. exit 2
  26. fi
  27. if [ -z "$KERNEL" ] ; then
  28. KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
  29. fi
  30. CMD=$TESTDIR/vm/inside.sh
  31. unset RUN_TEST_ARGS
  32. TIMESTAMP=$(date +%s)
  33. DATE=$TIMESTAMP
  34. CODECOV=no
  35. TIMEWARP=0
  36. DELAY=0
  37. CODECOV_DIR=
  38. while [ "$1" != "" ]; do
  39. case $1 in
  40. --timestamp ) shift
  41. TIMESTAMP=$1
  42. shift
  43. ;;
  44. --ext ) shift
  45. DATE=$TIMESTAMP.$1
  46. shift
  47. ;;
  48. --codecov ) shift
  49. CODECOV=yes
  50. ;;
  51. --codecov_dir ) shift
  52. CODECOV_DIR=$1
  53. shift
  54. ;;
  55. --timewrap ) shift
  56. TIMEWARP=1
  57. ;;
  58. --delay ) shift
  59. DELAY=$1
  60. shift
  61. ;;
  62. * )
  63. RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
  64. shift
  65. ;;
  66. esac
  67. done
  68. LOGDIR=$LOGS/$DATE
  69. mkdir -p $LOGDIR
  70. if [ -n "$CODECOV_DIR" ]; then
  71. cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR
  72. cp -a $CODECOV_DIR/alt-hostapd $LOGDIR
  73. cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR
  74. cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR
  75. elif [ $CODECOV = "yes" ]; then
  76. ./build-codecov.sh $LOGDIR || exit 1
  77. else
  78. CODECOV=no
  79. fi
  80. if [ $DELAY -gt 0 ]; then
  81. echo "Wait $DELAY seconds before starting VM"
  82. sleep $DELAY
  83. fi
  84. echo "Starting test run in a virtual machine"
  85. kvm \
  86. -kernel $KERNEL -smp 4 \
  87. $KVMARGS -m $MEMORY -nographic \
  88. -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
  89. -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
  90. -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
  91. -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
  92. -monitor null -serial stdio -serial file:$LOGDIR/console \
  93. -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$RUN_TEST_ARGS"
  94. if [ $CODECOV = "yes" ]; then
  95. echo "Preparing code coverage reports"
  96. ./process-codecov.sh $LOGDIR "" restore
  97. ./combine-codecov.sh $LOGDIR lcov
  98. fi
  99. echo
  100. echo "Test run completed"
  101. echo "Logfiles are at $LOGDIR"
  102. if [ $CODECOV = "yes" ]; then
  103. echo "Code coverage report:"
  104. echo "file://$LOGDIR/lcov/index.html"
  105. fi