lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <11499360abc3e627800e286050d9388395a2d1ff.1484289212.git.viresh.kumar@linaro.org>
Date:   Fri, 13 Jan 2017 12:06:46 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Rafael Wysocki <rjw@...ysocki.net>, Shuah Khan <shuah@...nel.org>
Cc:     linaro-kernel@...ts.linaro.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Vincent Guittot <vincent.guittot@...aro.org>,
        linux-kselftest@...r.kernel.org,
        Viresh Kumar <viresh.kumar@...aro.org>
Subject: [PATCH 2/4] selftest: cpufreq: Add suspend/resume/hibernate support

This patch adds support to test basic suspend/resume and hibernation to
the cpufreq selftests.

Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
 tools/testing/selftests/cpufreq/cpufreq.sh | 40 ++++++++++++++++++++++++++++++
 tools/testing/selftests/cpufreq/main.sh    | 14 +++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/cpufreq/cpufreq.sh b/tools/testing/selftests/cpufreq/cpufreq.sh
index 2b8b05aaa874..1ed3832030b4 100755
--- a/tools/testing/selftests/cpufreq/cpufreq.sh
+++ b/tools/testing/selftests/cpufreq/cpufreq.sh
@@ -199,3 +199,43 @@ cpufreq_basic_tests()
 	# Test all governors
 	shuffle_governors_for_all_cpus 1
 }
+
+# Suspend/resume
+# $1: "suspend" or "hibernate", $2: loop count
+do_suspend()
+{
+	printf "** Test: Running ${FUNCNAME[0]}: Trying $1 for $2 loops **\n\n"
+
+	# Is the directory available
+	if [ ! -d $SYSFS/power/ -o ! -f $SYSFS/power/state ]; then
+		printf "$SYSFS/power/state not available\n"
+		return 1
+	fi
+
+	if [ $1 = "suspend" ]; then
+		filename="mem"
+	elif [ $1 = "hibernate" ]; then
+		filename="disk"
+	else
+		printf "$1 is not a valid option\n"
+		return 1
+	fi
+
+	if [ -n $filename ]; then
+		present=$(cat $SYSFS/power/state | grep $filename)
+
+		if [ -z "$present" ]; then
+			printf "Tried to $1 but $filename isn't present in $SYSFS/power/state\n"
+			return 1;
+		fi
+
+		for i in `seq 1 $2`; do
+			printf "Starting $1\n"
+			echo $filename > $SYSFS/power/state
+			printf "Came out of $1\n"
+
+			printf "Do basic tests after finishing $1 to verify cpufreq state\n\n"
+			cpufreq_basic_tests
+		done
+	fi
+}
diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/selftests/cpufreq/main.sh
index 3224652ccbd4..9ff662f67ea4 100755
--- a/tools/testing/selftests/cpufreq/main.sh
+++ b/tools/testing/selftests/cpufreq/main.sh
@@ -15,7 +15,9 @@ helpme()
 	printf "Usage: $0 [-h] [-to args]
 	[-h <help>]
 	[-o <output-file-for-dump>]
-	[-t <basic: Basic cpufreq testing>]
+	[-t <basic: Basic cpufreq testing
+	     suspend: suspend/resume,
+	     hibernate: hibernate/resume>]
 	\n"
 	exit 2
 }
@@ -61,7 +63,7 @@ parse_arguments()
 				helpme
 				;;
 
-			t) # --func_type (Function to perform: basic (default: basic))
+			t) # --func_type (Function to perform: basic, suspend, hibernate (default: basic))
 				FUNC=$OPTARG
 				;;
 
@@ -91,6 +93,14 @@ do_test()
 		cpufreq_basic_tests
 		;;
 
+		"suspend")
+		do_suspend "suspend" 1
+		;;
+
+		"hibernate")
+		do_suspend "hibernate" 1
+		;;
+
 		*)
 		echo "Invalid [-f] function type"
 		helpme
-- 
2.7.1.410.g6faf27b

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