]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
regtest: add a deliberately false address to drd and helgrind getaddrinfo
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 9 Nov 2023 19:43:55 +0000 (20:43 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 9 Nov 2023 19:43:55 +0000 (20:43 +0100)
Make sure that at least one call fails.

helgrind/tests/getaddrinfo.c

index bdb8434588d66316a77d2cc285b96b4f5fabcdc9..9c9bcc1c5c59f71ec3ce3be2a016e4339165c82c 100644 (file)
@@ -8,15 +8,18 @@ struct data {
     struct addrinfo *res;
 };
 
-struct data threaddat[5] = {
+struct data threaddat[] = {
     { "www.freebsd.org", 0 },
     { "www.google.com", 0 },
     { "www.freshports.org", 0 },
     { "www.github.com", 0 },
-    { "www.kernel.org", 0 }
+    { "www.kernel.org", 0 },
+    { "petunia.bogus.address", 0 }
 };
 
-pthread_t threads[5];
+static const size_t threaddat_size = sizeof(threaddat)/sizeof(threaddat[0]);
+
+pthread_t threads[sizeof(threaddat)/sizeof(threaddat[0])];
 
 void *resolve(void *d) {
     struct data *data = d;
@@ -26,10 +29,10 @@ void *resolve(void *d) {
 
 int main(void) {
     int i;
-    for (i = 0; i < 5; ++i) {
+    for (i = 0; i < threaddat_size; ++i) {
         pthread_create(&threads[i], 0, resolve, &threaddat[i]);
     }
-    for (i = 0; i < 5; ++i) {
+    for (i = 0; i < threaddat_size; ++i) {
         pthread_join(threads[i], 0);
         freeaddrinfo(threaddat[i].res);
     }