Skip to content

Commit dde915c

Browse files
committed
string: Convert KUnit test names to standard convention
The KUnit convention for test names is AREA_test_WHAT. Adjust the string test names to follow this pattern. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Tested-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20240419140155.3028912-5-keescook@chromium.org Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent bd678f7 commit dde915c

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

lib/string_kunit.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define STRCMP_TEST_EXPECT_LOWER(test, fn, ...) KUNIT_EXPECT_LT(test, fn(__VA_ARGS__), 0)
1818
#define STRCMP_TEST_EXPECT_GREATER(test, fn, ...) KUNIT_EXPECT_GT(test, fn(__VA_ARGS__), 0)
1919

20-
static void test_memset16(struct kunit *test)
20+
static void string_test_memset16(struct kunit *test)
2121
{
2222
unsigned i, j, k;
2323
u16 v, *p;
@@ -46,7 +46,7 @@ static void test_memset16(struct kunit *test)
4646
}
4747
}
4848

49-
static void test_memset32(struct kunit *test)
49+
static void string_test_memset32(struct kunit *test)
5050
{
5151
unsigned i, j, k;
5252
u32 v, *p;
@@ -75,7 +75,7 @@ static void test_memset32(struct kunit *test)
7575
}
7676
}
7777

78-
static void test_memset64(struct kunit *test)
78+
static void string_test_memset64(struct kunit *test)
7979
{
8080
unsigned i, j, k;
8181
u64 v, *p;
@@ -104,7 +104,7 @@ static void test_memset64(struct kunit *test)
104104
}
105105
}
106106

107-
static void test_strchr(struct kunit *test)
107+
static void string_test_strchr(struct kunit *test)
108108
{
109109
const char *test_string = "abcdefghijkl";
110110
const char *empty_string = "";
@@ -127,7 +127,7 @@ static void test_strchr(struct kunit *test)
127127
KUNIT_ASSERT_NULL(test, result);
128128
}
129129

130-
static void test_strnchr(struct kunit *test)
130+
static void string_test_strnchr(struct kunit *test)
131131
{
132132
const char *test_string = "abcdefghijkl";
133133
const char *empty_string = "";
@@ -160,7 +160,7 @@ static void test_strnchr(struct kunit *test)
160160
KUNIT_ASSERT_NULL(test, result);
161161
}
162162

163-
static void test_strspn(struct kunit *test)
163+
static void string_test_strspn(struct kunit *test)
164164
{
165165
static const struct strspn_test {
166166
const char str[16];
@@ -196,7 +196,7 @@ static void strcmp_fill_buffers(char fill1, char fill2)
196196
strcmp_buffer2[STRCMP_LARGE_BUF_LEN - 1] = 0;
197197
}
198198

199-
static void test_strcmp(struct kunit *test)
199+
static void string_test_strcmp(struct kunit *test)
200200
{
201201
/* Equal strings */
202202
STRCMP_TEST_EXPECT_EQUAL(test, strcmp, "Hello, Kernel!", "Hello, Kernel!");
@@ -214,7 +214,7 @@ static void test_strcmp(struct kunit *test)
214214
STRCMP_TEST_EXPECT_LOWER(test, strcmp, "Just a string", "Just a string and something else");
215215
}
216216

217-
static void test_strcmp_long_strings(struct kunit *test)
217+
static void string_test_strcmp_long_strings(struct kunit *test)
218218
{
219219
strcmp_fill_buffers('B', 'B');
220220
STRCMP_TEST_EXPECT_EQUAL(test, strcmp, strcmp_buffer1, strcmp_buffer2);
@@ -226,7 +226,7 @@ static void test_strcmp_long_strings(struct kunit *test)
226226
STRCMP_TEST_EXPECT_GREATER(test, strcmp, strcmp_buffer1, strcmp_buffer2);
227227
}
228228

229-
static void test_strncmp(struct kunit *test)
229+
static void string_test_strncmp(struct kunit *test)
230230
{
231231
/* Equal strings */
232232
STRCMP_TEST_EXPECT_EQUAL(test, strncmp, "Hello, KUnit!", "Hello, KUnit!", 13);
@@ -249,7 +249,7 @@ static void test_strncmp(struct kunit *test)
249249
strlen("Just a string"));
250250
}
251251

252-
static void test_strncmp_long_strings(struct kunit *test)
252+
static void string_test_strncmp_long_strings(struct kunit *test)
253253
{
254254
strcmp_fill_buffers('B', 'B');
255255
STRCMP_TEST_EXPECT_EQUAL(test, strncmp, strcmp_buffer1,
@@ -269,7 +269,7 @@ static void test_strncmp_long_strings(struct kunit *test)
269269
strcmp_buffer2, STRCMP_CHANGE_POINT + 1);
270270
}
271271

272-
static void test_strcasecmp(struct kunit *test)
272+
static void string_test_strcasecmp(struct kunit *test)
273273
{
274274
/* Same strings in different case should be equal */
275275
STRCMP_TEST_EXPECT_EQUAL(test, strcasecmp, "Hello, Kernel!", "HeLLO, KErNeL!");
@@ -282,7 +282,7 @@ static void test_strcasecmp(struct kunit *test)
282282
STRCMP_TEST_EXPECT_EQUAL(test, strcasecmp, "-+**.1230ghTTT~^", "-+**.1230Ghttt~^");
283283
}
284284

