aboutsummaryrefslogtreecommitdiff
path: root/runme.sh
blob: 66f8ad02c205dfc584df7b0c1a7fbad9406e91ae (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
#!/bin/bash

# parameters:
# - $1: Name of the output file with all the logs, dump.txt by default.

source cpu.sh
source governor.sh
source module.sh
source special-tests.sh

FUNC=basic	# do basic tests by default

# Check validity of arguments
USAGE="Usage: $0 [-h] [-odgf args]\n\t[-h <help>]\n\t[-o <output-file-for-dump>]\n\t[-d <driver's module name: only with -f=modtest>] \n\t[-g <governor's module name: only with -f=modtest>] \n\t[-f <basic: cpufreq_basic_tests, sp1: governor_race, sp2: simple_lockdep, sp3: hotplug_with_updates, modtest: driver as module>]\n"

# Parse arguments
parse_arguments()
{
	while getopts hd:g:f:o: arguments 2>/dev/null
	do
		case $arguments in
			h) # --help
				printf "$USAGE"
				exit 0
				;;

			f) # --func_type (Function to perform: basic, sp1, sp2, sp3, default: basic)
				FUNC=$OPTARG
				;;

			o) # --output-file (Output file to store dumps)
				OUTFILE=$OPTARG
				;;

			d) # --driver-mod-name (Name of the driver module)
				DRIVER_MOD=$OPTARG
				;;

			g) # --governor-mod-name (Name of the governor module)
				GOVERNOR_MOD=$OPTARG
				;;

			\?) # getopts issues an error message
				printf "$USAGE "
				exit 1
				;;
		esac
	done
}

# Run isolation test for $FUNC
__run_func()
{
	# Check if CPUs are managed by cpufreq or not
	count=$(count_cpufreq_managed_cpus)

	if [ $count = 0 -a $FUNC != "modtest" ]; then
		echo "No cpu is managed by cpufreq core, exiting"
		return;
	fi

	case "$FUNC" in
		"basic")
		cpufreq_basic_tests
		;;

		"modtest")
		# Do we have modules in place?
		if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
			echo "No driver or governor module passed with -d or -g"
			return;
		fi

		if [ $DRIVER_MOD ]; then
			if [ $GOVERNOR_MOD ]; then
				module_test $DRIVER_MOD $GOVERNOR_MOD
			else
				module_driver_test $DRIVER_MOD
			fi
		else
			if [ $count = 0 ]; then
				echo "No cpu is managed by cpufreq core, exiting"
				return;
			fi

			module_governor_test $GOVERNOR_MOD
		fi
		;;

		"sp1")
		governor_race
		;;

		"sp2")
		simple_lockdep
		;;

		"sp3")
		hotplug_with_updates
		;;

		*)
		echo "Invalid [-f] function type"
		printf "$USAGE"
		;;
	esac
}

# Takes dumps as well
run_func()
{
	if [ $OUTFILE ]; then
		# clear dumps first, we will append it later
		clear_dumps $OUTFILE

		__run_func >> $OUTFILE.txt
		dmesg_dumps $OUTFILE
	else
		__run_func
	fi
}

# Parse isol arguments
parse_arguments $@

# Run requested functions
run_func