From patchwork Mon Oct 3 08:18:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 4481 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2B62223F6E for ; Mon, 3 Oct 2011 08:20:47 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1B7EFA181A0 for ; Mon, 3 Oct 2011 08:20:47 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 5so6812441bke.11 for ; Mon, 03 Oct 2011 01:20:47 -0700 (PDT) Received: by 10.223.94.134 with SMTP id z6mr5039926fam.8.1317630046786; Mon, 03 Oct 2011 01:20:46 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.23.170 with SMTP id n10cs6254laf; Mon, 3 Oct 2011 01:20:46 -0700 (PDT) Received: by 10.216.138.213 with SMTP id a63mr3504306wej.113.1317630046069; Mon, 03 Oct 2011 01:20:46 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp11.smtpout.orange.fr. [80.12.242.133]) by mx.google.com with ESMTP id v21si9918085wec.41.2011.10.03.01.20.45; Mon, 03 Oct 2011 01:20:46 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.133 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.133; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.133 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([90.60.119.82]) by mwinf5d34 with ME id g8Lj1h0021mlJK6038Ll3l; Mon, 03 Oct 2011 10:20:45 +0200 X-ME-engine: default From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [pm-qa 04/10] check the cpu state is reflected in sysfs Date: Mon, 3 Oct 2011 10:18:29 +0200 Message-Id: <1317629915-31767-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1317629915-31767-1-git-send-email-daniel.lezcano@linaro.org> References: <1317629915-31767-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_02 + +source ../include/functions.sh + +check_state() { + local cpu=$1 + local dirpath=$CPU_PATH/$1 + local state= + shift 1 + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + set_offline $cpu + state=$(get_online $cpu) + + check "cpu is offline" "test $state -eq 0" + if [ $? -ne 0 ]; then + set_online $cpu + return 1 + fi + + set_online $cpu + state=$(get_online $cpu) + + check "cpu is online" "test $state -eq 1" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 +} + +for_each_cpu check_state diff --git a/cpuhotplug/cpuhotplug_02.txt b/cpuhotplug/cpuhotplug_02.txt new file mode 100644 index 0000000..4047c3a --- /dev/null +++ b/cpuhotplug/cpuhotplug_02.txt @@ -0,0 +1 @@ +test the cpu state is reflected in sysfs diff --git a/include/functions.sh b/include/functions.sh index b2a8b47..b34d49b 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -175,6 +175,27 @@ get_min_frequency() { cat $dirpath } +set_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + echo 1 > $dirpath/online +} + +set_offline() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + echo 0 > $dirpath/online +} + +get_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + cat $dirpath/online +} + check() { local descr=$1