diff mbox

[1/2] kselftests: timers: Make set-timer-lat fail more gracefully for !CAP_WAKE_ALARM

Message ID 1427327073-19011-1-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz March 25, 2015, 11:44 p.m. UTC
The set-timer-lat test fails when testing CLOCK_BOOTTIME_ALARM
or CLOCK_REALTIME_ALARM when the user isn't running as root or
with CAP_WAKE_ALARM.

So this patch improves the error checking so we report the
issue more clearly and continue rather then reporting a failure.

Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 tools/testing/selftests/timers/set-timer-lat.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

John Stultz March 26, 2015, 4:29 p.m. UTC | #1
On Thu, Mar 26, 2015 at 4:31 AM, Prarit Bhargava <prarit@redhat.com> wrote:
> On 03/25/2015 07:44 PM, John Stultz wrote:
>> +                     printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
>> +                                     clockstring(clock_id),
>> +                                     flags ? "ABSTIME":"RELTIME");
>
> Something to think about:  Do you want to write these tests to be more human
> readable or machine readable?  In theory with awk I guess it doesn't matter too
> much, however, it is something that we should think about moving forward.

So this came up at ELC in a few discussions. Right now there isn't any
established output format, but there's some nice and simple
infrastructure for counting pass/fails.

However, in talking to Tyler, I know he has started looking at how to
integrate the selftests into our automated infrastructure and was
interested in how we improve the output parsing for reports. So there
is interest in improving this, and I'm open to whatever changes might
be needed (adding extra arguments to the test to put them into "easy
parse" mode or whatever).

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Tyler Baker March 26, 2015, 5:33 p.m. UTC | #2
On 26 March 2015 at 09:29, John Stultz <john.stultz@linaro.org> wrote:
> On Thu, Mar 26, 2015 at 4:31 AM, Prarit Bhargava <prarit@redhat.com> wrote:
>> On 03/25/2015 07:44 PM, John Stultz wrote:
>>> +                     printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
>>> +                                     clockstring(clock_id),
>>> +                                     flags ? "ABSTIME":"RELTIME");
>>
>> Something to think about:  Do you want to write these tests to be more human
>> readable or machine readable?  In theory with awk I guess it doesn't matter too
>> much, however, it is something that we should think about moving forward.
>
> So this came up at ELC in a few discussions. Right now there isn't any
> established output format, but there's some nice and simple
> infrastructure for counting pass/fails.
>
> However, in talking to Tyler, I know he has started looking at how to
> integrate the selftests into our automated infrastructure and was
> interested in how we improve the output parsing for reports. So there
> is interest in improving this, and I'm open to whatever changes might
> be needed (adding extra arguments to the test to put them into "easy
> parse" mode or whatever).

Thanks for looping me in John. My interest in kselftest stems from my
involvement with kernelci.org, a communityservice focused on upstream
kernel validation across multiple architectures. In it's current form,
it is merely build and boot testing boards. However, we are at a point
where we'd like to start running some tests. The automation framework
(LAVA) used to execute these tests essentially uses a regular
expression to parse the test's standard output. This is advantageous
as a test can be written in any language, as long as it produces sane
uniform output.

Ideally, we would like to perform the kernel builds as we do today
along with building all the kseltests present in the tree, and
inserting them into a 'testing' ramdisk for deployment. Once we
successfully boot the platform, we execute all the kselftests, parse
standard out, and report the results. The benefit from this
implementation is that a developer writing a test does have to do
anything 'special' to get his/her test to run once it has been applied
to a upstream tree. I'll explain below some concerns I have about
accomplishing this.

Currently, we have had to write wrappers[1][2] for some kselftests to
be able parse the output. If we can choose/agree on a standard output
format all of this complexity goes away, and then we can dynamically
run kselftests. Integration of new tests will not be needed, as they
all produce output in standard way. I've taken a look at the wiki page
for standardizing output[3] and TAP looks like the good format IMO.

Also, for arch != x86 there are some barriers to overcome to get all
the kselftests cross compiling, which would be nice to have as well.

I realize this may be a good amount of work, so I'd like to help out.
Perhaps working John to convert his timer tests to use TAP output
would be a good starting point?

>
> thanks
> -john

[1] https://git.linaro.org/qa/test-definitions.git/blob/HEAD:/common/scripts/kselftest-runner.sh
[2] https://git.linaro.org/qa/test-definitions.git/blob/HEAD:/common/scripts/kselftest-mqueue.sh
[3] https://kselftest.wiki.kernel.org/standardize_the_test_output

Cheers,

Tyler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
John Stultz April 2, 2015, 3:42 a.m. UTC | #3
On Tue, Mar 31, 2015 at 8:55 AM, Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Hi John,
>
> I am seeing checkpatch warnings on this patch. See below.

Sorry!

> On 03/26/2015 05:31 AM, Prarit Bhargava wrote:
>>
>>
>> On 03/25/2015 07:44 PM, John Stultz wrote:
>>> The set-timer-lat test fails when testing CLOCK_BOOTTIME_ALARM
>>> or CLOCK_REALTIME_ALARM when the user isn't running as root or
>>> with CAP_WAKE_ALARM.
>>>
>>> So this patch improves the error checking so we report the
>>> issue more clearly and continue rather then reporting a failure.
>>>
>>> Cc: Shuah Khan <shuahkh@osg.samsung.com>
>>> Cc: Prarit Bhargava <prarit@redhat.com>
>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>> Cc: Richard Cochran <richardcochran@gmail.com>
>>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>
> WARNING: Duplicate signature
> #115:
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Fixed.

>>> ---
>>>  tools/testing/selftests/timers/set-timer-lat.c | 7 +++++++
>>>  1 file changed, 7 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
>>> index 3ea2eff..dbc9537c 100644
>>> --- a/tools/testing/selftests/timers/set-timer-lat.c
>>> +++ b/tools/testing/selftests/timers/set-timer-lat.c
>>> @@ -139,6 +139,13 @@ int do_timer(int clock_id, int flags)
>>>
>>>      err = timer_create(clock_id, &se, &tm1);
>>>      if (err) {
>>> +            if ((clock_id == CLOCK_REALTIME_ALARM)
>>> +                            || (clock_id == CLOCK_BOOTTIME_ALARM)) {
>>
>> I dunno of there is actually a CodingStyle rule for this, but I've always seen
>> this written with the operator on the first line:
>
> Yes it would be good to fix this one as well when you re-do the patch.

Fixed.

>>
>>       if ((clock_id == CLOCK_REALTIME_ALARM) ||
>>             (clock_id == CLOCK_BOOTTIME_ALARM)) {
>>
>>> +                    printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
>>> +                                    clockstring(clock_id),
>>> +                                    flags ? "ABSTIME":"RELTIME");
>>
>
> WARNING: line over 80 characters
> #130: FILE: tools/testing/selftests/timers/set-timer-lat.c:144:
> +                       printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",

This I probably will leave, as the alternative is breaking the text
string across lines, which checkpatch will also gripe about.

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Tyler Baker April 2, 2015, 5:17 p.m. UTC | #4
On 2 April 2015 at 06:43, Shuah Khan <shuahkh@osg.samsung.com> wrote:
> On 04/02/2015 04:18 AM, Prarit Bhargava wrote:
>>
>>
>> On 03/26/2015 01:33 PM, Tyler Baker wrote:
>>> On 26 March 2015 at 09:29, John Stultz <john.stultz@linaro.org> wrote:
>>>> On Thu, Mar 26, 2015 at 4:31 AM, Prarit Bhargava <prarit@redhat.com> wrote:
>>>>> On 03/25/2015 07:44 PM, John Stultz wrote:
>>>>>> +                     printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
>>>>>> +                                     clockstring(clock_id),
>>>>>> +                                     flags ? "ABSTIME":"RELTIME");
>>>>>
>>>>> Something to think about:  Do you want to write these tests to be more human
>>>>> readable or machine readable?  In theory with awk I guess it doesn't matter too
>>>>> much, however, it is something that we should think about moving forward.
>>>>
>>>> So this came up at ELC in a few discussions. Right now there isn't any
>>>> established output format, but there's some nice and simple
>>>> infrastructure for counting pass/fails.
>>>>
>>>> However, in talking to Tyler, I know he has started looking at how to
>>>> integrate the selftests into our automated infrastructure and was
>>>> interested in how we improve the output parsing for reports. So there
>>>> is interest in improving this, and I'm open to whatever changes might
>>>> be needed (adding extra arguments to the test to put them into "easy
>>>> parse" mode or whatever).
>>>
>>> Thanks for looping me in John. My interest in kselftest stems from my
>>> involvement with kernelci.org, a communityservice focused on upstream
>>> kernel validation across multiple architectures. In it's current form,
>>> it is merely build and boot testing boards. However, we are at a point
>>> where we'd like to start running some tests. The automation framework
>>> (LAVA) used to execute these tests essentially uses a regular
>>> expression to parse the test's standard output. This is advantageous
>>> as a test can be written in any language, as long as it produces sane
>>> uniform output.
>>>
>>> Ideally, we would like to perform the kernel builds as we do today
>>> along with building all the kseltests present in the tree, and
>>> inserting them into a 'testing' ramdisk for deployment. Once we
>>> successfully boot the platform, we execute all the kselftests, parse
>>> standard out, and report the results. The benefit from this
>>> implementation is that a developer writing a test does have to do
>>> anything 'special' to get his/her test to run once it has been applied
>>> to a upstream tree. I'll explain below some concerns I have about
>>> accomplishing this.
>>>
>>> Currently, we have had to write wrappers[1][2] for some kselftests to
>>> be able parse the output. If we can choose/agree on a standard output
>>> format all of this complexity goes away, and then we can dynamically
>>> run kselftests. Integration of new tests will not be needed, as they
>>> all produce output in standard way. I've taken a look at the wiki page
>>> for standardizing output[3] and TAP looks like the good format IMO.
>>>
>>> Also, for arch != x86 there are some barriers to overcome to get all
>>> the kselftests cross compiling, which would be nice to have as well.
>>>
>>> I realize this may be a good amount of work, so I'd like to help out.
>>> Perhaps working John to convert his timer tests to use TAP output
>>> would be a good starting point?
>>
>> John, I could probably do that for you.  I'm always willing to give it a shot.
>>
>
> Improving reporting and output is a good idea, as long as the
> reporting framework doesn't add external dependencies and makes
> it difficult to build and run tests from the kernel git tree
> environment. Being able to run tests on a development system
> is the primary objective for these tests.
>
> As long as the TAP doesn't require additional libraries and
> tools to be installed on the development systems, I will be
> happy with the improvements to reporting and output.

This is a very valid concern IMO. There is a C library for TAP
providers[0] but I agree we want to avoid external libraries as
dependencies. Perhaps, it would be simple enough to write a selftest
harness that provides a basic interface for displaying test results,
messages, and warning/errors. This harness would ensure all the
logging was done in a TAP compliant manner. Food for thought :)

>
> thanks,
> -- Shuah
>
> --
> Shuah Khan
> Sr. Linux Kernel Developer
> Open Source Innovation Group
> Samsung Research America (Silicon Valley)
> shuahkh@osg.samsung.com | (970) 217-8978

Cheers,

Tyler

[0] http://www.eyrie.org/~eagle/software/c-tap-harness/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
John Stultz April 2, 2015, 6:02 p.m. UTC | #5
On Thu, Apr 2, 2015 at 3:18 AM, Prarit Bhargava <prarit@redhat.com> wrote:
> On 03/26/2015 01:33 PM, Tyler Baker wrote:
>> I realize this may be a good amount of work, so I'd like to help out.
>> Perhaps working John to convert his timer tests to use TAP output
>> would be a good starting point?
>
> John, I could probably do that for you.  I'm always willing to give it a shot.

I took a quick look into it, since I'm definitely interested in
improving output formatting, but man, TAP is a fairly ugly output
format if you ask me.

It only has binary "ok" or "not ok" (why not "fail", or something else
that's exclusively grep-able, I don't know). So I'm not sure if cases
where functionality is unsupported should be a pass or fail.

Most problematically: It seems to want enumeration in the test output
(so test 2 needs to print: "ok 2 Test complete") which means either
there needs to be a wrapper that does the TAP output knowing which
test of N its currently running, or the test number needs to be
submitted as an runtime argument to the test, and the test then has to
add it to its output line.

Anyway, if we do want to go with that format,  I suspect it should be
something we add to the kselftest pass/fail hooks, rather then to the
individual tests. Then its just a matter of prefixing normal test
output with #'s so they can be ignored by the parser.

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Tyler Baker April 2, 2015, 6:58 p.m. UTC | #6
On 2 April 2015 at 10:48, Shuah Khan <shuahkh@osg.samsung.com> wrote:
> On 04/02/2015 11:17 AM, Tyler Baker wrote:
>> On 2 April 2015 at 06:43, Shuah Khan <shuahkh@osg.samsung.com> wrote:
>>> On 04/02/2015 04:18 AM, Prarit Bhargava wrote:
>>>>
>>>>
>>>> On 03/26/2015 01:33 PM, Tyler Baker wrote:
>>>>> On 26 March 2015 at 09:29, John Stultz <john.stultz@linaro.org> wrote:
>>>>>> On Thu, Mar 26, 2015 at 4:31 AM, Prarit Bhargava <prarit@redhat.com> wrote:
>>>>>>> On 03/25/2015 07:44 PM, John Stultz wrote:
>>>>>>>> +                     printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
>>>>>>>> +                                     clockstring(clock_id),
>>>>>>>> +                                     flags ? "ABSTIME":"RELTIME");
>>>>>>>
>>>>>>> Something to think about:  Do you want to write these tests to be more human
>>>>>>> readable or machine readable?  In theory with awk I guess it doesn't matter too
>>>>>>> much, however, it is something that we should think about moving forward.
>>>>>>
>>>>>> So this came up at ELC in a few discussions. Right now there isn't any
>>>>>> established output format, but there's some nice and simple
>>>>>> infrastructure for counting pass/fails.
>>>>>>
>>>>>> However, in talking to Tyler, I know he has started looking at how to
>>>>>> integrate the selftests into our automated infrastructure and was
>>>>>> interested in how we improve the output parsing for reports. So there
>>>>>> is interest in improving this, and I'm open to whatever changes might
>>>>>> be needed (adding extra arguments to the test to put them into "easy
>>>>>> parse" mode or whatever).
>>>>>
>>>>> Thanks for looping me in John. My interest in kselftest stems from my
>>>>> involvement with kernelci.org, a communityservice focused on upstream
>>>>> kernel validation across multiple architectures. In it's current form,
>>>>> it is merely build and boot testing boards. However, we are at a point
>>>>> where we'd like to start running some tests. The automation framework
>>>>> (LAVA) used to execute these tests essentially uses a regular
>>>>> expression to parse the test's standard output. This is advantageous
>>>>> as a test can be written in any language, as long as it produces sane
>>>>> uniform output.
>>>>>
>>>>> Ideally, we would like to perform the kernel builds as we do today
>>>>> along with building all the kseltests present in the tree, and
>>>>> inserting them into a 'testing' ramdisk for deployment. Once we
>>>>> successfully boot the platform, we execute all the kselftests, parse
>>>>> standard out, and report the results. The benefit from this
>>>>> implementation is that a developer writing a test does have to do
>>>>> anything 'special' to get his/her test to run once it has been applied
>>>>> to a upstream tree. I'll explain below some concerns I have about
>>>>> accomplishing this.
>>>>>
>>>>> Currently, we have had to write wrappers[1][2] for some kselftests to
>>>>> be able parse the output. If we can choose/agree on a standard output
>>>>> format all of this complexity goes away, and then we can dynamically
>>>>> run kselftests. Integration of new tests will not be needed, as they
>>>>> all produce output in standard way. I've taken a look at the wiki page
>>>>> for standardizing output[3] and TAP looks like the good format IMO.
>>>>>
>>>>> Also, for arch != x86 there are some barriers to overcome to get all
>>>>> the kselftests cross compiling, which would be nice to have as well.
>>>>>
>>>>> I realize this may be a good amount of work, so I'd like to help out.
>>>>> Perhaps working John to convert his timer tests to use TAP output
>>>>> would be a good starting point?
>>>>
>>>> John, I could probably do that for you.  I'm always willing to give it a shot.
>>>>
>>>
>>> Improving reporting and output is a good idea, as long as the
>>> reporting framework doesn't add external dependencies and makes
>>> it difficult to build and run tests from the kernel git tree
>>> environment. Being able to run tests on a development system
>>> is the primary objective for these tests.
>>>
>>> As long as the TAP doesn't require additional libraries and
>>> tools to be installed on the development systems, I will be
>>> happy with the improvements to reporting and output.
>>
>> This is a very valid concern IMO. There is a C library for TAP
>> providers[0] but I agree we want to avoid external libraries as
>> dependencies. Perhaps, it would be simple enough to write a selftest
>> harness that provides a basic interface for displaying test results,
>> messages, and warning/errors. This harness would ensure all the
>> logging was done in a TAP compliant manner. Food for thought :)
>>
>
> The harness has to cover tests in written in C as well as shell
> scripts. I added a simple framework in kselftest.h as a step
> towards harness. However, it needs more work. I would welcome
> any patches that would provide a harness that meets the needs
> of external selftest use-cases such as yours.

Ok, I'll have a closer look at kselftest.h.

>
> Is writing a simple TAP compliant harness something you can take
> on?? Looking for volunteers :)

I'll volunteer to pick up these work items :) I should be able to
start on this work at some point next week.

John brought up some good points about the TAP format, and I'm
personally not yet convinced it is the best format. That being said,
I'll work to keep the changes to the harness generic so that we can
easily switch test output formats if we decide there is something
better than TAP in the future.

>
> thanks,
> -- Shuah
>
> --
> Shuah Khan
> Sr. Linux Kernel Developer
> Open Source Innovation Group
> Samsung Research America (Silicon Valley)
> shuahkh@osg.samsung.com | (970) 217-8978

Thanks,

Tyler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index 3ea2eff..dbc9537c 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -139,6 +139,13 @@  int do_timer(int clock_id, int flags)
 
 	err = timer_create(clock_id, &se, &tm1);
 	if (err) {
+		if ((clock_id == CLOCK_REALTIME_ALARM)
+				|| (clock_id == CLOCK_BOOTTIME_ALARM)) {
+			printf("%-22s %s missing CAP_WAKE_ALARM?    : [UNSUPPORTED]\n",
+					clockstring(clock_id),
+					flags ? "ABSTIME":"RELTIME");
+			return 0;
+		}
 		printf("%s - timer_create() failed\n", clockstring(clock_id));
 		return -1;
 	}