Files
Brendan Higgins eee7f4a3f8 kunit: test: adds KUnit, a basic unit testing library for Linux
Adds the core of KUnit along with a minimal set of features. In
particular, this adds:
 - the base reporting infrastructure for reporting test results.
 - the concept of test modules and test cases, which is how tests are
   specified and organized.
 - infrastructure for running test modules and cases on UML.
 - expectations, which is how properties to be verified by a test are
   asserted.

Change-Id: I61ea0abe30fd0f1679e5cd16d0c101b956380d52
Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
2018-08-14 14:11:29 -07:00

49 lines
1.4 KiB
C++

/* SPDX-License-Identifier: GPL-2.0 */
/*
* C++ stream style string formatter and printer used in KUnit for outputting
* KUnit messages.
*
* Copyright (C) 2018, Google LLC.
* Author: Brendan Higgins <brendanhiggins@google.com>
*/
#ifndef _TEST_TEST_STREAM_H
#define _TEST_TEST_STREAM_H
#include <linux/types.h>
#include <test/string-stream.h>
struct test;
/**
* struct test_stream - a std::stream style string builder.
* @set_level: sets the level that this string should be printed at.
* @add: adds the formatted input to the internal buffer.
* @commit: prints out the internal buffer to the user.
* @clear: clears the internal buffer.
*
* A std::stream style string builder. Allows messages to be built up and
* printed all at once.
*/
struct test_stream {
void (*set_level)(struct test_stream *this, const char *level);
void (*add)(struct test_stream *this, const char *fmt, ...);
void (*append)(struct test_stream *this, struct test_stream *other);
void (*commit)(struct test_stream *this);
void (*clear)(struct test_stream *this);
/* private: internal use only. */
struct test *test;
const char *level;
struct string_stream *internal_stream;
};
/**
* test_new_stream() - constructs a new &struct test_stream.
* @test: The test context object.
*
* Constructs a new test managed &struct test_stream.
*/
struct test_stream *test_new_stream(struct test *test);
#endif /* _TEST_TEST_STREAM_H */