On 24 February 2015 at 01:58, Lisa Nguyen <lisa.ngu...@linaro.org> wrote:
> [Adding Mike Turquette as another possible reviewer]
>
> On 7 February 2015 at 16:08, Larry Bassel <larry.bas...@linaro.org> wrote:
>> Add test which checks and prints scheduler domain flags.
>>
>> Signed-off-by: Larry Bassel <larry.bas...@linaro.org>
>> ---
>>  cputopology/cputopology_03.sh  | 74 
>> ++++++++++++++++++++++++++++++++++++++++++
>>  cputopology/cputopology_03.txt |  1 +
>>  2 files changed, 75 insertions(+)
>>  create mode 100755 cputopology/cputopology_03.sh
>>  create mode 100644 cputopology/cputopology_03.txt
>>
>> diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh
>> new file mode 100755
>> index 0000000..0fc2771
>> --- /dev/null
>> +++ b/cputopology/cputopology_03.sh
>> @@ -0,0 +1,74 @@
>> +#!/bin/sh
>> +#
>> +# PM-QA validation test suite for the power management on Linux
>> +#
>> +# Copyright (C) 2015, Linaro Limited.
>> +#
>> +# This program is free software; you can redistribute it and/or
>> +# modify it under the terms of the GNU General Public License
>> +# as published by the Free Software Foundation; either version 2
>> +# of the License, or (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program; if not, write to the Free Software
>> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
>> 02110-1301, USA.
>> +#
>> +# Contributors:
>> +#     Larry Bassel <larry.bas...@linaro.org>
>> +#
>> +
>> +# URL : 
>> https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#cputopology_03
>> +
>> +. ../include/functions.sh
>> +
>> +is_flag_set() {
>> +    flag=$1
>> +    mask=$2
>> +    message=$3
>> +
>> +    value=$(( $flag & $mask ))
>> +
>> +    if [ $value -ne 0 ]; then
>> +       echo "$message set"
>> +    else
>> +       echo "$message not set"
>> +    fi
>> +}
>> +
>> +check_sched_domain_flags() {
>> +
>> +    cpu_num=$1
>> +    domain_num=$2
>> +
>> +    
>> sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
>> +    val=$(cat $sched_domain_flags)
>> +
>> +    check "sched_domain_flags (domain $domain_num)" "test \"$val\" != 
>> \"-1\""
>> +    printf "domain$domain_num flag 0x%x\n" $val
>> +
>> +    is_flag_set $val  0x80  "domain$domain_num share cpu capacity flag"
>> +    is_flag_set $val  0x100  "domain$domain_num share power domain flag"
>> +    is_flag_set $val  0x200  "domain$domain_num share cpu package resources 
>> flag"
>> +}
>> +
>> +check_all_sched_domain_flags() {
>> +
>> +    n=0
>> +
>> +    if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
>> +       return
>> +    fi
>
> That looks weird with the ! hanging outside of the expression; it's
> usually inside the [ ]. Can you store the
> /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make
> that small code block nicer and easier to maintain if the path needs
> to be changed in the future.
>
> Also, please use the log_skip function to display an "error" message
> to stdout before the return keyword if the directory doesn't exist.
>
>> +    while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
>> +        check_sched_domain_flags $1 $n
>> +       n=$(( n + 1))
>> +    done
>> +}
>
> Again, if there's a way to store the path into a variable, it'd be nice.
>
>> +
>> +for_each_cpu check_all_sched_domain_flags 1 || exit 1
>> +test_status_show
>> diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt
>> new file mode 100644
>> index 0000000..e43de69
>> --- /dev/null
>> +++ b/cputopology/cputopology_03.txt
>> @@ -0,0 +1 @@
>> +test that the sched_domain files are present and show the topology related 
>> flags
>> --
>> 1.9.1
>
> Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see
> if his tests make sense? I can't accept Larry's patch without another
> person's ack or reviewed-by and in need of a second opinion. Thanks.

I'm going to test it on my cb2 tomorrow and will give you a feedback

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to