2020-11-06 18:46:51

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] kunit: Support for Parameterized Testing

On Fri, 6 Nov 2020 at 19:28, Arpitha Raghunandan <[email protected]> wrote:
>
> Implementation of support for parameterized testing in KUnit.
> This approach requires the creation of a test case using the
> KUNIT_CASE_PARAM macro that accepts a generator function as input.
> This generator function should return the next parameter given the
> previous parameter in parameterized tests. It also provides
> a macro to generate common-case generators.
>
> Signed-off-by: Arpitha Raghunandan <[email protected]>
> Co-developed-by: Marco Elver <[email protected]>
> Signed-off-by: Marco Elver <[email protected]>
[...]
> - kunit_suite_for_each_test_case(suite, test_case)
> - kunit_run_case_catch_errors(suite, test_case);
> + kunit_suite_for_each_test_case(suite, test_case) {
> + struct kunit test = { .param_value = NULL, .param_index = 0 };
> + bool test_success = true;
> +
> + if (test_case->generate_params)
> + test.param_value = test_case->generate_params(NULL);
> +
> + do {
> + kunit_run_case_catch_errors(suite, test_case, &test);
> + test_success &= test_case->success;
> +
> + if (test_case->generate_params) {
> + kunit_log(KERN_INFO, &test,
> + KUNIT_SUBTEST_INDENT
> + "# %s: param-%d %s",
> + test_case->name, test.param_index,
> + kunit_status_to_string(test.success));

Sorry, I still found something. The patch I sent had this aligned with
the '(', whereas when I apply this patch it no longer is aligned. Why?

I see the rest of the file also aligns arguments with opening '(', so
I think your change is inconsistent.

Thanks,
-- Marco


2020-11-06 19:01:22

by Arpitha Raghunandan

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] kunit: Support for Parameterized Testing

On 07/11/20 12:15 am, Marco Elver wrote:
> On Fri, 6 Nov 2020 at 19:28, Arpitha Raghunandan <[email protected]> wrote:
>>
>> Implementation of support for parameterized testing in KUnit.
>> This approach requires the creation of a test case using the
>> KUNIT_CASE_PARAM macro that accepts a generator function as input.
>> This generator function should return the next parameter given the
>> previous parameter in parameterized tests. It also provides
>> a macro to generate common-case generators.
>>
>> Signed-off-by: Arpitha Raghunandan <[email protected]>
>> Co-developed-by: Marco Elver <[email protected]>
>> Signed-off-by: Marco Elver <[email protected]>
> [...]
>> - kunit_suite_for_each_test_case(suite, test_case)
>> - kunit_run_case_catch_errors(suite, test_case);
>> + kunit_suite_for_each_test_case(suite, test_case) {
>> + struct kunit test = { .param_value = NULL, .param_index = 0 };
>> + bool test_success = true;
>> +
>> + if (test_case->generate_params)
>> + test.param_value = test_case->generate_params(NULL);
>> +
>> + do {
>> + kunit_run_case_catch_errors(suite, test_case, &test);
>> + test_success &= test_case->success;
>> +
>> + if (test_case->generate_params) {
>> + kunit_log(KERN_INFO, &test,
>> + KUNIT_SUBTEST_INDENT
>> + "# %s: param-%d %s",
>> + test_case->name, test.param_index,
>> + kunit_status_to_string(test.success));
>
> Sorry, I still found something. The patch I sent had this aligned with
> the '(', whereas when I apply this patch it no longer is aligned. Why?
>
> I see the rest of the file also aligns arguments with opening '(', so
> I think your change is inconsistent.
>

Ah those lines had spaces instead of tab and I think I messed up the alignment
fixing that. I will send another version fixing this.
Thanks!

> Thanks,
> -- Marco
>

2020-11-06 19:06:56

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] kunit: Support for Parameterized Testing

On Fri, 6 Nov 2020 at 20:00, Arpitha Raghunandan <[email protected]> wrote:
>
> On 07/11/20 12:15 am, Marco Elver wrote:
> > On Fri, 6 Nov 2020 at 19:28, Arpitha Raghunandan <[email protected]> wrote:
> >>
> >> Implementation of support for parameterized testing in KUnit.
> >> This approach requires the creation of a test case using the
> >> KUNIT_CASE_PARAM macro that accepts a generator function as input.
> >> This generator function should return the next parameter given the
> >> previous parameter in parameterized tests. It also provides
> >> a macro to generate common-case generators.
> >>
> >> Signed-off-by: Arpitha Raghunandan <[email protected]>
> >> Co-developed-by: Marco Elver <[email protected]>
> >> Signed-off-by: Marco Elver <[email protected]>
> > [...]
> >> - kunit_suite_for_each_test_case(suite, test_case)
> >> - kunit_run_case_catch_errors(suite, test_case);
> >> + kunit_suite_for_each_test_case(suite, test_case) {
> >> + struct kunit test = { .param_value = NULL, .param_index = 0 };
> >> + bool test_success = true;
> >> +
> >> + if (test_case->generate_params)
> >> + test.param_value = test_case->generate_params(NULL);
> >> +
> >> + do {
> >> + kunit_run_case_catch_errors(suite, test_case, &test);
> >> + test_success &= test_case->success;
> >> +
> >> + if (test_case->generate_params) {
> >> + kunit_log(KERN_INFO, &test,
> >> + KUNIT_SUBTEST_INDENT
> >> + "# %s: param-%d %s",
> >> + test_case->name, test.param_index,
> >> + kunit_status_to_string(test.success));
> >
> > Sorry, I still found something. The patch I sent had this aligned with
> > the '(', whereas when I apply this patch it no longer is aligned. Why?
> >
> > I see the rest of the file also aligns arguments with opening '(', so
> > I think your change is inconsistent.
> >
>
> Ah those lines had spaces instead of tab and I think I messed up the alignment
> fixing that. I will send another version fixing this.
> Thanks!

It was tabs then <8 spaces to align. checkpatch.pl certainly is happy with that.

> > Thanks,
> > -- Marco
> >
>