* [PATCH v1 0/2] Fix kselftest_harness regression
@ 2017-06-11 12:32 Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 1/2] Revert "selftests: kselftest_harness: fix compile warnings" Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning Mickaël Salaün
0 siblings, 2 replies; 5+ messages in thread
From: Mickaël Salaün @ 2017-06-11 12:32 UTC (permalink / raw)
To: linux-kernel
Cc: Mickaël Salaün, Andy Lutomirski, Kees Cook, Shuah Khan,
Will Drewry, linux-kselftest, linux-next
In the linux-next tree, commit f3380b7b8a72 ("selftests: kselftest_harness: fix
compile warnings") changes the test behavior when a test goes wrong. Instead,
the error handler is called when a test succeed.
Mickaël Salaün (2):
Revert "selftests: kselftest_harness: fix compile warnings"
selftests: kselftest_harness: Fix compile warning
tools/testing/selftests/kselftest_harness.h | 3 +--
tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/2] Revert "selftests: kselftest_harness: fix compile warnings"
2017-06-11 12:32 [PATCH v1 0/2] Fix kselftest_harness regression Mickaël Salaün
@ 2017-06-11 12:32 ` Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning Mickaël Salaün
1 sibling, 0 replies; 5+ messages in thread
From: Mickaël Salaün @ 2017-06-11 12:32 UTC (permalink / raw)
To: linux-kernel
Cc: Mickaël Salaün, Andy Lutomirski, Kees Cook, Shuah Khan,
Will Drewry, linux-kselftest, linux-next, Shuah Khan
This reverts commit f3380b7b8a72f435daceb49f7f7513f3ea2ce5ea.
The OPTIONAL_HANDLER macro, called by all ASSERT_* and EXPECT_* macros,
must support an optional error handler. This is done with an optional
block after the "for" loop.
This enable to pass 52/52 seccomp-bpf tests instead of 42/52.
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Will Drewry <wad@chromium.org>
---
tools/testing/selftests/kselftest_harness.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 432245faeab3..c56f72e07cd7 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -555,8 +555,7 @@
* return while still providing an optional block to the API consumer.
*/
#define OPTIONAL_HANDLER(_assert) \
- for (; _metadata->trigger; _metadata->trigger = __bail(_assert)) \
- ;
+ for (; _metadata->trigger; _metadata->trigger = __bail(_assert))
#define __EXPECT(_expected, _seen, _t, _assert) do { \
/* Avoid multiple evaluation of the cases */ \
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning
2017-06-11 12:32 [PATCH v1 0/2] Fix kselftest_harness regression Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 1/2] Revert "selftests: kselftest_harness: fix compile warnings" Mickaël Salaün
@ 2017-06-11 12:32 ` Mickaël Salaün
2017-06-12 2:22 ` Kees Cook
1 sibling, 1 reply; 5+ messages in thread
From: Mickaël Salaün @ 2017-06-11 12:32 UTC (permalink / raw)
To: linux-kernel
Cc: Mickaël Salaün, Andy Lutomirski, Kees Cook, Shuah Khan,
Will Drewry, linux-kselftest, linux-next, Shuah Khan
Do not confuse the compiler with a semicolon preceding a block. Replace
the semicolon with an empty block to avoid a warning:
gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
In file included from seccomp_bpf.c:40:0:
seccomp_bpf.c: In function ‘change_syscall’:
../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
for (; _metadata->trigger; _metadata->trigger = __bail(_assert))
^
../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
} while (0); OPTIONAL_HANDLER(_assert)
^~~~~~~~~~~~~~~~
../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
__EXPECT(expected, seen, ==, 0)
^~~~~~~~
seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
EXPECT_EQ(0, ret);
^~~~~~~~~
seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
{
^
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Will Drewry <wad@chromium.org>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 7ba94efb24fd..18dad07ae16b 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1310,7 +1310,7 @@ void change_syscall(struct __test_metadata *_metadata,
iov.iov_len = sizeof(regs);
ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
#endif
- EXPECT_EQ(0, ret);
+ EXPECT_EQ(0, ret) {}
#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
defined(__s390__) || defined(__hppa__)
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning
2017-06-11 12:32 ` [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning Mickaël Salaün
@ 2017-06-12 2:22 ` Kees Cook
2017-06-12 20:31 ` Shuah Khan
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2017-06-12 2:22 UTC (permalink / raw)
To: Mickaël Salaün
Cc: LKML, Andy Lutomirski, Shuah Khan, Will Drewry, linux-kselftest,
Linux-Next, Shuah Khan
On Sun, Jun 11, 2017 at 5:32 AM, Mickaël Salaün <mic@digikod.net> wrote:
> Do not confuse the compiler with a semicolon preceding a block. Replace
> the semicolon with an empty block to avoid a warning:
>
> gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
> In file included from seccomp_bpf.c:40:0:
> seccomp_bpf.c: In function ‘change_syscall’:
> ../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
> for (; _metadata->trigger; _metadata->trigger = __bail(_assert))
> ^
> ../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
> } while (0); OPTIONAL_HANDLER(_assert)
> ^~~~~~~~~~~~~~~~
> ../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
> __EXPECT(expected, seen, ==, 0)
> ^~~~~~~~
> seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
> EXPECT_EQ(0, ret);
> ^~~~~~~~~
> seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
> {
> ^
>
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Shuah Khan <shuahkh@osg.samsung.com>
> Cc: Will Drewry <wad@chromium.org>
Eek, thanks for catching that. :)
Acked-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 7ba94efb24fd..18dad07ae16b 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -1310,7 +1310,7 @@ void change_syscall(struct __test_metadata *_metadata,
> iov.iov_len = sizeof(regs);
> ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
> #endif
> - EXPECT_EQ(0, ret);
> + EXPECT_EQ(0, ret) {}
>
> #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
> defined(__s390__) || defined(__hppa__)
> --
> 2.11.0
>
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning
2017-06-12 2:22 ` Kees Cook
@ 2017-06-12 20:31 ` Shuah Khan
0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2017-06-12 20:31 UTC (permalink / raw)
To: Kees Cook, Mickaël Salaün
Cc: LKML, Andy Lutomirski, Will Drewry, linux-kselftest, Linux-Next,
Shuah Khan, Shuah Khan
On 06/11/2017 08:22 PM, Kees Cook wrote:
> On Sun, Jun 11, 2017 at 5:32 AM, Mickaël Salaün <mic@digikod.net> wrote:
>> Do not confuse the compiler with a semicolon preceding a block. Replace
>> the semicolon with an empty block to avoid a warning:
>>
>> gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
>> In file included from seccomp_bpf.c:40:0:
>> seccomp_bpf.c: In function ‘change_syscall’:
>> ../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
>> for (; _metadata->trigger; _metadata->trigger = __bail(_assert))
>> ^
>> ../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
>> } while (0); OPTIONAL_HANDLER(_assert)
>> ^~~~~~~~~~~~~~~~
>> ../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
>> __EXPECT(expected, seen, ==, 0)
>> ^~~~~~~~
>> seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
>> EXPECT_EQ(0, ret);
>> ^~~~~~~~~
>> seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
>> {
>> ^
>>
>> Signed-off-by: Mickaël Salaün <mic@digikod.net>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Shuah Khan <shuahkh@osg.samsung.com>
>> Cc: Will Drewry <wad@chromium.org>
>
> Eek, thanks for catching that. :)
>
> Acked-by: Kees Cook <keescook@chromium.org>
>
> -Kees
Thanks. Ths fix is now in linux-kselftest next.
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-06-12 20:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-11 12:32 [PATCH v1 0/2] Fix kselftest_harness regression Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 1/2] Revert "selftests: kselftest_harness: fix compile warnings" Mickaël Salaün
2017-06-11 12:32 ` [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning Mickaël Salaün
2017-06-12 2:22 ` Kees Cook
2017-06-12 20:31 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).