| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib rand" { ! hostedlib } } */ |
| 2 |
|
| 3 |
/* Reduced from |
| 4 |
https://github.com/libguestfs/libguestfs/blob/e0a11061035d47b118c95706240bcc17fd576edc/tests/mount-local/test-parallel-mount-local.c#L299-L335 |
| 5 |
which is GPLv2 or later. */ |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
#include <stdlib.h> |
| 9 |
|
| 10 |
extern int foo (void); |
| 11 |
|
| 12 |
void |
| 13 |
test_mountpoint (const char *mp) |
| 14 |
{ |
| 15 |
const int nr_passes = 5 + (rand () & 31); |
| 16 |
int pass; |
| 17 |
int ret = 1; |
| 18 |
FILE *fp; |
| 19 |
|
| 20 |
for (pass = 0; pass < nr_passes; ++pass) { |
| 21 |
if (foo ()) { |
| 22 |
goto error; |
| 23 |
} |
| 24 |
fp = fopen ("file", "w"); |
| 25 |
if (fp == NULL) { |
| 26 |
goto error; |
| 27 |
} |
| 28 |
fprintf (fp, "hello world\n"); |
| 29 |
fclose (fp); /* { dg-bogus "double 'fclose'" } */ |
| 30 |
} |
| 31 |
|
| 32 |
ret = 0; |
| 33 |
|
| 34 |
error: |
| 35 |
exit (ret); |
| 36 |
} |