Re: [PATCH v3 2/4] memblock tests: add verbose output to memblock tests
From: Rebecca Mckeever
Date: Thu Jun 23 2022 - 03:57:39 EST
On Thu, Jun 23, 2022 at 12:04:33AM -0500, Mike Rapoport wrote:
> On Wed, Jun 22, 2022 at 11:56:30PM -0500, Rebecca Mckeever wrote:
> > On Wed, Jun 22, 2022 at 11:05:27PM -0500, Mike Rapoport wrote:
> > > On Thu, Jun 23, 2022 at 09:29:05AM +0800, Huang, Shaoqin wrote:
> > > >
> > > >
> > > > On 6/23/2022 8:45 AM, Rebecca Mckeever wrote:
> > > > > On Wed, Jun 22, 2022 at 06:32:04PM +0800, Huang, Shaoqin wrote:
> > > > > > Just test it and everything works fine. And I think there are some thing can
> > > > > > improve:
> > > > > >
> > > > > > The prefix_push() and prefix_pop() are used in so many functions and
> > > > > > almost of them just put the prefix_push(__func__) begin in the head and the
> > > > > > prefix_pop() in the end.
> > > > > > May be you can define some macro that when you output something and
> > > > > > automatically push the __func__ as prefix. And when leave the function,
> > > > > > automatically pop it. And only in some special place, you call it manually.
> > > > > >
> > > > > Thank you for your review. I'm not sure how you would automatically push
> > > > > __func__ since you have to be inside the function to access that
> > > > > variable. Let me know if you have any suggestions. I am thinking about
> > > > > adding another function in common.c that just calls test_pass() followed
> > > > > by prefix_pop() since those are called together so often.
> > > >
> > > > Just like:
> > > > #define test_pass_macro() \
> > > > do { \
> > > > prefix_push(__func__); \
> > > > test_pass(); \
> > > > prefix_pop(); \
> > > > } while (0)
> > >
> > > This will not print the name of the failing test, e.g. instead of
> > >
> > > not ok 28 : memblock_alloc: alloc_bottom_up_disjoint_check: failed
> > >
> > > with Rebecca's implementation it'll print
> > >
> > > not ok 28 : memblock_alloc: failed
> > >
> > Oh yeah, prefix_push() needs to be called before the asserts.
> >
> > > How about
> > >
> > > #define PREFIX_PUSH() prefix_push(__func__)?
> > >
> > Good idea. What about
> >
> > #define TEST_PASS() do { \
> > test_pass(); \
> > prefix_pop(); \
> > } while (0)
> >
> > ? Or would it be better to make a function?
>
> static inline function would be better.
>
Would there be any advantage to defining a different version for each
side of #ifdef VERBOSE?
> > Thanks,
> > Rebecca
>
> --
> Sincerely yours,
> Mike.
Thanks,
Rebecca