Lines Matching refs:test

30 static char *get_concatenated_string(struct kunit *test, struct string_stream *stream)  in get_concatenated_string()  argument
34 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, str); in get_concatenated_string()
35 kunit_add_action(test, kfree_wrapper, (void *)str); in get_concatenated_string()
41 static void string_stream_managed_init_test(struct kunit *test) in string_stream_managed_init_test() argument
46 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_managed_init_test()
47 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_managed_init_test()
49 KUNIT_EXPECT_EQ(test, stream->length, 0); in string_stream_managed_init_test()
50 KUNIT_EXPECT_TRUE(test, list_empty(&stream->fragments)); in string_stream_managed_init_test()
51 KUNIT_EXPECT_TRUE(test, (stream->gfp == GFP_KERNEL)); in string_stream_managed_init_test()
52 KUNIT_EXPECT_FALSE(test, stream->append_newlines); in string_stream_managed_init_test()
53 KUNIT_EXPECT_TRUE(test, string_stream_is_empty(stream)); in string_stream_managed_init_test()
57 static void string_stream_unmanaged_init_test(struct kunit *test) in string_stream_unmanaged_init_test() argument
62 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_unmanaged_init_test()
63 kunit_add_action(test, cleanup_raw_stream, stream); in string_stream_unmanaged_init_test()
65 KUNIT_EXPECT_EQ(test, stream->length, 0); in string_stream_unmanaged_init_test()
66 KUNIT_EXPECT_TRUE(test, list_empty(&stream->fragments)); in string_stream_unmanaged_init_test()
67 KUNIT_EXPECT_TRUE(test, (stream->gfp == GFP_KERNEL)); in string_stream_unmanaged_init_test()
68 KUNIT_EXPECT_FALSE(test, stream->append_newlines); in string_stream_unmanaged_init_test()
70 KUNIT_EXPECT_TRUE(test, string_stream_is_empty(stream)); in string_stream_unmanaged_init_test()
97 static void string_stream_managed_free_test(struct kunit *test) in string_stream_managed_free_test() argument
99 struct string_stream_test_priv *priv = test->priv; in string_stream_managed_free_test()
105 kunit_activate_static_stub(test, in string_stream_managed_free_test()
109 priv->expected_free_stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_managed_free_test()
110 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->expected_free_stream); in string_stream_managed_free_test()
113 kunit_free_string_stream(test, priv->expected_free_stream); in string_stream_managed_free_test()
115 KUNIT_EXPECT_TRUE(test, priv->stream_was_freed); in string_stream_managed_free_test()
116 KUNIT_EXPECT_FALSE(test, priv->stream_free_again); in string_stream_managed_free_test()
120 static void string_stream_resource_free_test(struct kunit *test) in string_stream_resource_free_test() argument
122 struct string_stream_test_priv *priv = test->priv; in string_stream_resource_free_test()
125 fake_test = kunit_kzalloc(test, sizeof(*fake_test), GFP_KERNEL); in string_stream_resource_free_test()
126 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fake_test); in string_stream_resource_free_test()
144 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->expected_free_stream); in string_stream_resource_free_test()
153 current->kunit_test = test; in string_stream_resource_free_test()
155 KUNIT_EXPECT_TRUE(test, priv->stream_was_freed); in string_stream_resource_free_test()
156 KUNIT_EXPECT_FALSE(test, priv->stream_free_again); in string_stream_resource_free_test()
163 static void string_stream_line_add_test(struct kunit *test) in string_stream_line_add_test() argument
171 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_line_add_test()
172 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_line_add_test()
181 KUNIT_ASSERT_LT(test, len, sizeof(line)); in string_stream_line_add_test()
188 concat_string = get_concatenated_string(test, stream); in string_stream_line_add_test()
189 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, concat_string); in string_stream_line_add_test()
190 KUNIT_EXPECT_EQ(test, strlen(concat_string), total_len); in string_stream_line_add_test()
199 KUNIT_EXPECT_NOT_NULL(test, string_end); in string_stream_line_add_test()
206 KUNIT_EXPECT_STREQ(test, pos, line); in string_stream_line_add_test()
212 KUNIT_EXPECT_EQ(test, strlen(pos), 0); in string_stream_line_add_test()
216 static void string_stream_variable_length_line_test(struct kunit *test) in string_stream_variable_length_line_test() argument
227 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_variable_length_line_test()
228 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_variable_length_line_test()
244 concat_string = get_concatenated_string(test, stream); in string_stream_variable_length_line_test()
245 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, concat_string); in string_stream_variable_length_line_test()
246 KUNIT_EXPECT_EQ(test, strlen(concat_string), total_len); in string_stream_variable_length_line_test()
256 KUNIT_EXPECT_NOT_NULL(test, string_end); in string_stream_variable_length_line_test()
262 KUNIT_EXPECT_STREQ(test, pos, &line[offset]); in string_stream_variable_length_line_test()
268 KUNIT_EXPECT_EQ(test, strlen(pos), 0); in string_stream_variable_length_line_test()
272 static void string_stream_append_test(struct kunit *test) in string_stream_append_test() argument
287 stream_1 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_test()
288 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_1); in string_stream_append_test()
290 stream_2 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_test()
291 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_2); in string_stream_append_test()
295 KUNIT_EXPECT_EQ(test, strlen(get_concatenated_string(test, stream_1)), 0); in string_stream_append_test()
301 stream1_content_before_append = get_concatenated_string(test, stream_1); in string_stream_append_test()
305 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream_1), in string_stream_append_test()
319 stream_2_content = get_concatenated_string(test, stream_2); in string_stream_append_test()
322 combined_content = kunit_kmalloc(test, combined_length, GFP_KERNEL); in string_stream_append_test()
323 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, combined_content); in string_stream_append_test()
327 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream_1), combined_content); in string_stream_append_test()
330 kunit_free_string_stream(test, stream_1); in string_stream_append_test()
332 stream_1 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_test()
333 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_1); in string_stream_append_test()
336 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream_1), stream_2_content); in string_stream_append_test()
340 static void string_stream_append_auto_newline_test(struct kunit *test) in string_stream_append_auto_newline_test() argument
345 stream_1 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_auto_newline_test()
346 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_1); in string_stream_append_auto_newline_test()
348 KUNIT_EXPECT_TRUE(test, stream_1->append_newlines); in string_stream_append_auto_newline_test()
351 stream_2 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_auto_newline_test()
352 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_2); in string_stream_append_auto_newline_test()
359 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream_1), in string_stream_append_auto_newline_test()
362 kunit_free_string_stream(test, stream_2); in string_stream_append_auto_newline_test()
363 stream_2 = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_auto_newline_test()
364 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream_2); in string_stream_append_auto_newline_test()
374 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream_1), in string_stream_append_auto_newline_test()
379 static void string_stream_append_empty_string_test(struct kunit *test) in string_stream_append_empty_string_test() argument
384 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_append_empty_string_test()
385 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_append_empty_string_test()
389 KUNIT_EXPECT_TRUE(test, string_stream_is_empty(stream)); in string_stream_append_empty_string_test()
390 KUNIT_EXPECT_TRUE(test, list_empty(&stream->fragments)); in string_stream_append_empty_string_test()
397 KUNIT_EXPECT_EQ(test, list_count_nodes(&stream->fragments), original_frag_count); in string_stream_append_empty_string_test()
398 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream), "Add this line"); in string_stream_append_empty_string_test()
402 static void string_stream_no_auto_newline_test(struct kunit *test) in string_stream_no_auto_newline_test() argument
406 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_no_auto_newline_test()
407 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_no_auto_newline_test()
420 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream), in string_stream_no_auto_newline_test()
425 static void string_stream_auto_newline_test(struct kunit *test) in string_stream_auto_newline_test() argument
429 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_auto_newline_test()
430 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_auto_newline_test()
433 KUNIT_EXPECT_TRUE(test, stream->append_newlines); in string_stream_auto_newline_test()
447 KUNIT_EXPECT_STREQ(test, get_concatenated_string(test, stream), in string_stream_auto_newline_test()
455 static void string_stream_performance_test(struct kunit *test) in string_stream_performance_test() argument
464 stream = kunit_alloc_string_stream(test, GFP_KERNEL); in string_stream_performance_test()
465 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream); in string_stream_performance_test()
495 kunit_info(test, "Time elapsed: %lld us\n", in string_stream_performance_test()
497 kunit_info(test, "Total string length: %zu\n", total_string_length); in string_stream_performance_test()
498 kunit_info(test, "Bytes requested: %zu\n", bytes_requested); in string_stream_performance_test()
499 kunit_info(test, "Actual bytes allocated: %zu\n", actual_bytes_used); in string_stream_performance_test()
502 static int string_stream_test_init(struct kunit *test) in string_stream_test_init() argument
506 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in string_stream_test_init()
510 test->priv = priv; in string_stream_test_init()