RE: [PATCH v3 5/5] kselftest: kcmp: Port kcmp test to TAP v13

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Alice Ferrazzi  on Thursday, June 15, 2017 8:38 AM
> 
> On Thu, Jun 15, 2017 at 8:30 AM, Bird, Timothy <Tim.Bird@xxxxxxxx
> <mailto:Tim.Bird@xxxxxxxx> > wrote:
> 
> 
> 	> -----Original Message-----
> 	> From: Alice Ferrazz on Thursday, June 15, 2017 7:33 AM
> 	>
> 	> Make the kcmp test output in the TAP13 format by using the
> 	> TAP13 output functions defined in kselftest.h
> 	>
> 	> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx
> <mailto:gregkh@xxxxxxxxxxxxxxxxxxx> >
> 	> Signed-off-by: Paul Elder <paul.elder@xxxxxxxx
> <mailto:paul.elder@xxxxxxxx> >
> 	> Signed-off-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx
> <mailto:alice.ferrazzi@xxxxxxxxx> >
> 	> ---
> 	> v3: Add kcmp test port to TAP13 - Alice
> 	>
> 	>  tools/testing/selftests/kcmp/kcmp_test.c | 33 ++++++++++++++--
> -----------
> 	> -----
> 	>  1 file changed, 14 insertions(+), 19 deletions(-)
> 	>
> 	> diff --git a/tools/testing/selftests/kcmp/kcmp_test.c
> 	> b/tools/testing/selftests/kcmp/kcmp_test.c
> 	> index a5a4da856d..b007e62e03 100644
> 	> --- a/tools/testing/selftests/kcmp/kcmp_test.c
> 	> +++ b/tools/testing/selftests/kcmp/kcmp_test.c
> 	> @@ -35,30 +35,28 @@ int main(int argc, char **argv)
> 	>       pid1 = getpid();
> 	>
> 	>       if (fd1 < 0) {
> 	> -             perror("Can't create file");
> 	> -             ksft_exit_fail();
> 	> +             ksft_exit_fail_msg("Can't create file");
> 	>       }
> 	>
> 	>       pid2 = fork();
> 	>       if (pid2 < 0) {
> 	> -             perror("fork failed");
> 	> -             ksft_exit_fail();
> 	> +             ksft_exit_fail_msg("fork failed");
> 	>       }
> 	>
> 	>       if (!pid2) {
> 	>               int pid2 = getpid();
> 	>               int ret;
> 	> +             char buf[512];
> 	>
> 	>               fd2 = open(kpath, O_RDWR, 0644);
> 	>               if (fd2 < 0) {
> 	> -                     perror("Can't open file");
> 	> -                     ksft_exit_fail();
> 	> +                     ksft_exit_fail_msg("Can't open file");
> 	>               }
> 	>
> 	>               /* An example of output and arguments */
> 	> -             printf("pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld "
> 	> +             snprintf(&buf[0], sizeof(buf) ,"pid1: %6d pid2: %6d FD: %2ld
> 	> FILES: %2ld VM: %2ld "
> 	>                      "FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld "
> 	> -                    "INV: %2ld\n",
> 	> +                    "INV: %2ld",
> 	>                      pid1, pid2,
> 	>                      sys_kcmp(pid1, pid2, KCMP_FILE,          fd1, fd2),
> 	>                      sys_kcmp(pid1, pid2, KCMP_FILES,         0, 0),
> 	> @@ -73,30 +71,27 @@ int main(int argc, char **argv)
> 	>
> 	>               /* This one should return same fd */
> 	>               ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1);
> 	> +             ksft_test_result_pass(buf);
> 
> 	This uses a string with all kinds of dynamic data (particularly pid
> 	values) as the test description.  Please use only non-dynamic
> 	strings for test descriptions.  If it is desired to output information
> about
> 	the data used for the test, that should be in a YAML block.
> 
> 
> 
> As now we don't have YAML block implementation yet, so I thought we can
> implement it in a later moment.

TAP13 uses the YAML block for more structured output parsing, but also
supports the backwards compatible comment format, for test diagnostic
output.  That is, you can always have the output look like this:

ok 3 validate that sys_kcmp works
# pid1:  27897 pid2:  27898 FD:  1 FILES:  2 VM:  2 FS:  2 SIGHAND:  1 IO:  0 SYSVSEM:  0 INV: -1

I  would recommend that we either: 1) implement some basic
ksft_output_yaml(), or 2) just use printfs to output commented
lines, so that this information text is not lost.

However, I do think we need to migrate to non-dynamic strings in
the test description lines.

If we adopt option 2, then the sequence becomes something like:

(at the start of the routine:)
    const char *test_name="validate that sys_kcmp works";

(then at this call site:)
   ksft_test_result_pass(test_name);
   printf("# %s\n", buf);

-- Tim
��.n��������+%������w��{.n�����{��K����n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux