Currently the large_mounts test uses mkstemp to generate a temporary mounts
file.  This leaves the temporary files in around after the test is finished.
This patch changes the test to use tmpfile instead because the file returned
is cleaned when the stream is closed.

Signed-off-by: Eric B Munson <[EMAIL PROTECTED]>

---

 tests/large_mounts.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/large_mounts.c b/tests/large_mounts.c
index 5b1bbee..47bdc23 100644
--- a/tests/large_mounts.c
+++ b/tests/large_mounts.c
@@ -35,10 +35,10 @@
 
 #define BUF_SIZE 4096
 #define FILLER "tmpfs /var/run tmpfs rw,nosuid,nodev,noexec,mode=755 0 0\n"
-#define TMP_MOUNTS "hugetlbfs_large_mounts-XXXXXX"
 
 int in_test; /* = 0; */
 int tmp_mounts_fd; /* = 0; */
+FILE *tmp_stream; /* = NULL; */
 
 /*
  * We override the normal open, so we can remember the fd for the
@@ -62,16 +62,17 @@ int open(const char *path, int flags, ...)
 void make_test_mounts()
 {
        char buf[BUF_SIZE];
-       char tmp_mounts[] = TMP_MOUNTS;
        int mounts_fd;
        unsigned int written = 0;
        int ret;
        int filler_sz;
 
        mounts_fd = open("/proc/mounts", O_RDONLY);
-       tmp_mounts_fd = mkstemp(tmp_mounts);
-       if (mounts_fd < 0 || tmp_mounts_fd < 0)
-               FAIL("Unable to open /proc/mounts or %s", TMP_MOUNTS);
+       tmp_stream = tmpfile();
+       if (mounts_fd < 0 || !tmp_stream)
+               FAIL("Unable to open /proc/mounts or temporary mounts file\n");
+
+       tmp_mounts_fd = fileno(tmp_stream);
 
        filler_sz = strlen(FILLER);
 
@@ -97,6 +98,7 @@ int main(int argc, char *argv[])
 
        fd = hugetlbfs_unlinked_fd();
 
+       fclose(tmp_stream);
        if (fd < 0)
                FAIL("Unable to find mount point\n");
 

Attachment: signature.asc
Description: Digital signature

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to