diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2025-07-19 07:43:27 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2025-08-04 14:41:29 -0700 |
commit | e7db5150603bb2224a2bfd9628cae04ddcbe49e3 (patch) | |
tree | d0cf9a2fc0298d4e3fe9574de318e1ae03251a26 | |
parent | d27b1a71cd424710813bd3d81afb32a36470d643 (diff) | |
download | glibc-e7db5150603bb2224a2bfd9628cae04ddcbe49e3.zip glibc-e7db5150603bb2224a2bfd9628cae04ddcbe49e3.tar.gz glibc-e7db5150603bb2224a2bfd9628cae04ddcbe49e3.tar.bz2 |
tst-fopen-threaded.c: Delete temporary file
Update tst-fopen-threaded.c to call support_create_temp_directory to
create a temporary directory and open "file" in the temporary directory,
instead of using /tmp/openclosetest and leaving it behind.
This partially fixes BZ #33182.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r-- | sysdeps/pthread/tst-fopen-threaded.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sysdeps/pthread/tst-fopen-threaded.c b/sysdeps/pthread/tst-fopen-threaded.c index ade58ad..c17f1ea 100644 --- a/sysdeps/pthread/tst-fopen-threaded.c +++ b/sysdeps/pthread/tst-fopen-threaded.c @@ -34,11 +34,13 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <stdlib.h> #include <support/check.h> #include <support/temp_file.h> #include <support/xstdio.h> #include <support/xthread.h> +#include <support/support.h> #define NUM_THREADS 100 #define ITERS 10 @@ -111,7 +113,8 @@ threadOpenCloseRoutine (void *argv) /* Wait for all threads to be ready to call fopen and fclose. */ xpthread_barrier_wait (&barrier); - FILE *fd = xfopen ("/tmp/openclosetest", "w+"); + char *file = (char *) argv; + FILE *fd = xfopen (file, "w+"); xfclose (fd); return NULL; } @@ -235,6 +238,10 @@ do_test (void) xfclose (fd_file); } + char *tempdir = support_create_temp_directory ("openclosetest-"); + char *file = xasprintf ("%s/file", tempdir); + add_temp_file (file); + /* Test 3: Concurrent open/close. */ for (int reps = 1; reps <= ITERS; reps++) { @@ -243,7 +250,7 @@ do_test (void) { threads[i] = xpthread_create (support_small_stack_thread_attribute (), - threadOpenCloseRoutine, NULL); + threadOpenCloseRoutine, file); } for (int i = 0; i < NUM_THREADS; i++) { @@ -252,6 +259,9 @@ do_test (void) xpthread_barrier_destroy (&barrier); } + free (file); + free (tempdir); + return 0; } |