kvm-test-1-run-batch.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Carry out a kvm-based run for the specified batch of scenarios, which
  5. # might have been built by --build-only kvm.sh run.
  6. #
  7. # Usage: kvm-test-1-run-batch.sh SCENARIO [ SCENARIO ... ]
  8. #
  9. # Each SCENARIO is the name of a directory in the current directory
  10. # containing a ready-to-run qemu-cmd file.
  11. #
  12. # Copyright (C) 2021 Facebook, Inc.
  13. #
  14. # Authors: Paul E. McKenney <paulmck@kernel.org>
  15. T="`mktemp -d ${TMPDIR-/tmp}/kvm-test-1-run-batch.sh.XXXXXX`"
  16. trap 'rm -rf $T' 0
  17. echo ---- Running batch $*
  18. # Check arguments
  19. runfiles=
  20. for i in "$@"
  21. do
  22. if ! echo $i | grep -q '^[^/.a-z]\+\(\.[0-9]\+\)\?$'
  23. then
  24. echo Bad scenario name: \"$i\" 1>&2
  25. exit 1
  26. fi
  27. if ! test -d "$i"
  28. then
  29. echo Scenario name not a directory: \"$i\" 1>&2
  30. exit 2
  31. fi
  32. if ! test -f "$i/qemu-cmd"
  33. then
  34. echo Scenario lacks a command file: \"$i/qemu-cmd\" 1>&2
  35. exit 3
  36. fi
  37. rm -f $i/build.*
  38. touch $i/build.run
  39. runfiles="$runfiles $i/build.run"
  40. done
  41. # Extract settings from the qemu-cmd file.
  42. grep '^#' $1/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
  43. . $T/qemu-cmd-settings
  44. # Start up jitter, start each scenario, wait, end jitter.
  45. echo ---- System running test: `uname -a`
  46. echo ---- Starting kernels. `date` | tee -a log
  47. $TORTURE_JITTER_START
  48. kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk
  49. for i in "$@"
  50. do
  51. echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out
  52. echo > $i/kvm-test-1-run-qemu.sh.out
  53. export TORTURE_AFFINITY=
  54. kvm-get-cpus-script.sh $T/cpuarray.awk $T/cpubatches.awk $T/cpustate
  55. if test -z "${TORTURE_NO_AFFINITY}"
  56. then
  57. cat << ' ___EOF___' >> $T/cpubatches.awk
  58. END {
  59. affinitylist = "";
  60. if (!gotcpus()) {
  61. print "echo No CPU-affinity information, so no taskset command.";
  62. } else if (cpu_count !~ /^[0-9][0-9]*$/) {
  63. print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command.";
  64. } else {
  65. affinitylist = nextcpus(cpu_count);
  66. if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/))
  67. print "echo " scenario ": Bogus CPU-affinity information, so no taskset command.";
  68. else if (!dumpcpustate())
  69. print "echo " scenario ": Could not dump state, so no taskset command.";
  70. else
  71. print "export TORTURE_AFFINITY=" affinitylist;
  72. }
  73. }
  74. ___EOF___
  75. cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`"
  76. affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`"
  77. $affinity_export
  78. fi
  79. kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &
  80. done
  81. for i in $runfiles
  82. do
  83. while ls $i > /dev/null 2>&1
  84. do
  85. :
  86. done
  87. done
  88. echo ---- All kernel runs complete. `date` | tee -a log
  89. $TORTURE_JITTER_STOP