Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / cpufreq / special-tests.sh
blob8d40505dc4682c0ca44be1c3fcebb2f6aa1ee932
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Special test cases reported by people
6 # Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2
8 # protect against multiple inclusion
9 if [ $FILE_SPECIAL ]; then
10 return 0
11 else
12 FILE_SPECIAL=DONE
15 source cpu.sh
16 source cpufreq.sh
17 source governor.sh
19 # Test 1
20 # $1: policy
21 __simple_lockdep()
23 # switch to ondemand
24 __switch_governor $1 "ondemand"
26 # cat ondemand files
27 local ondir=$(find_gov_directory $1 "ondemand")
28 if [ -z $ondir ]; then
29 printf "${FUNCNAME[0]}Ondemand directory not created, quit"
30 return
33 cat $ondir/*
35 # switch to conservative
36 __switch_governor $1 "conservative"
39 simple_lockdep()
41 printf "** Test: Running ${FUNCNAME[0]} **\n"
43 for_each_policy __simple_lockdep
46 # Test 2
47 # $1: policy
48 __concurrent_lockdep()
50 for i in `seq 0 100`; do
51 __simple_lockdep $1
52 done
55 concurrent_lockdep()
57 printf "** Test: Running ${FUNCNAME[0]} **\n"
59 for_each_policy_concurrent __concurrent_lockdep
62 # Test 3
63 quick_shuffle()
65 # this is called concurrently from governor_race
66 for I in `seq 1000`
68 echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor &
69 echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor &
70 done
73 governor_race()
75 printf "** Test: Running ${FUNCNAME[0]} **\n"
77 # run 8 concurrent instances
78 for I in `seq 8`
80 quick_shuffle &
81 done
84 # Test 4
85 # $1: cpu
86 hotplug_with_updates_cpu()
88 local filepath="$CPUROOT/$1/cpufreq"
90 # switch to ondemand
91 __switch_governor_for_cpu $1 "ondemand"
93 for i in `seq 1 5000`
95 reboot_cpu $1
96 done &
98 local freqs=$(cat $filepath/scaling_available_frequencies)
99 local oldfreq=$(cat $filepath/scaling_min_freq)
101 for j in `seq 1 5000`
103 # Set all frequencies one-by-one
104 for freq in $freqs; do
105 echo $freq > $filepath/scaling_min_freq
106 done
107 done
109 # restore old freq
110 echo $oldfreq > $filepath/scaling_min_freq
113 hotplug_with_updates()
115 for_each_non_boot_cpu hotplug_with_updates_cpu