License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / tools / testing / selftests / cpufreq / special-tests.sh
CommitLineData
1e4c2830 1#!/bin/bash
b2441318 2# SPDX-License-Identifier: GPL-2.0
1e4c2830
VK
3#
4# Special test cases reported by people
5
6# Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2
7
8# protect against multiple inclusion
9if [ $FILE_SPECIAL ]; then
10 return 0
11else
12 FILE_SPECIAL=DONE
13fi
14
15source cpu.sh
16source cpufreq.sh
17source governor.sh
18
19# Test 1
20# $1: policy
21__simple_lockdep()
22{
23 # switch to ondemand
24 __switch_governor $1 "ondemand"
25
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
31 fi
32
33 cat $ondir/*
34
35 # switch to conservative
36 __switch_governor $1 "conservative"
37}
38
39simple_lockdep()
40{
41 printf "** Test: Running ${FUNCNAME[0]} **\n"
42
43 for_each_policy __simple_lockdep
44}
45
46# Test 2
47# $1: policy
48__concurrent_lockdep()
49{
50 for i in `seq 0 100`; do
51 __simple_lockdep $1
52 done
53}
54
55concurrent_lockdep()
56{
57 printf "** Test: Running ${FUNCNAME[0]} **\n"
58
59 for_each_policy_concurrent __concurrent_lockdep
60}
61
62# Test 3
63quick_shuffle()
64{
65 # this is called concurrently from governor_race
66 for I in `seq 1000`
67 do
68 echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor &
69 echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor &
70 done
71}
72
73governor_race()
74{
75 printf "** Test: Running ${FUNCNAME[0]} **\n"
76
77 # run 8 concurrent instances
78 for I in `seq 8`
79 do
80 quick_shuffle &
81 done
82}
83
84# Test 4
85# $1: cpu
86hotplug_with_updates_cpu()
87{
88 local filepath="$CPUROOT/$1/cpufreq"
89
90 # switch to ondemand
91 __switch_governor_for_cpu $1 "ondemand"
92
93 for i in `seq 1 5000`
94 do
95 reboot_cpu $1
96 done &
97
98 local freqs=$(cat $filepath/scaling_available_frequencies)
99 local oldfreq=$(cat $filepath/scaling_min_freq)
100
101 for j in `seq 1 5000`
102 do
103 # Set all frequencies one-by-one
104 for freq in $freqs; do
105 echo $freq > $filepath/scaling_min_freq
106 done
107 done
108
109 # restore old freq
110 echo $oldfreq > $filepath/scaling_min_freq
111}
112
113hotplug_with_updates()
114{
115 for_each_non_boot_cpu hotplug_with_updates_cpu
116}