]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DHAT regtest: add wcpncpy and wcsncpy to copy test
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 26 Jun 2026 19:04:39 +0000 (21:04 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 26 Jun 2026 19:05:35 +0000 (21:05 +0200)
dhat/tests/copy.c
dhat/tests/copy.stderr.exp
dhat/tests/filter_copy

index 18479d782b39090434dceed82844afe720402c3d..5f3f8ed4ba12da73698d4f9cbf849af6b58039f9 100644 (file)
@@ -38,8 +38,9 @@ int main(void) {
 }
 
 void f(char* a, char* b, wchar_t* wa, wchar_t* wb) {
-   // The memcpy is duplicated so we have 10 calls, which makes for nice round
-   // numbers in the totals.
+   // The memcpy is duplicated so we have 10 calls
+   // which was a nice round 100,000 until wcpncpy
+   // and wcsncpy were added
    memcpy (a, b, 1000); // Redirects to memmove
    memcpy (a, b, 1000); // Redirects to memmove
    memmove(a, b, 1000);
@@ -54,6 +55,16 @@ void f(char* a, char* b, wchar_t* wa, wchar_t* wb) {
    stpcpy (a, b);       // Redirects to strcpy
    stpncpy(a, b, 1000);
    wcscpy (wa, wb);
+#if defined(HAVE_WCPNCPY)
+   wcpncpy(wa, wb, 1000/sizeof(*wa));
+#else
+   memcpy(a, b, 1000);
+#endif
+#if defined(HAVE_WCSNCPY)
+    wcsncpy(wa, wb, 1000/sizeof(*wa));
+#else
+   memcpy(a, b, 1000);
+#endif
 }
 
 void test_malloc() {
index 2e35f697ebecab4a287278d6f5dc5aa4d4a6bb24..9955a8b2870ae47025375380d46d484dbccde256 100644 (file)
@@ -1 +1 @@
-Total:     1,000,... bytes in 1,0.. blocks
+Total:     1,200,... bytes in 1,2.. blocks
index 57b6536c6998efa9da74b496ae3428e4d913a61b..6b5827e4a74fdbff4162526aedcd81c96924baa6 100755 (executable)
@@ -2,8 +2,8 @@
 
 # It's impossible to get exact matches for copy counts because even trivial C
 # programs do a few memcpy/strcpy calls. So we allow some fuzzy matching.
-# So we allow 1,000,000..1,009,999 bytes and 1,000..1,099 blocks.
+# So we allow 1,200,000..1,209,999 bytes and 1,200..1,299 blocks.
 
 ./filter_stderr "$@" |
-sed -e "s/1,00.,... bytes in 1,0.. blocks/1,000,... bytes in 1,0.. blocks/"
+sed -e "s/1,20.,... bytes in 1,2.. blocks/1,200,... bytes in 1,2.. blocks/"