summaryrefslogtreecommitdiff
path: root/lib/kunit/string-stream-test.c
diff options
context:
space:
mode:
authorBrendan Higgins <brendanhiggins@google.com>2019-09-23 02:02:41 -0700
committerShuah Khan <skhan@linuxfoundation.org>2019-09-30 17:35:01 -0600
commite4aea8f8532b55f966d828efcf720f8aeb203e13 (patch)
tree3ed6e6f8f451c40b34c6c42759116a00bca1c4a6 /lib/kunit/string-stream-test.c
parente4eb117f61486e8a1e6edec7d95dbdd712a5429b (diff)
kunit: test: add the concept of assertions
Add support for assertions which are like expectations except the test terminates if the assertion is not satisfied. The idea with assertions is that you use them to state all the preconditions for your test. Logically speaking, these are the premises of the test case, so if a premise isn't true, there is no point in continuing the test case because there are no conclusions that can be drawn without the premises. Whereas, the expectation is the thing you are trying to prove. It is not used universally in x-unit style test frameworks, but I really like it as a convention. You could still express the idea of a premise using the above idiom, but I think KUNIT_ASSERT_* states the intended idea perfectly. Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/string-stream-test.c')
-rw-r--r--lib/kunit/string-stream-test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/kunit/string-stream-test.c b/lib/kunit/string-stream-test.c
index 75229e267c32..76cc05eb00ed 100644
--- a/lib/kunit/string-stream-test.c
+++ b/lib/kunit/string-stream-test.c
@@ -35,7 +35,7 @@ static void string_stream_test_get_string(struct kunit *test)
string_stream_add(stream, " %s", "bar");
output = string_stream_get_string(stream);
- KUNIT_EXPECT_STREQ(test, output, "Foo bar");
+ KUNIT_ASSERT_STREQ(test, output, "Foo bar");
}
static struct kunit_case string_stream_test_cases[] = {