diff mbox series

[bpf-next] selftests/bpf: fix subtest number formatting in test_progs

Message ID 20220520070144.10312-1-mykolal@fb.com (mailing list archive)
State Accepted
Commit fa376860658252a4559026496528c5d3a36b52e3
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: fix subtest number formatting in test_progs | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 8 maintainers not CCed: kpsingh@kernel.org kafai@fb.com john.fastabend@gmail.com yhs@fb.com songliubraving@fb.com netdev@vger.kernel.org linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 fail Logs for Kernel LATEST on ubuntu-latest with gcc
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for Kernel LATEST on z15 with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-2 fail Logs for Kernel LATEST on ubuntu-latest with llvm-15

Commit Message

Mykola Lysenko May 20, 2022, 7:01 a.m. UTC
Remove weird spaces around / while preserving proper
indentation

Signed-off-by: Mykola Lysenko <mykolal@fb.com>
---
 tools/testing/selftests/bpf/test_progs.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Daniel Müller May 20, 2022, 4:22 p.m. UTC | #1
On Fri, May 20, 2022 at 12:01:44AM -0700, Mykola Lysenko wrote:
> Remove weird spaces around / while preserving proper
> indentation
> 
> Signed-off-by: Mykola Lysenko <mykolal@fb.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index ecf69fce036e..262b7577b0ef 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -230,9 +230,14 @@ static void print_test_log(char *log_buf, size_t log_cnt)
>  		fprintf(env.stdout, "\n");
>  }
>  
> +#define TEST_NUM_WIDTH 7
> +#define STRINGIFY(value) #value
> +#define QUOTE(macro) STRINGIFY(macro)
> +#define TEST_NUM_WIDTH_STR QUOTE(TEST_NUM_WIDTH)
> +
>  static void print_test_name(int test_num, const char *test_name, char *result)
>  {
> -	fprintf(env.stdout, "#%-9d %s", test_num, test_name);
> +	fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "d %s", test_num, test_name);
>  
>  	if (result)
>  		fprintf(env.stdout, ":%s", result);
> @@ -244,8 +249,12 @@ static void print_subtest_name(int test_num, int subtest_num,
>  			       const char *test_name, char *subtest_name,
>  			       char *result)
>  {
> -	fprintf(env.stdout, "#%-3d/%-5d %s/%s",
> -		test_num, subtest_num,
> +	char test_num_str[TEST_NUM_WIDTH + 1];
> +
> +	snprintf(test_num_str, sizeof(test_num_str), "%d/%d", test_num, subtest_num);
> +
> +	fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "s %s/%s",
> +		test_num_str,
>  		test_name, subtest_name);
>  
>  	if (result)
> -- 
> 2.30.2
> 

Looks good to me, thanks.

Acked-by: Daniel Müller <deso@posteo.net>
Andrii Nakryiko May 20, 2022, 11:23 p.m. UTC | #2
On Fri, May 20, 2022 at 12:02 AM Mykola Lysenko <mykolal@fb.com> wrote:
>
> Remove weird spaces around / while preserving proper
> indentation
>
> Signed-off-by: Mykola Lysenko <mykolal@fb.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index ecf69fce036e..262b7577b0ef 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -230,9 +230,14 @@ static void print_test_log(char *log_buf, size_t log_cnt)
>                 fprintf(env.stdout, "\n");
>  }
>
> +#define TEST_NUM_WIDTH 7
> +#define STRINGIFY(value) #value
> +#define QUOTE(macro) STRINGIFY(macro)
> +#define TEST_NUM_WIDTH_STR QUOTE(TEST_NUM_WIDTH)
> +
>  static void print_test_name(int test_num, const char *test_name, char *result)
>  {
> -       fprintf(env.stdout, "#%-9d %s", test_num, test_name);
> +       fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "d %s", test_num, test_name);

this is equivalent to

fprintf(env.stdout, "#%-*d %s", TEST_NUM_WIDTH, test_num, test_name);

but doesn't require macro stringify sequence, so I dropped STRINGIFY,
QUOTE and TEST_NU_WIDTH_STR and replaced it with * argument here and
below

>
>         if (result)
>                 fprintf(env.stdout, ":%s", result);
> @@ -244,8 +249,12 @@ static void print_subtest_name(int test_num, int subtest_num,
>                                const char *test_name, char *subtest_name,
>                                char *result)
>  {
> -       fprintf(env.stdout, "#%-3d/%-5d %s/%s",
> -               test_num, subtest_num,
> +       char test_num_str[TEST_NUM_WIDTH + 1];
> +
> +       snprintf(test_num_str, sizeof(test_num_str), "%d/%d", test_num, subtest_num);
> +
> +       fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "s %s/%s",
> +               test_num_str,
>                 test_name, subtest_name);
>
>         if (result)
> --
> 2.30.2
>
patchwork-bot+netdevbpf@kernel.org May 20, 2022, 11:30 p.m. UTC | #3
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Fri, 20 May 2022 00:01:44 -0700 you wrote:
> Remove weird spaces around / while preserving proper
> indentation
> 
> Signed-off-by: Mykola Lysenko <mykolal@fb.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

Here is the summary with links:
  - [bpf-next] selftests/bpf: fix subtest number formatting in test_progs
    https://git.kernel.org/bpf/bpf-next/c/fa3768606582

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index ecf69fce036e..262b7577b0ef 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -230,9 +230,14 @@  static void print_test_log(char *log_buf, size_t log_cnt)
 		fprintf(env.stdout, "\n");
 }
 
+#define TEST_NUM_WIDTH 7
+#define STRINGIFY(value) #value
+#define QUOTE(macro) STRINGIFY(macro)
+#define TEST_NUM_WIDTH_STR QUOTE(TEST_NUM_WIDTH)
+
 static void print_test_name(int test_num, const char *test_name, char *result)
 {
-	fprintf(env.stdout, "#%-9d %s", test_num, test_name);
+	fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "d %s", test_num, test_name);
 
 	if (result)
 		fprintf(env.stdout, ":%s", result);
@@ -244,8 +249,12 @@  static void print_subtest_name(int test_num, int subtest_num,
 			       const char *test_name, char *subtest_name,
 			       char *result)
 {
-	fprintf(env.stdout, "#%-3d/%-5d %s/%s",
-		test_num, subtest_num,
+	char test_num_str[TEST_NUM_WIDTH + 1];
+
+	snprintf(test_num_str, sizeof(test_num_str), "%d/%d", test_num, subtest_num);
+
+	fprintf(env.stdout, "#%-" TEST_NUM_WIDTH_STR "s %s/%s",
+		test_num_str,
 		test_name, subtest_name);
 
 	if (result)