sort: add -x hex sort feature back
[minix.git] / test / test55.c
blobd309d390d17881f12157d264ef03ffa82d9d9191
1 #include <sys/statvfs.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <assert.h>
5 #include <fcntl.h>
6 #include <err.h>
7 #include <unistd.h>
8 #define TRIALS 10
9 #define SIZE 65536
11 #define MAX_ERROR 3
13 int subtest;
14 char *filename = "statvfs_test_XXXXXX";
15 #include "common.c"
17 void create_file(void)
19 char buf[SIZE]={0};
20 char *p;
21 ssize_t ntowrite, nwritten;
22 int fd;
24 subtest = 2;
25 if ((fd = mkstemp(filename)) < 0) e(1);
27 ntowrite = SIZE;
28 p = &buf[0];
29 while (ntowrite > 0) {
30 if ((nwritten = write(fd, p, ntowrite)) < 0) e(2);
31 p += nwritten;
32 ntowrite -= nwritten;
35 if (close(fd) < 0) e(3);
38 int main(int argc, char *argv[])
40 struct statvfs stats;
41 unsigned long f_bsize, f_bsize_new;
42 unsigned long f_frsize, f_frsize_new;
43 fsblkcnt_t f_blocks, f_blocks_new;
44 fsblkcnt_t f_bfree, f_bfree_new;
45 fsblkcnt_t f_bavail, f_bavail_new;
46 fsfilcnt_t f_files, f_files_new;
47 fsfilcnt_t f_ffree, f_ffree_new;
48 fsfilcnt_t f_favail, f_favail_new;
49 unsigned long f_fsid, f_fsid_new;
50 unsigned long f_flag, f_flag_new;
51 unsigned long f_namemax, f_namemax_new;
52 int i;
54 start(55);
56 subtest = 1;
57 for(i = 0; i < TRIALS; i++) {
58 if (statvfs(".", &stats) < 0) e(1);
60 f_bsize = stats.f_bsize ;
61 f_frsize = stats.f_frsize ;
62 f_blocks = stats.f_blocks ;
63 f_bfree = stats.f_bfree ;
64 f_bavail = stats.f_bavail ;
65 f_files = stats.f_files ;
66 f_ffree = stats.f_ffree ;
67 f_favail = stats.f_favail ;
68 f_fsid = stats.f_fsid ;
69 f_flag = stats.f_flag ;
70 f_namemax = stats.f_namemax;
72 create_file();
74 if (statvfs(".", &stats) < 0) e(2);
75 if (unlink(filename) < 0) e(3);
77 f_bsize_new = stats.f_bsize ;
78 f_frsize_new = stats.f_frsize ;
79 f_blocks_new = stats.f_blocks ;
80 f_bfree_new = stats.f_bfree ;
81 f_bavail_new = stats.f_bavail ;
82 f_files_new = stats.f_files ;
83 f_ffree_new = stats.f_ffree ;
84 f_favail_new = stats.f_favail ;
85 f_fsid_new = stats.f_fsid ;
86 f_flag_new = stats.f_flag ;
87 f_namemax_new = stats.f_namemax;
89 if (!((f_bsize == f_bsize_new) &&
90 (f_frsize == f_frsize_new) &&
91 (f_blocks == f_blocks_new) &&
92 (f_bfree > f_bfree_new) &&
93 (f_bavail > f_bavail_new) &&
94 (f_files == f_files_new) &&
95 (f_ffree == f_ffree_new + 1) &&
96 (f_favail == f_favail_new + 1) &&
97 (f_fsid == f_fsid_new) &&
98 (f_flag == f_flag_new) &&
99 (f_namemax == f_namemax_new))) {
100 e(4);
104 quit();
105 return(-1);