-static int
-test_clib_strstr (vlib_main_t * vm, unformat_input_t * input)
-{
- char *sub, *s;
- char s1[64];
- size_t s1len = sizeof (s1) - 1; // excluding null
- int indicator;
-
- vlib_cli_output (vm, "Test clib_strstr...");
-
- /* substring not present */
- strcpy_s (s1, s1len, "success is not final, failure is not fatal.");
- sub = clib_strstr (s1, "failures");
- if (sub != 0)
- return -1;
- /* verify it against strstr */
- sub = strstr (s1, "failures");
- if (sub != 0)
- return -1;
-
- /* substring present */
- sub = clib_strstr (s1, "failure");
- if (sub == 0)
- return -1;
- if (strcmp_s (sub, strlen (sub), "failure is not fatal.", &indicator) !=
- EOK)
- return -1;
- if (indicator != 0)
- return -1;
- /* verify it against strstr */
- sub = strstr (s1, "failure");
- if (sub == 0)
- return -1;
- if (strcmp_s (sub, strlen (sub), "failure is not fatal.", &indicator) !=
- EOK)
- return -1;
- if (indicator != 0)
- return -1;
-
- /* negative stuff */
-
- /* Null pointers test */
- s = 0;
- sub = clib_strstr (s, s);
- if (sub != 0)
- return -1;
- /*
- * Can't verify it against strstr for this test. Null pointers cause strstr
- * to crash. Go figure!
- */
-
- /* unterminated s1 and s2 */
- memset_s (s1, ARRAY_LEN (s1), 0xfe, ARRAY_LEN (s1));
- sub = clib_strstr (s1, s1);
- if (sub == 0)
- return -1;
- /*
- * Can't verify it against strstr for this test. Unterminated string causes
- * strstr to crash. Go figure!
- */
-
- /* OK, seems to work */
- return 0;
-}
-
-#define foreach_string_test \
- _ (0, MEMCPY_S, "memcpy_s", memcpy_s) \
- _ (1, CLIB_MEMCPY, "clib_memcpy", clib_memcpy) \
- _ (2, MEMSET_S , "memset_s", memset_s) \
- _ (3, CLIB_MEMSET , "clib_memset", clib_memset) \
- _ (4, MEMCMP_S, "memcmp_s", memcmp_s) \
- _ (5, CLIB_MEMCMP, "clib_memcmp", clib_memcmp) \
- _ (6, STRCMP_S, "strcmp_s", strcmp_s) \
- _ (7, CLIB_STRCMP, "clib_strcmp", clib_strcmp) \
- _ (8, STRNCMP_S, "strncmp_s", strncmp_s) \
- _ (9, CLIB_STRNCMP, "clib_strncmp", clib_strncmp) \
- _ (10, STRCPY_S, "strcpy_s", strcpy_s) \
- _ (11, CLIB_STRCPY, "clib_strcpy", clib_strcpy) \
- _ (12, STRNCPY_S, "strncpy_s", strncpy_s) \
- _ (13, CLIB_STRNCPY, "clib_strncpy", clib_strncpy) \
- _ (14, STRCAT_S, "strcat_s", strcat_s) \
- _ (15, CLIB_STRCAT, "clib_strcat", clib_strcat) \
- _ (16, STRNCAT_S, "strncat_s", strncat_s) \
- _ (17, CLIB_STRNCAT, "clib_strncat", clib_strncat) \
- _ (18, STRTOK_S, "strtok_s", strtok_s) \
- _ (19, CLIB_STRTOK, "clib_strtok", clib_strtok) \
- _ (20, STRNLEN_S, "strnlen_s", strnlen_s) \
- _ (21, CLIB_STRNLEN, "clib_strnlen", clib_strnlen) \
- _ (22, STRSTR_S, "strstr_s", strstr_s) \
- _ (23, CLIB_STRSTR, "clib_strstr", clib_strstr)
+#define foreach_string_test \
+ _ (0, MEMCPY_S, "memcpy_s", memcpy_s) \
+ _ (1, CLIB_MEMCPY, "clib_memcpy", clib_memcpy) \
+ _ (2, MEMSET_S, "memset_s", memset_s) \
+ _ (3, CLIB_MEMSET, "clib_memset", clib_memset) \
+ _ (4, MEMCMP_S, "memcmp_s", memcmp_s) \
+ _ (5, CLIB_MEMCMP, "clib_memcmp", clib_memcmp) \
+ _ (6, STRCMP_S, "strcmp_s", strcmp_s) \
+ _ (7, CLIB_STRCMP, "clib_strcmp", clib_strcmp) \
+ _ (8, STRNCMP_S, "strncmp_s", strncmp_s) \
+ _ (9, CLIB_STRNCMP, "clib_strncmp", clib_strncmp) \
+ _ (10, STRCPY_S, "strcpy_s", strcpy_s) \
+ _ (11, STRNCPY_S, "strncpy_s", strncpy_s) \
+ _ (12, CLIB_STRNCPY, "clib_strncpy", clib_strncpy) \
+ _ (13, STRCAT_S, "strcat_s", strcat_s) \
+ _ (14, STRNCAT_S, "strncat_s", strncat_s) \
+ _ (15, STRTOK_S, "strtok_s", strtok_s) \
+ _ (16, CLIB_STRTOK, "clib_strtok", clib_strtok) \
+ _ (17, STRNLEN_S, "strnlen_s", strnlen_s) \
+ _ (18, CLIB_STRNLEN, "clib_strnlen", clib_strnlen) \
+ _ (19, STRSTR_S, "strstr_s", strstr_s)