public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf@google•com>
To: netdev@vger•kernel.org, bpf@vger•kernel.org
Cc: davem@davemloft•net, ast@kernel•org, daniel@iogearbox•net,
	Stanislav Fomichev <sdf@google•com>,
	John Fastabend <john.fastabend@gmail•com>
Subject: [PATCH bpf-next 2/2] selftests/bpf: move test_align under test_progs
Date: Fri, 15 May 2020 12:49:04 -0700	[thread overview]
Message-ID: <20200515194904.229296-2-sdf@google.com> (raw)
In-Reply-To: <20200515194904.229296-1-sdf@google.com>

There is a much higher chance we can see the regressions if the
test is part of test_progs.

Cc: John Fastabend <john.fastabend@gmail•com>
Signed-off-by: Stanislav Fomichev <sdf@google•com>
---
 .../bpf/{test_align.c => prog_tests/align.c}  | 68 ++-----------------
 1 file changed, 7 insertions(+), 61 deletions(-)
 rename tools/testing/selftests/bpf/{test_align.c => prog_tests/align.c} (94%)

diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/prog_tests/align.c
similarity index 94%
rename from tools/testing/selftests/bpf/test_align.c
rename to tools/testing/selftests/bpf/prog_tests/align.c
index c9c9bdce9d6d..c548aded6585 100644
--- a/tools/testing/selftests/bpf/test_align.c
+++ b/tools/testing/selftests/bpf/prog_tests/align.c
@@ -1,24 +1,5 @@
-#include <asm/types.h>
-#include <linux/types.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdbool.h>
-
-#include <linux/unistd.h>
-#include <linux/filter.h>
-#include <linux/bpf_perf_event.h>
-#include <linux/bpf.h>
-
-#include <bpf/bpf.h>
-
-#include "../../../include/linux/filter.h"
-#include "bpf_rlimit.h"
-#include "bpf_util.h"
+// SPDX-License-Identifier: GPL-2.0
+#include <test_progs.h>
 
 #define MAX_INSNS	512
 #define MAX_MATCHES	16
@@ -670,51 +651,16 @@ static int do_test_single(struct bpf_align_test *test)
 	return ret;
 }
 
-static int do_test(unsigned int from, unsigned int to)
+void test_align(void)
 {
-	int all_pass = 0;
-	int all_fail = 0;
 	unsigned int i;
 
-	for (i = from; i < to; i++) {
+	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		struct bpf_align_test *test = &tests[i];
-		int fail;
-
-		printf("Test %3d: %s ... ",
-		       i, test->descr);
-		fail = do_test_single(test);
-		if (fail) {
-			all_fail++;
-			printf("FAIL\n");
-		} else {
-			all_pass++;
-			printf("PASS\n");
-		}
-	}
-	printf("Results: %d pass %d fail\n",
-	       all_pass, all_fail);
-	return all_fail ? EXIT_FAILURE : EXIT_SUCCESS;
-}
-
-int main(int argc, char **argv)
-{
-	unsigned int from = 0, to = ARRAY_SIZE(tests);
 
-	if (argc == 3) {
-		unsigned int l = atoi(argv[argc - 2]);
-		unsigned int u = atoi(argv[argc - 1]);
+		if (!test__start_subtest(test->descr))
+			continue;
 
-		if (l < to && u < to) {
-			from = l;
-			to   = u + 1;
-		}
-	} else if (argc == 2) {
-		unsigned int t = atoi(argv[argc - 1]);
-
-		if (t < to) {
-			from = t;
-			to   = t + 1;
-		}
+		CHECK_FAIL(do_test_single(test));
 	}
-	return do_test(from, to);
 }
-- 
2.26.2.761.g0e0b3e54be-goog


  reply	other threads:[~2020-05-15 19:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 19:49 [PATCH bpf-next 1/2] selftests/bpf: fix test_align Stanislav Fomichev
2020-05-15 19:49 ` Stanislav Fomichev [this message]
2020-05-15 23:19 ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200515194904.229296-2-sdf@google.com \
    --to=sdf@google$(echo .)com \
    --cc=ast@kernel$(echo .)org \
    --cc=bpf@vger$(echo .)kernel.org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox