kunit: subtests should be indented 4 spaces according to TAP

Introduce KUNIT_SUBTEST_INDENT macro which corresponds to 4-space
indentation and KUNIT_SUBSUBTEST_INDENT macro which corresponds to
8-space indentation in line with TAP spec (e.g. see "Subtests"
section of https://node-tap.org/tap-protocol/).

Use these macros in place of one or two tabs in strings to clarify
why we are indenting.

Suggested-by: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
Alan Maguire
2020-03-26 14:25:09 +00:00
committed by Shuah Khan
parent eda8e324f7
commit c3bba690a2
4 changed files with 59 additions and 48 deletions

View File

@@ -84,6 +84,14 @@ struct kunit;
/* Size of log associated with test. */
#define KUNIT_LOG_SIZE 512
/*
* TAP specifies subtest stream indentation of 4 spaces, 8 spaces for a
* sub-subtest. See the "Subtests" section in
* https://node-tap.org/tap-protocol/
*/
#define KUNIT_SUBTEST_INDENT " "
#define KUNIT_SUBSUBTEST_INDENT " "
/**
* struct kunit_case - represents an individual test case.
*
@@ -395,7 +403,8 @@ void kunit_log_append(char *log, const char *fmt, ...);
} while (0)
#define kunit_printk(lvl, test, fmt, ...) \
kunit_log(lvl, test, "\t# %s: " fmt, (test)->name, ##__VA_ARGS__)
kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt, \
(test)->name, ##__VA_ARGS__)
/**
* kunit_info() - Prints an INFO level message associated with @test.