]> Zhao Yanbai Git Server - minix.git/commitdiff
some prettification for test55.
authorBen Gras <ben@minix3.org>
Thu, 24 Jun 2010 00:27:26 +0000 (00:27 +0000)
committerBen Gras <ben@minix3.org>
Thu, 24 Jun 2010 00:27:26 +0000 (00:27 +0000)
test/test55.c

index 165e2c49294689e4a2a51f1c85c62a6a3c8fe20d..5dbbb0004d71325779d750d274b3ec31a3b7f2f8 100644 (file)
@@ -8,15 +8,17 @@
 #define TRIALS 10
 #define SIZE   65536
 
-void create_file(void)
+#define TMPPATH "/usr/tmp/"
+
+char *create_file(void)
 {
        char buf[SIZE]={0};
        char *p;
+       ssize_t ntowrite, nwritten;
        int fd;
        char *filename;
-       ssize_t ntowrite, nwritten;
 
-       if((filename = mktemp("/tmp/statvfs_test_XXXXXXX")) == NULL) {
+       if((filename = mktemp(TMPPATH "statvfs_test_XXXXXXX")) == NULL) {
                err(1, "mktemp failed");
        }
 
@@ -33,6 +35,10 @@ void create_file(void)
                p += nwritten;
                ntowrite -= nwritten;
        }
+
+       close(fd);
+
+       return filename;
 }
 
 int main(int argc, char *argv[])
@@ -54,7 +60,10 @@ int main(int argc, char *argv[])
        printf("Test 55 ");
        
        for(i = 0; i < TRIALS; i++) {
-               if(statvfs("/tmp", &stats) < 0) {
+               int r;
+               char *filename;
+
+               if(statvfs(TMPPATH, &stats) < 0) {
                        perror("statvfs failed");
                        return 1;
                }
@@ -71,9 +80,13 @@ int main(int argc, char *argv[])
                f_flag    = stats.f_flag   ;
                f_namemax = stats.f_namemax;
                
-               create_file();
+               filename = create_file();
+
+               r = statvfs(TMPPATH, &stats);
+
+               unlink(filename);
 
-               if(statvfs("/tmp", &stats) < 0) {
+               if(r < 0) {
                        perror("statvfs failed");
                        return 1;
                }