• Rae Moar's avatar
    kunit: fix bug of extra newline characters in debugfs logs · 2c6a96da
    Rae Moar authored
    Fix bug of the extra newline characters in debugfs logs. When a
    line is added to debugfs with a newline character at the end,
    an extra line appears in the debugfs log.
    
    This is due to a discrepancy between how the lines are printed and how they
    are added to the logs. Remove this discrepancy by checking if a newline
    character is present before adding a newline character. This should closely
    match the printk behavior.
    
    Add kunit_log_newline_test to provide test coverage for this issue.  (Also,
    move kunit_log_test above suite definition to remove the unnecessary
    declaration prior to the suite definition)
    
    As an example, say we add these two lines to the log:
    
    kunit_log(..., "KTAP version 1\n");
    kunit_log(..., "1..1");
    
    The debugfs log before this fix:
    
     KTAP version 1
    
     1..1
    
    The debugfs log after this fix:
    
     KTAP version 1
     1..1
    Signed-off-by: default avatarRae Moar <rmoar@google.com>
    Reviewed-by: default avatarDavid Gow <davidgow@google.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    2c6a96da
test.c 19.9 KB