aboutsummaryrefslogtreecommitdiff
path: root/special-tests.sh
blob: 868b4ac5a73d3f7c5069bc7e9cade049d0a3fb9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#
# Special test cases reported by people

# Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2

# protect against multiple inclusion
if [ $FILE_SPECIAL ]; then
	return 0
else
	FILE_SPECIAL=DONE
fi

source cpu.sh
source cpufreq.sh
source governor.sh

# Test 1
quick_shuffle()
{
	# this is called concurrently from governor_race
	for I in `seq 1000`
	do
		echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &
		echo userspace | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &
	done
}

governor_race()
{
	echo "** Test: Running ${FUNCNAME[0]} **"
	echo ""

	# run 8 concurrent instances
	for I in `seq 8`
	do
		quick_shuffle &
	done
}

# Test 2
# $1: cpu
__simple_lockdep()
{
	# switch to ondemand
	__switch_governor $1 "ondemand"

	# cat ondemand files
	local ondir=$(find_gov_directory $1 "ondemand")
	if [ -z $ondir ]; then
		echo "${FUNCNAME[0]}Ondemand directory not created, quit"
		return
	fi

	cat $ondir/*

	# switch to conservative
	__switch_governor $1 "conservative"
}

simple_lockdep()
{
	echo "** Test: Running ${FUNCNAME[0]} **"
	echo ""

	for_each_cpu __simple_lockdep
}

# Test 3
# $1: cpu
hotplug_with_updates_cpu()
{
	local filepath="$CPU_PATH/$1/cpufreq"

	# switch to ondemand
	__switch_governor $1 "ondemand"

	for i in `seq 1 5000`
	do
		offline_online_cpu $1
	done &

	local freqs=$(cat $filepath/scaling_available_frequencies)
	local oldfreq=$(cat $filepath/scaling_min_freq)

	for j in `seq 1 5000`
	do
		# Set all frequencies one-by-one
		for freq in $freqs; do
			echo $freq > $filepath/scaling_min_freq
		done
	done

	# restore old freq
	echo $oldfreq > $filepath/scaling_min_freq
}

hotplug_with_updates()
{
	for_each_non_boot_cpu hotplug_with_updates_cpu
}

# Test 4
# $1: cpu
__concurrent_lockdep()
{
	for i in `seq 0 100`; do
		# switch to ondemand
		__switch_governor $1 "ondemand"

		# cat ondemand files
		local ondir=$(find_gov_directory $1 "ondemand")
		if [ -z $ondir ]; then
			echo "${FUNCNAME[0]}Ondemand directory not created, quit"
			return
		fi

		cat $ondir/*

		# switch to conservative
		__switch_governor $1 "conservative"
	done
}

concurrent_lockdep()
{
	echo "** Test: Running ${FUNCNAME[0]} **"
	echo ""

	for_each_cpu_concurrent __concurrent_lockdep
}