diff options
-rw-r--r-- | src/plugins/unittest/string_test.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/plugins/unittest/string_test.c b/src/plugins/unittest/string_test.c index 2beee139ec9..65b7c62ece8 100644 --- a/src/plugins/unittest/string_test.c +++ b/src/plugins/unittest/string_test.c @@ -559,9 +559,12 @@ test_strcpy_s (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = strcpy_s (dst, s1size, dst); if (err == EOK) return -1; +#endif /* overlap fail */ err = strcpy_s (dst, s1size, dst + 1); @@ -610,9 +613,12 @@ test_clib_strcpy (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = clib_strcpy (dst, dst); if (err == EOK) return -1; +#endif /* overlap fail */ err = clib_strcpy (dst, dst + 1); @@ -706,9 +712,12 @@ test_strncpy_s (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = strncpy_s (dst, s1size, dst, s1size); if (err == EOK) return -1; +#endif /* OK, seems to work */ return 0; @@ -758,12 +767,16 @@ test_clib_strncpy (vlib_main_t * vm, unformat_input_t * input) return -1; /* verify it against strncpy */ memset_s (dst, sizeof (dst), 0, sizeof (dst)); + +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ strncpy (dst, "The price of greatness is responsibility.", 10); if (strcmp_s (dst, clib_strnlen (dst, sizeof (dst)), "The price ", &indicator) != EOK) return -1; if (indicator != 0) return -1; +#endif /* n > string len of src */ err = clib_strncpy (dst, src, clib_strnlen (src, sizeof (src)) + 10); @@ -806,9 +819,12 @@ test_clib_strncpy (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = clib_strncpy (dst, dst, s1size); if (err == EOK) return -1; +#endif /* OK, seems to work */ return 0; @@ -858,9 +874,12 @@ test_strcat_s (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = strcat_s (dst, s1size, dst); if (err != EINVAL) return -1; +#endif /* not enough space for dst */ err = strcat_s (dst, 10, src); @@ -925,9 +944,12 @@ test_clib_strcat (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = clib_strcat (dst, dst); if (err != EINVAL) return -1; +#endif /* OK, seems to work */ return 0; @@ -1046,9 +1068,12 @@ test_strncat_s (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = strncat_s (dst, s1size, dst, clib_strnlen (dst, sizeof (dst))); if (err != EINVAL) return -1; +#endif /* OK, seems to work */ return 0; @@ -1160,9 +1185,12 @@ test_clib_strncat (vlib_main_t * vm, unformat_input_t * input) return -1; /* overlap fail */ +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ err = clib_strncat (dst, dst, clib_strnlen (dst, sizeof (dst))); if (err != EINVAL) return -1; +#endif /* OK, seems to work */ return 0; @@ -1266,7 +1294,9 @@ static int test_clib_strtok (vlib_main_t * vm, unformat_input_t * input) { int indicator; - char *tok, *ptr, *s1; + char *s1 __attribute__ ((unused)); + char *tok __attribute__ ((unused)); + char *ptr __attribute__ ((unused)); char str1[40]; char *p2str; char *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7; @@ -1368,6 +1398,8 @@ test_clib_strtok (vlib_main_t * vm, unformat_input_t * input) /* negative stuff */ s1 = 0; ptr = 0; +#if __GNUC__ < 8 + /* GCC 8 flunks this one at compile time... */ tok = clib_strtok (s1, s1, (char **) 0); if (tok != 0) return -1; @@ -1376,6 +1408,8 @@ test_clib_strtok (vlib_main_t * vm, unformat_input_t * input) tok = clib_strtok (s1, s1, &ptr); if (tok != 0) return -1; +#endif + /* verify it against strtok_r */ /* No can do. This causes a crash in strtok_r */ // tok = strtok_r (s1, " ", &ptr); |