On Wed, Nov 09, 2022 at 05:43:34AM IST, Andrii Nakryiko wrote: > On Mon, Nov 7, 2022 at 3:11 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > > > Make updates in preparation for adding more test cases to this selftest: > > - Convert from CHECK_ to ASSERT macros. > > - Use BPF skeleton > > - Fix typo sping -> spin > > - Rename spinlock.c -> spin_lock.c > > > > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> > > --- > > .../selftests/bpf/prog_tests/spin_lock.c | 46 +++++++++++++++++++ > > .../selftests/bpf/prog_tests/spinlock.c | 45 ------------------ > > .../selftests/bpf/progs/test_spin_lock.c | 4 +- > > 3 files changed, 48 insertions(+), 47 deletions(-) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/spin_lock.c > > delete mode 100644 tools/testing/selftests/bpf/prog_tests/spinlock.c > > > > [...] > > > +void test_spinlock(void) > > +{ > > + struct test_spin_lock *skel; > > + pthread_t thread_id[4]; > > + int prog_fd, i; > > + void *ret; > > + > > + skel = test_spin_lock__open_and_load(); > > + if (!ASSERT_OK_PTR(skel, "test_spin_lock__open_and_load")) > > + return; > > + prog_fd = bpf_program__fd(skel->progs.bpf_spin_lock_test); > > + for (i = 0; i < 4; i++) > > + if (!ASSERT_OK(pthread_create(&thread_id[i], NULL, > > + &spin_lock_thread, &prog_fd), "pthread_create")) > > I mean... does that pthread_create() call have to happen inside ASSERT_OK? > > err = pthread_create(...) > if (!ASSERT_OK(err, "pthread_create")) > goto end; > Ack, I'll rewrite it like this.