• Richard Fitzgerald's avatar
    kunit: string-stream: Decouple string_stream from kunit · a3fdf784
    Richard Fitzgerald authored
    Re-work string_stream so that it is not tied to a struct kunit. This is
    to allow using it for the log of struct kunit_suite.
    
    Instead of resource-managing individual allocations the whole string_stream
    can be resource-managed, if required.
    
        alloc_string_stream() now allocates a string stream that is
        not resource-managed.
    
        string_stream_destroy() now works on an unmanaged string_stream
        allocated by alloc_string_stream() and frees the entire
        string_stream (previously it only freed the fragments).
    
        string_stream_clear() has been made public for callers that
        want to free the fragments without destroying the string_stream.
    
    For resource-managed allocations use kunit_alloc_string_stream()
    and kunit_free_string_stream().
    
    In addition to this, string_stream_get_string() now returns an
    unmanaged buffer that the caller must kfree().
    Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
    Reviewed-by: default avatarDavid Gow <davidgow@google.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    a3fdf784
test.c 21.6 KB