Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 #
0004 # Special test cases reported by people
0005 
0006 # Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2
0007 
0008 # protect against multiple inclusion
0009 if [ $FILE_SPECIAL ]; then
0010         return 0
0011 else
0012         FILE_SPECIAL=DONE
0013 fi
0014 
0015 source cpu.sh
0016 source cpufreq.sh
0017 source governor.sh
0018 
0019 # Test 1
0020 # $1: policy
0021 __simple_lockdep()
0022 {
0023         # switch to ondemand
0024         __switch_governor $1 "ondemand"
0025 
0026         # cat ondemand files
0027         local ondir=$(find_gov_directory $1 "ondemand")
0028         if [ -z $ondir ]; then
0029                 printf "${FUNCNAME[0]}Ondemand directory not created, quit"
0030                 return
0031         fi
0032 
0033         cat $ondir/*
0034 
0035         # switch to conservative
0036         __switch_governor $1 "conservative"
0037 }
0038 
0039 simple_lockdep()
0040 {
0041         printf "** Test: Running ${FUNCNAME[0]} **\n"
0042 
0043         for_each_policy __simple_lockdep
0044 }
0045 
0046 # Test 2
0047 # $1: policy
0048 __concurrent_lockdep()
0049 {
0050         for i in `seq 0 100`; do
0051                 __simple_lockdep $1
0052         done
0053 }
0054 
0055 concurrent_lockdep()
0056 {
0057         printf "** Test: Running ${FUNCNAME[0]} **\n"
0058 
0059         for_each_policy_concurrent __concurrent_lockdep
0060 }
0061 
0062 # Test 3
0063 quick_shuffle()
0064 {
0065         # this is called concurrently from governor_race
0066         for I in `seq 1000`
0067         do
0068                 echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor &
0069                 echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor &
0070         done
0071 }
0072 
0073 governor_race()
0074 {
0075         printf "** Test: Running ${FUNCNAME[0]} **\n"
0076 
0077         # run 8 concurrent instances
0078         for I in `seq 8`
0079         do
0080                 quick_shuffle &
0081         done
0082 }
0083 
0084 # Test 4
0085 # $1: cpu
0086 hotplug_with_updates_cpu()
0087 {
0088         local filepath="$CPUROOT/$1/cpufreq"
0089 
0090         # switch to ondemand
0091         __switch_governor_for_cpu $1 "ondemand"
0092 
0093         for i in `seq 1 5000`
0094         do
0095                 reboot_cpu $1
0096         done &
0097 
0098         local freqs=$(cat $filepath/scaling_available_frequencies)
0099         local oldfreq=$(cat $filepath/scaling_min_freq)
0100 
0101         for j in `seq 1 5000`
0102         do
0103                 # Set all frequencies one-by-one
0104                 for freq in $freqs; do
0105                         echo $freq > $filepath/scaling_min_freq
0106                 done
0107         done
0108 
0109         # restore old freq
0110         echo $oldfreq > $filepath/scaling_min_freq
0111 }
0112 
0113 hotplug_with_updates()
0114 {
0115         for_each_non_boot_cpu hotplug_with_updates_cpu
0116 }