From: Ben Gras Date: Thu, 24 Jun 2010 00:27:26 +0000 (+0000) Subject: some prettification for test55. X-Git-Tag: v3.1.8~370 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.host.html?a=commitdiff_plain;h=762665cec1a5ec0fcbaa6b927f0368ded45fcf82;p=minix.git some prettification for test55. --- diff --git a/test/test55.c b/test/test55.c index 165e2c492..5dbbb0004 100644 --- a/test/test55.c +++ b/test/test55.c @@ -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; }