285-
static void test_strcasecmp_long_strings(struct kunit *test)
285+
static void string_test_strcasecmp_long_strings(struct kunit *test)
286286
{
287287
strcmp_fill_buffers('b', 'B');
288288
STRCMP_TEST_EXPECT_EQUAL(test, strcasecmp, strcmp_buffer1, strcmp_buffer2);
@@ -294,7 +294,7 @@ static void test_strcasecmp_long_strings(struct kunit *test)
294294
STRCMP_TEST_EXPECT_GREATER(test, strcasecmp, strcmp_buffer1, strcmp_buffer2);
295295
}
296296

297-
static void test_strncasecmp(struct kunit *test)
297+
static void string_test_strncasecmp(struct kunit *test)
298298
{
299299
/* Same strings in different case should be equal */
300300
STRCMP_TEST_EXPECT_EQUAL(test, strncasecmp, "AbAcAbA", "Abacaba", strlen("Abacaba"));
@@ -306,7 +306,7 @@ static void test_strncasecmp(struct kunit *test)
306306
STRCMP_TEST_EXPECT_EQUAL(test, strncasecmp, "Abacaba", "Not abacaba", 0);
307307
}
308308

309-
static void test_strncasecmp_long_strings(struct kunit *test)
309+
static void string_test_strncasecmp_long_strings(struct kunit *test)
310310
{
311311
strcmp_fill_buffers('b', 'B');
312312
STRCMP_TEST_EXPECT_EQUAL(test, strncasecmp, strcmp_buffer1,
@@ -398,7 +398,7 @@ static void strscpy_check(struct kunit *test, char *src, int count,
398398
}
399399
}
400400

401-
static void test_strscpy(struct kunit *test)
401+
static void string_test_strscpy(struct kunit *test)
402402
{
403403
char dest[8];
404404

@@ -447,7 +447,7 @@ static void test_strscpy(struct kunit *test)
447447

448448
static volatile int unconst;
449449

450-
static void test_strcat(struct kunit *test)
450+
static void string_test_strcat(struct kunit *test)
451451
{
452452
char dest[8];
453453

@@ -466,7 +466,7 @@ static void test_strcat(struct kunit *test)
466466
KUNIT_EXPECT_STREQ(test, dest, "fourAB");
467467
}
468468

469-
static void test_strncat(struct kunit *test)
469+
static void string_test_strncat(struct kunit *test)
470470
{
471471
char dest[8];
472472

@@ -493,7 +493,7 @@ static void test_strncat(struct kunit *test)
493493
KUNIT_EXPECT_STREQ(test, dest, "fourAB");
494494
}
495495

496-
static void test_strlcat(struct kunit *test)
496+
static void string_test_strlcat(struct kunit *test)
497497
{
498498
char dest[8] = "";
499499
int len = sizeof(dest) + unconst;
@@ -525,24 +525,24 @@ static void test_strlcat(struct kunit *test)
525525
}
526526

527527
static struct kunit_case string_test_cases[] = {
528-
KUNIT_CASE(test_memset16),
529-
KUNIT_CASE(test_memset32),
530-
KUNIT_CASE(test_memset64),
531-
KUNIT_CASE(test_strchr),
532-
KUNIT_CASE(test_strnchr),
533-
KUNIT_CASE(test_strspn),
534-
KUNIT_CASE(test_strcmp),
535-
KUNIT_CASE(test_strcmp_long_strings),
536-
KUNIT_CASE(test_strncmp),
537-
KUNIT_CASE(test_strncmp_long_strings),
538-
KUNIT_CASE(test_strcasecmp),
539-
KUNIT_CASE(test_strcasecmp_long_strings),
540-
KUNIT_CASE(test_strncasecmp),
541-
KUNIT_CASE(test_strncasecmp_long_strings),
542-
KUNIT_CASE(test_strscpy),
543-
KUNIT_CASE(test_strcat),
544-
KUNIT_CASE(test_strncat),
545-
KUNIT_CASE(test_strlcat),
528+
KUNIT_CASE(string_test_memset16),
529+
KUNIT_CASE(string_test_memset32),
530+
KUNIT_CASE(string_test_memset64),
531+
KUNIT_CASE(string_test_strchr),
532+
KUNIT_CASE(string_test_strnchr),
533+
KUNIT_CASE(string_test_strspn),
534+
KUNIT_CASE(string_test_strcmp),
535+
KUNIT_CASE(string_test_strcmp_long_strings),
536+
KUNIT_CASE(string_test_strncmp),
537+
KUNIT_CASE(string_test_strncmp_long_strings),
538+
KUNIT_CASE(string_test_strcasecmp),
539+
KUNIT_CASE(string_test_strcasecmp_long_strings),
540+
KUNIT_CASE(string_test_strncasecmp),
541+
KUNIT_CASE(string_test_strncasecmp_long_strings),
542+
KUNIT_CASE(string_test_strscpy),
543+
KUNIT_CASE(string_test_strcat),
544+
KUNIT_CASE(string_test_strncat),
545+
KUNIT_CASE(string_test_strlcat),
546546
{}
547547
};
548548

0 commit comments

Comments
 (0)