Linaro Power Management Work Group QA
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..73d1f66
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+all:
+ @(cd testcases; $(MAKE) all)
+
+clean:
+ @(cd testcases; $(MAKE) clean)
+
diff --git a/run_template b/run_template
new file mode 100644
index 0000000..8c866f9
--- /dev/null
+++ b/run_template
@@ -0,0 +1,7 @@
+pm-qa-cexists proof_o_concept PM-list_c_states.sh
+pm-qa-pexists proof_o_concept PM-list_p_states.sh
+pm-qa-availfreq01 cpufreq avail_freq01.sh
+pm-qa-availfreq02 cpufreq avail_freq02.sh
+pm-qa-availgov01 cpufreq avail_gov01.sh
+pm-qa-availgov02 cpufreq avail_gov02.sh
+pm-qa-cpuidle cpuidle test_usb_cpuidle /dev/sdb 5 10000
diff --git a/testcases.awk b/testcases.awk
new file mode 100644
index 0000000..5459f48
--- /dev/null
+++ b/testcases.awk
@@ -0,0 +1,31 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # For a series of power management related test, cycle through and
+ # execute. Each test to be executed is in file testcases where the
+ # following columns make sense....
+ # column 1: name of the test case
+ # column 2: sub directory housing the test
+ # column 3: name of file for the test case
+ # column 4: from column 4 onwards, any arguments to pass on to the test
+###
+{
+ printf $1 ": "
+ cmd = "cd ./testcases/"$2 " ; sudo ./"$3 " " substr($0, length($1 $2 $3) +4)
+ system(cmd)
+ printf "\n"
+}
+
diff --git a/testcases/Makefile b/testcases/Makefile
new file mode 100644
index 0000000..364ef1f
--- /dev/null
+++ b/testcases/Makefile
@@ -0,0 +1,30 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+tmp := $(shell find -maxdepth 2 -mindepth 2 -name Makefile)
+paths := $(subst Makefile, ,$(tmp))
+SUBDIRS := $(subst ./, ,$(paths))
+
+.PHONY: $(SUBDIRS)
+
+all:
+ @for X in $(SUBDIRS) ; do $(MAKE) -C $$X all ; done;
+
+
+clean:
+ @for X in $(SUBDIRS) ; do $(MAKE) -C $$X clean; done;
+
+
+
diff --git a/testcases/cpufreq/Makefile b/testcases/cpufreq/Makefile
new file mode 100644
index 0000000..6e537ca
--- /dev/null
+++ b/testcases/cpufreq/Makefile
@@ -0,0 +1,22 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+testcases = avail_freq01.sh avail_freq02.sh avail_gov01.sh avail_gov02.sh
+
+all:
+ @for t in $(testcases) ; do chmod +x $$t; done;
+
+clean:
+ @for t in $(testcases) ; do chmod -x $$t; done;
diff --git a/testcases/cpufreq/avail_freq01.sh b/testcases/cpufreq/avail_freq01.sh
new file mode 100644
index 0000000..489c1ea
--- /dev/null
+++ b/testcases/cpufreq/avail_freq01.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # To test ability to monitor and/or alter cpu frequency on the board, assure
+ # basic files are there.
+###
+
+if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies ] ; then
+ echo "NA no added frequencies"
+ exit -1;
+ fi
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ] ; then
+ echo "FAIL missing current frequency file"
+ exit -1;
+ fi
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed ] ; then
+ echo "FAIL missing file to set frequency speed"
+ exit -1;
+ fi
+ echo "PASS `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies `"
+ exit 0;
+else
+ echo "NA no added frequencies"
+ exit -1;
+fi
+
diff --git a/testcases/cpufreq/avail_freq02.sh b/testcases/cpufreq/avail_freq02.sh
new file mode 100644
index 0000000..cb23869
--- /dev/null
+++ b/testcases/cpufreq/avail_freq02.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # Track how much time it takes to cycle through a loop 1000 times at this current frequency
+###
+loop_it() {
+ LOOP_LIMIT=1000
+ time while ( test $LOOP_LIMIT -ge 1 ); do
+ LOOP_LIMIT=$(( $LOOP_LIMIT - 1 ))
+ done
+}
+
+
+###
+ # set governor to be user space governor which allows you to manually alter the frequency
+###
+echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+if [ $? != 0 ]; then
+ echo "FAIL could not change governor to userspace, remained `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`"
+ exit -1
+fi
+
+
+###
+ # Now loop through, changing the cpu frequency to available frequencies. Sleep for a
+ # period of about 5 seconds each time it's set to a new frequency to allow the system
+ # to settle down.
+###
+for LOOP_FREQ in `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`
+do
+ echo $LOOP_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
+ if [ $? != 0 ]; then
+ echo "FAIL could not write freq for $LOOP_FREQ"
+ exit -1
+ fi
+ sleep 5
+ if [ `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` != $LOOP_FREQ ]; then
+ echo "FAIL could not change freq to $LOOP_FREQ remained `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`"
+ exit -1
+ fi
+ loop_it
+done
+
+echo PASS
+
diff --git a/testcases/cpufreq/avail_gov01.sh b/testcases/cpufreq/avail_gov01.sh
new file mode 100644
index 0000000..89fb002
--- /dev/null
+++ b/testcases/cpufreq/avail_gov01.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # Simple test to assure governor support for cpu frequency altering is possible.
+ # Assure the files are available that allow you to switch between governors.
+###
+if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ] ; then
+ echo "NA no added frequencies"
+ exit -1;
+ fi
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] ; then
+ echo "FAIL missing scaling governor file"
+ exit -1;
+ fi
+ echo "PASS `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors `"
+ exit 0;
+else
+ echo "NA no added frequencies"
+ exit -1;
+fi
+
diff --git a/testcases/cpufreq/avail_gov02.sh b/testcases/cpufreq/avail_gov02.sh
new file mode 100644
index 0000000..cfc9a56
--- /dev/null
+++ b/testcases/cpufreq/avail_gov02.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+
+###
+ # For each available governor, can we change the cpu governor to
+ # that new value? Sleep a few seconds after changing to allow system
+ # to settle down.
+###
+
+for i in `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors`
+do
+ echo $i > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+ if [ $? != 0 ]; then
+ echo "FAIL can not write governor for $i"
+ exit -1
+ fi
+ sleep 5
+ if [ `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` != $i ]; then
+ echo "FAIL could not change governor to $i"
+ exit -1
+ fi
+done
+
+echo PASS
+
+
diff --git a/testcases/cpuhotplug/Makefile b/testcases/cpuhotplug/Makefile
new file mode 100644
index 0000000..e0ff787
--- /dev/null
+++ b/testcases/cpuhotplug/Makefile
@@ -0,0 +1,26 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Vincent Guittot <vincent.guittot@linaro.org>
+ # - initial API and implementation
+ #
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - editorial and/or harness conformance changes
+ #******************************************************************************/
+
+testcases = cpu_hotplug_latency.sh
+
+all:
+ @for t in $(testcases) ; do chmod +x $$t; done;
+
+clean:
+ @for t in $(testcases) ; do chmod -x $$t; done;
+ rm -rf test_load.txt
diff --git a/testcases/cpuhotplug/cpu_hotplug_latency.sh b/testcases/cpuhotplug/cpu_hotplug_latency.sh
new file mode 100644
index 0000000..bbb1fa9
--- /dev/null
+++ b/testcases/cpuhotplug/cpu_hotplug_latency.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Vincent Guittot <vincent.guittot@linaro.org>
+ # - initial API and implementation
+ #
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - editorial and/or harness conformance changes
+ #******************************************************************************/
+
+PWD=pwd
+
+echo 0 > /sys/kernel/debug/tracing/tracing_on
+
+echo 1 > /sys/kernel/debug/tracing/events/cpu_hotplug/enable
+
+# echo "**** TEST LOADED CPU*****"
+
+LOOP=10
+MAX_PROCESS=$LOOP
+
+while ( test $LOOP -ge 0 ); do
+
+ PROCESS=$LOOP
+
+ while ( test $PROCESS -lt $MAX_PROCESS ); do
+ # echo "**** Start cyclictest *****"
+ cyclictest -D 180 -t 10 -q > /dev/null &
+ PROCESS=$(( $PROCESS + 1 ))
+ done
+
+ ILOOP=20
+ echo 1 > /sys/kernel/debug/tracing/tracing_on
+
+ while ( test $ILOOP -ge 1 ); do
+
+ # echo "**** TEST " $ILOOP " *****"
+ # echo ""
+
+ sleep 1
+
+# echo -n "Disabling CPU1 ... "
+ echo 0 > /sys/devices/system/cpu/cpu1/online
+ # echo "Disable"
+
+ sleep 1
+
+# echo -n "Enabling CPU1 ... "
+ echo 1 > /sys/devices/system/cpu/cpu1/online
+ # echo "Enable"
+
+ sleep 1
+
+ ILOOP=$(( $ILOOP - 1 ))
+
+ done
+
+ echo 0 > /sys/kernel/debug/tracing/tracing_on
+
+ LIST=`ps | grep cyclictest | awk '{ print $1 }'`
+
+ for I in $LIST; do
+ # echo "**** Kill cyclictest *****"
+ kill $I
+ done
+
+ LOOP=$(( $LOOP - 1 ))
+
+done
+
+cat /sys/kernel/debug/tracing/trace > $PWD/test_load.txt
+
+echo "PASS"
diff --git a/testcases/cpuidle/Makefile b/testcases/cpuidle/Makefile
new file mode 100644
index 0000000..6e3e784
--- /dev/null
+++ b/testcases/cpuidle/Makefile
@@ -0,0 +1,28 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Amit Daniel <amit.kachhap@linaro.org>
+ # - initial API and implementation
+ #
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - editorial and/or harness conformance changes
+ #******************************************************************************/
+
+CC=gcc
+CFLAGS=-Wall
+
+all: test_usb_cpuidle
+
+clean:
+ rm -f test_usb_cpuidle test_usb_cpuidle.o
+
+
+
diff --git a/testcases/cpuidle/test_usb_cpuidle.c b/testcases/cpuidle/test_usb_cpuidle.c
new file mode 100644
index 0000000..6e2e5ab
--- /dev/null
+++ b/testcases/cpuidle/test_usb_cpuidle.c
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (C) 2011, Linaro Limited.
+ *
+ * This file is part of PM QA.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Amit Daniel <amit.kachhap@linaro.org>
+ * - initial API and implementation
+ *
+ * Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ * - editorial and/or harness conformance changes
+ *******************************************************************************/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+//void usleep(unsigned long usec);
+
+
+#define MAX_COUNT 1024
+int main(int argc, char *argv[])
+{
+ int err = 0;
+ FILE *fp = 0;
+ int byteCount = 0;
+ int iterCount = 0;
+ char dataArray[MAX_COUNT];
+/*
+ printf("\nUSB mass storage test: parameters --device_name, byte to read, times to run\n");
+*/
+ if(argc!=4) {
+ printf("Error: No of argumets not proper\n");
+ return 0;
+ }
+ byteCount = atoi(argv[2]);
+ iterCount = atoi(argv[3]);
+/*
+ printf("Device to open=%s, bytes read =%d, iteration =%d\n",argv[1], byteCount, iterCount);
+*/
+ fp = fopen(argv[1], "r");
+ if(fp == NULL)
+ {
+ printf("Error: Invalid device name passed\n");
+ return 0;
+ }
+
+ /*Init random generator*/
+ srand((unsigned int)time(NULL));
+ while(iterCount != 0) {
+ /*read from the begining*/
+ err = fread(dataArray,1,byteCount,fp);
+ if(err < 0) {
+ printf("Error: Data read failed\n");
+ return 0;
+ }
+ fseek(fp,((iterCount%5)*100*1024), SEEK_SET);
+ if(err < 0) {
+ printf("Error: Data seek failed\n");
+ return 0;
+ }
+
+ /*read from somewhere in the middle*/
+ err = fread(dataArray,1,byteCount,fp);
+ if(err < 0) {
+ printf("Error: Data read failed\n");
+ return 0;
+ }
+ fseek(fp, byteCount, SEEK_END);
+ if(err < 0) {
+ printf("Error: Data seek failed\n");
+ return 0;
+ }
+
+ /*read from the end*/
+ err = fread(dataArray,1,byteCount,fp);
+ if(err < 0) {
+ printf("Error: Data read failed\n");
+ return 0;
+ }
+
+ rewind(fp);
+ iterCount--;
+ fclose(fp);
+ /*sleep between 1ms to 50ms*/
+ usleep(((rand()%50) + 1)*1000);
+ fp = fopen(argv[1], "r");
+ }
+ fclose(fp);
+ return 0;
+}
diff --git a/testcases/proof_o_concept/Makefile b/testcases/proof_o_concept/Makefile
new file mode 100644
index 0000000..ce9339d
--- /dev/null
+++ b/testcases/proof_o_concept/Makefile
@@ -0,0 +1,22 @@
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+testcases = PM-list_c_states.sh PM-list_p_states.sh
+
+all:
+ @for t in $(testcases) ; do chmod +x $$t; done;
+
+clean:
+ @for t in $(testcases) ; do chmod -x $$t; done;
diff --git a/testcases/proof_o_concept/PM-list_c_states.sh b/testcases/proof_o_concept/PM-list_c_states.sh
new file mode 100644
index 0000000..207da56
--- /dev/null
+++ b/testcases/proof_o_concept/PM-list_c_states.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # Determine which CPUidle C States are defined on this system by
+ # cycling through the sysfs files for cpuidle.
+###
+
+for state in `cat /sys/devices/system/cpu/cpu0/cpuidle/state*/name`
+do
+ test_case=$test_case' '$state
+done
+
+echo $test_case
diff --git a/testcases/proof_o_concept/PM-list_p_states.sh b/testcases/proof_o_concept/PM-list_p_states.sh
new file mode 100644
index 0000000..f6e9222
--- /dev/null
+++ b/testcases/proof_o_concept/PM-list_p_states.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#/*******************************************************************************
+ # Copyright (C) 2011, Linaro Limited.
+ #
+ # This file is part of PM QA.
+ #
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Torez Smith <torez.smith@linaro.org> (IBM Corporation)
+ # - initial API and implementation
+ #******************************************************************************/
+
+###
+ # Determine which CPUidle P States are defined on this system by
+ # cycling through the sysfs files for cpufreq.
+###
+
+echo `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`
+