special-tests.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Special test cases reported by people
  5. # Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2
  6. # protect against multiple inclusion
  7. if [ $FILE_SPECIAL ]; then
  8. return 0
  9. else
  10. FILE_SPECIAL=DONE
  11. fi
  12. source cpu.sh
  13. source cpufreq.sh
  14. source governor.sh
  15. # Test 1
  16. # $1: policy
  17. __simple_lockdep()
  18. {
  19. # switch to ondemand
  20. __switch_governor $1 "ondemand"
  21. # cat ondemand files
  22. local ondir=$(find_gov_directory $1 "ondemand")
  23. if [ -z $ondir ]; then
  24. printf "${FUNCNAME[0]}Ondemand directory not created, quit"
  25. return
  26. fi
  27. cat $ondir/*
  28. # switch to conservative
  29. __switch_governor $1 "conservative"
  30. }
  31. simple_lockdep()
  32. {
  33. printf "** Test: Running ${FUNCNAME[0]} **\n"
  34. for_each_policy __simple_lockdep
  35. }
  36. # Test 2
  37. # $1: policy
  38. __concurrent_lockdep()
  39. {
  40. for i in `seq 0 100`; do
  41. __simple_lockdep $1
  42. done
  43. }
  44. concurrent_lockdep()
  45. {
  46. printf "** Test: Running ${FUNCNAME[0]} **\n"
  47. for_each_policy_concurrent __concurrent_lockdep
  48. }
  49. # Test 3
  50. quick_shuffle()
  51. {
  52. # this is called concurrently from governor_race
  53. for I in `seq 1000`
  54. do
  55. echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor &
  56. echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor &
  57. done
  58. }
  59. governor_race()
  60. {
  61. printf "** Test: Running ${FUNCNAME[0]} **\n"
  62. # run 8 concurrent instances
  63. for I in `seq 8`
  64. do
  65. quick_shuffle &
  66. done
  67. }
  68. # Test 4
  69. # $1: cpu
  70. hotplug_with_updates_cpu()
  71. {
  72. local filepath="$CPUROOT/$1/cpufreq"
  73. # switch to ondemand
  74. __switch_governor_for_cpu $1 "ondemand"
  75. for i in `seq 1 5000`
  76. do
  77. reboot_cpu $1
  78. done &
  79. local freqs=$(cat $filepath/scaling_available_frequencies)
  80. local oldfreq=$(cat $filepath/scaling_min_freq)
  81. for j in `seq 1 5000`
  82. do
  83. # Set all frequencies one-by-one
  84. for freq in $freqs; do
  85. echo $freq > $filepath/scaling_min_freq
  86. done
  87. done
  88. # restore old freq
  89. echo $oldfreq > $filepath/scaling_min_freq
  90. }
  91. hotplug_with_updates()
  92. {
  93. for_each_non_boot_cpu hotplug_with_updates_cpu
  94. }