All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: "sunyucong@gmail.com" <sunyucong@gmail.com>
Cc: Yucong Sun <fallentree@fb.com>, bpf <bpf@vger.kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH bpf-next v6 02/14] selftests/bpf: Allow some tests to be executed in sequence
Date: Fri, 8 Oct 2021 20:17:08 -0700	[thread overview]
Message-ID: <CAEf4Bzb8ukSDJk0sZokCVwh-7qNGKMD=PCh-aXVLQHPbgAYADA@mail.gmail.com> (raw)
In-Reply-To: <CAJygYd34kafprTobpd7gT9shdpPZF=aAcYF-YY0Vs+8Hh16bAg@mail.gmail.com>

On Fri, Oct 8, 2021 at 4:06 PM sunyucong@gmail.com <sunyucong@gmail.com> wrote:
>
> On Fri, Oct 8, 2021 at 3:26 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Wed, Oct 6, 2021 at 11:56 AM Yucong Sun <fallentree@fb.com> wrote:
> > >
> > > From: Yucong Sun <sunyucong@gmail.com>
> > >
> > > This patch allows tests to define serial_test_name() instead of
> > > test_name(), and this will make test_progs execute those in sequence
> > > after all other tests finished executing concurrently.
> > >
> > > Signed-off-by: Yucong Sun <sunyucong@gmail.com>
> > > ---
> > >  tools/testing/selftests/bpf/test_progs.c | 60 +++++++++++++++++++++---
> > >  1 file changed, 54 insertions(+), 6 deletions(-)
> > >
> >
> > [...]
> >
> > > @@ -1129,6 +1136,40 @@ static int server_main(void)
> > >         free(env.worker_current_test);
> > >         free(data);
> > >
> > > +       /* run serial tests */
> > > +       save_netns();
> > > +
> > > +       for (int i = 0; i < prog_test_cnt; i++) {
> > > +               struct prog_test_def *test = &prog_test_defs[i];
> > > +               struct test_result *result = &test_results[i];
> > > +
> > > +               if (!test->should_run || !test->run_serial_test)
> > > +                       continue;
> > > +
> > > +               stdio_hijack();
> > > +
> > > +               run_one_test(i);
> > > +
> > > +               stdio_restore();
> > > +               if (env.log_buf) {
> > > +                       result->log_cnt = env.log_cnt;
> > > +                       result->log_buf = strdup(env.log_buf);
> > > +
> > > +                       free(env.log_buf);
> > > +                       env.log_buf = NULL;
> > > +                       env.log_cnt = 0;
> > > +               }
> > > +               restore_netns();
> > > +
> > > +               fprintf(stdout, "#%d %s:%s\n",
> > > +                       test->test_num, test->test_name,
> > > +                       test->error_cnt ? "FAIL" : (test->skip_cnt ? "SKIP" : "OK"));
> > > +
> > > +               result->error_cnt = test->error_cnt;
> > > +               result->skip_cnt = test->skip_cnt;
> > > +               result->sub_succ_cnt = test->sub_succ_cnt;
> > > +       }
> > > +
> >
> > Did you try to just reuse sequential running loop logic in main() for
> > this? I'd like to avoid the third test running loop copy, if possible.
> > What were the problems of reusing the sequential logic from main(),
> > they do the same work, no?
>
> Well, yes and no
>
> The loop itself is small/simple enough, I'm not sure there is a value
> to extract them to a common function with multiple arguments.

The loop has netns save/restore, stdio hijacking, output formatting,
we might add some more logic later. I'm mainly asking because there is
already a sequential loop in the main, and I was wondering if we can
reuse that (as in, let it run regardless of -j option, just run only
serial tests if -j is specified).


> I think the main issue that needs to be refactored is that log
> printing still works differently in serial mode or parallel mode,  it
> works now, but I would like to get rid of the old dump_test_log()
> function.
>
> >
> >
> > >         /* generate summary */
> > >         fflush(stderr);
> > >         fflush(stdout);
> > > @@ -1326,6 +1367,13 @@ int main(int argc, char **argv)
> > >                         test->should_run = true;
> > >                 else
> > >                         test->should_run = false;
> > > +
> > > +               if ((test->run_test == NULL && test->run_serial_test == NULL) ||
> > > +                   (test->run_test != NULL && test->run_serial_test != NULL)) {
> > > +                       fprintf(stderr, "Test %d:%s must have either test_%s() or serial_test_%sl() defined.\n",
> > > +                               test->test_num, test->test_name, test->test_name, test->test_name);
> > > +                       exit(EXIT_ERR_SETUP_INFRA);
> > > +               }
> > >         }
> > >
> > >         /* ignore workers if we are just listing */
> > > --
> > > 2.30.2
> > >

  reply	other threads:[~2021-10-09  3:17 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 18:56 [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 01/14] " Yucong Sun
2021-10-08 22:26   ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 02/14] selftests/bpf: Allow some tests to be executed in sequence Yucong Sun
2021-10-08 22:26   ` Andrii Nakryiko
2021-10-08 23:06     ` sunyucong
2021-10-09  3:17       ` Andrii Nakryiko [this message]
2021-10-06 18:56 ` [PATCH bpf-next v6 03/14] selftests/bpf: disable perf rate limiting when running tests Yucong Sun
2021-10-08 22:26   ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 04/14] selftests/bpf: add per worker cgroup suffix Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 05/14] selftests/bpf: adding read_perf_max_sample_freq() helper Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-08 22:49     ` sunyucong
2022-03-08 20:22       ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 06/14] selftests/bpf: fix race condition in enable_stats Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 07/14] selftests/bpf: make cgroup_v1v2 use its own port Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 08/14] selftests/bpf: adding a namespace reset for tc_redirect Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-08 23:07     ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 09/14] selftests/bpf: Make uprobe tests use different attach functions Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-08 22:46     ` sunyucong
2021-10-09  3:13       ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 10/14] selftests/bpf: adding pid filtering for atomics test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 11/14] selftests/bpf: adding random delay for send_signal test Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 12/14] selftests/bpf: Fix pid check in fexit_sleep test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 13/14] selftests/bpf: increase loop count for perf_branches Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-08 22:57     ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 14/14] selfetest/bpf: make some tests serial Yucong Sun
2021-10-08 22:27   ` Andrii Nakryiko
2021-10-08 22:55     ` sunyucong
2021-10-09  3:14       ` Andrii Nakryiko
2021-10-08 22:26 ` [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Andrii Nakryiko
2021-10-08 22:42   ` Andrii Nakryiko
2021-10-08 23:37     ` Steven Rostedt
2021-10-09  3:20       ` Andrii Nakryiko
2021-10-09  3:28         ` Steven Rostedt

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='CAEf4Bzb8ukSDJk0sZokCVwh-7qNGKMD=PCh-aXVLQHPbgAYADA@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=fallentree@fb.com \
    --cc=sunyucong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.