diff mbox series

[v2,2/4] bpf: Print full verification log

Message ID 20210831091005.25361-2-rpalethorpe@suse.com
State Accepted
Headers show
Series [v2,1/4] API: Add tst_printf to avoid specifying the output FD in tests | expand

Commit Message

Richard Palethorpe Aug. 31, 2021, 9:10 a.m. UTC
The log never falls within the 1024 byte limit imposed by format
string buffer. So print it separately with dprintf.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 testcases/kernel/syscalls/bpf/bpf_common.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis Aug. 31, 2021, 9:51 a.m. UTC | #1
Hi!
> diff --git a/testcases/kernel/syscalls/bpf/bpf_common.c b/testcases/kernel/syscalls/bpf/bpf_common.c
> index ba0829a75..aac235cac 100644
> --- a/testcases/kernel/syscalls/bpf/bpf_common.c
> +++ b/testcases/kernel/syscalls/bpf/bpf_common.c
> @@ -3,6 +3,8 @@
>   * Copyright (c) 2019-2020 Linux Test Project
>   */
>  
> +#include <stdio.h>

I've removed this now unused include.

>  #define TST_NO_DEFAULT_MAIN
>  #include "tst_test.h"
>  #include "bpf_common.h"
> @@ -118,8 +120,10 @@ int bpf_load_prog(union bpf_attr *const attr, const char *const log)
>  	if (ret != -1)
>  		tst_brk(TBROK, "Invalid bpf() return value: %d", ret);
>  
> -	if (log[0] != 0)
> -		tst_brk(TBROK | TERRNO, "Failed verification: %s", log);
> +	if (log[0] != 0) {
> +		tst_printf("%s\n", log);
> +		tst_brk(TBROK | TERRNO, "Failed verification");
> +	}
>  
>  	tst_brk(TBROK | TERRNO, "Failed to load program");
>  	return ret;

And pushed the whole patchset, thanks.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/bpf/bpf_common.c b/testcases/kernel/syscalls/bpf/bpf_common.c
index ba0829a75..aac235cac 100644
--- a/testcases/kernel/syscalls/bpf/bpf_common.c
+++ b/testcases/kernel/syscalls/bpf/bpf_common.c
@@ -3,6 +3,8 @@ 
  * Copyright (c) 2019-2020 Linux Test Project
  */
 
+#include <stdio.h>
+
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "bpf_common.h"
@@ -118,8 +120,10 @@  int bpf_load_prog(union bpf_attr *const attr, const char *const log)
 	if (ret != -1)
 		tst_brk(TBROK, "Invalid bpf() return value: %d", ret);
 
-	if (log[0] != 0)
-		tst_brk(TBROK | TERRNO, "Failed verification: %s", log);
+	if (log[0] != 0) {
+		tst_printf("%s\n", log);
+		tst_brk(TBROK | TERRNO, "Failed verification");
+	}
 
 	tst_brk(TBROK | TERRNO, "Failed to load program");
 	return ret;