Whamcloud - gitweb
b=15689
[fs/lustre-release.git] / lustre / liblustre / tests / sanity.c
index e46f480..39e45c0 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/queue.h>
 #include <signal.h>
 #include <errno.h>
 #include <dirent.h>
 #include <sys/uio.h>
 #include <sys/time.h>
 #include <time.h>
-#include <sys/ioctl.h>
 
+#include <liblustre.h>
 #include "test_common.h"
-#include <ioctl.h>
 #include <lustre/liblustreapi.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE getpagesize()
-#endif
 #define _npages (2048)
 
 void *buf_alloc;
@@ -57,7 +52,7 @@ struct timeval start;
 
 extern char *lustre_path;
 
-#define ENTRY(str)                                                      \
+#define ENTER(str)                                                      \
         do {                                                            \
                 char buf[100];                                          \
                 int len;                                                \
@@ -113,7 +108,7 @@ int t2(char *name)
 {
         char path[MAX_PATH_LENGTH] = "";
 
-        ENTRY("mkdir/rmdir");
+        ENTER("mkdir/rmdir");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t2", lustre_path);
 
         t_mkdir(path);
@@ -125,7 +120,7 @@ int t3(char *name)
 {
         char path[MAX_PATH_LENGTH] = "";
 
-        ENTRY("regular stat");
+        ENTER("regular stat");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t3", lustre_path);
 
         t_touch(path);
@@ -138,7 +133,7 @@ int t4(char *name)
 {
         char path[MAX_PATH_LENGTH] = "";
 
-        ENTRY("dir stat");
+        ENTER("dir stat");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t4", lustre_path);
 
         t_mkdir(path);
@@ -152,7 +147,7 @@ int t6(char *name)
         char path[MAX_PATH_LENGTH] = "";
         char path2[MAX_PATH_LENGTH] = "";
 
-        ENTRY("symlink");
+        ENTER("symlink");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t6", lustre_path);
         snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6_link", lustre_path);
 
@@ -172,7 +167,7 @@ int t6b(char *name)
         char *tmp;
         int fd;
 
-        ENTRY("symlink + chdir and open");
+        ENTER("symlink + chdir and open");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t6b", lustre_path);
         snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6b_link", lustre_path);
 
@@ -204,7 +199,7 @@ int t7(char *name)
         char path[MAX_PATH_LENGTH] = "";
         int rc;
 
-        ENTRY("mknod");
+        ENTER("mknod");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t7", lustre_path);
 
         if (geteuid() != 0) {
@@ -225,7 +220,7 @@ int t8(char *name)
 {
         char path[MAX_PATH_LENGTH] = "";
 
-        ENTRY("chmod");
+        ENTER("chmod");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t8", lustre_path);
 
         /* Check file. */
@@ -248,7 +243,7 @@ int t9(char *name)
         char path[MAX_PATH_LENGTH] = "";
         char path2[MAX_PATH_LENGTH] = "";
 
-        ENTRY("hard link");
+        ENTER("hard link");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t9", lustre_path);
         snprintf(path2, MAX_PATH_LENGTH, "%s/test_t9_link", lustre_path);
 
@@ -271,7 +266,7 @@ int t10(char *name)
         char rename2[MAX_PATH_LENGTH] = "";
         char rename3[MAX_PATH_LENGTH] = "";
 
-        ENTRY("rename");
+        ENTER("rename");
         snprintf(dir1, MAX_PATH_LENGTH, "%s/test_t10_dir1", lustre_path);
         snprintf(dir2, MAX_PATH_LENGTH, "%s/test_t10_dir2", lustre_path);
         snprintf(path1, MAX_PATH_LENGTH, "%s/test_t10_reg1", lustre_path);
@@ -299,7 +294,7 @@ int t11(char *name)
         char *base=lustre_path;
         char path[MAX_PATH_LENGTH], path2[MAX_PATH_LENGTH];
         int i, j, level = 5, nreg = 5;
-        ENTRY("deep tree");
+        ENTER("deep tree");
 
         safe_strncpy(path, base, MAX_PATH_LENGTH);
 
@@ -335,7 +330,7 @@ int t12(char *name)
         char dir[MAX_PATH_LENGTH] = "";
         char buf[1024*128];
         int fd;
-        ENTRY("empty directory readdir");
+        ENTER("empty directory readdir");
         snprintf(dir, MAX_PATH_LENGTH, "%s/test_t12_dir", lustre_path);
 
         t_mkdir(dir);
@@ -354,7 +349,7 @@ int t13(char *name)
         const int nfiles = 20;
         char *prefix = "test13_filename_prefix_";
         int fd, i;
-        ENTRY("multiple entries directory readdir");
+        ENTER("multiple entries directory readdir");
         snprintf(dir, MAX_PATH_LENGTH, "%s/test_t13_dir/", lustre_path);
 
         t_mkdir(dir);
@@ -385,7 +380,7 @@ int t14(char *name)
         struct dirent64 *ent;
         int fd, i, rc, pos, index;
         loff_t base = 0;
-        ENTRY(">1 block(4k) directory readdir");
+        ENTER(">1 block(4k) directory readdir");
         snprintf(dir, MAX_PATH_LENGTH, "%s/test_t14_dir/", lustre_path);
 
         rc = mkdir(dir, 0755);
@@ -442,7 +437,7 @@ int t15(char *name)
 {
         char file[MAX_PATH_LENGTH] = "";
         int fd;
-        ENTRY("open-stat-close");
+        ENTER("open-stat-close");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t15_file", lustre_path);
 
         t_touch(file);
@@ -456,7 +451,7 @@ int t15(char *name)
 int t16(char *name)
 {
         char file[MAX_PATH_LENGTH] = "";
-        ENTRY("small-write-read");
+        ENTER("small-write-read");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t16_file", lustre_path);
 
         t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaa");
@@ -469,7 +464,7 @@ int t17(char *name)
 {
         char file[MAX_PATH_LENGTH] = "";
         int fd;
-        ENTRY("open-unlink without close");
+        ENTER("open-unlink without close");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t17_file", lustre_path);
 
         fd = open(file, O_WRONLY | O_CREAT, 0666);
@@ -487,7 +482,7 @@ int t18(char *name)
         char buf[128];
         int fd, i;
         struct stat statbuf[3];
-        ENTRY("write should change mtime/ctime");
+        ENTER("write should change mtime/ctime");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t18_file", lustre_path);
 
         for (i = 0; i < 3; i++) {
@@ -526,7 +521,7 @@ int t18b(char *name)
         char file[MAX_PATH_LENGTH] = "";
         int i;
         struct stat statbuf[3];
-        ENTRY("utime should change mtime/atime/ctime");
+        ENTER("utime should change mtime/atime/ctime");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t18b_file", lustre_path);
         t_touch(file);
 
@@ -554,7 +549,7 @@ int t18b(char *name)
         LEAVE();
 }
 
-static int check_file_size(char *file, off_t size)
+static int check_file_size(char *file, long long size)
 {
         struct stat statbuf;
 
@@ -574,7 +569,7 @@ int t19(char *name)
         char file[MAX_PATH_LENGTH] = "";
         int fd;
         int result;
-        ENTRY("open(O_TRUNC) should truncate file to 0-length");
+        ENTER("open(O_TRUNC) should truncate file to 0-length");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t19_file", lustre_path);
 
         t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
@@ -599,7 +594,7 @@ int t20(char *name)
         struct iovec iov[2];
         char buf[100];
         ssize_t ret;
-        ENTRY("trap app's general bad pointer for file i/o");
+        ENTER("trap app's general bad pointer for file i/o");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t20_file", lustre_path);
 
         fd = open(file, O_RDWR|O_CREAT, (mode_t)0666);
@@ -681,7 +676,7 @@ int t21(char *name)
                 .l_whence = SEEK_SET,
         };
 
-        ENTRY("basic fcntl support");
+        ENTER("basic fcntl support");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t21_file", lustre_path);
 
         fd = open(file, O_RDWR|O_CREAT, (mode_t)0666);
@@ -716,7 +711,7 @@ int t22(char *name)
         char *str = "1234567890";
         char buf[100];
         ssize_t ret;
-        ENTRY("make sure O_APPEND take effect");
+        ENTER("make sure O_APPEND take effect");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t22_file", lustre_path);
 
         fd = open(file, O_RDWR|O_CREAT|O_APPEND, (mode_t)0666);
@@ -778,9 +773,9 @@ int t23(char *name)
         char path[MAX_PATH_LENGTH];
         int fd;
         long long ret;
-        loff_t off;
+        long long off;
 
-        ENTRY("handle seek > 2GB");
+        ENTER("handle seek > 2GB");
         snprintf(path, MAX_PATH_LENGTH, "%s/f%s", lustre_path, name);
 
         fd = open(path, O_WRONLY | O_CREAT | O_LARGEFILE, 0666);
@@ -970,7 +965,7 @@ int t50(char *name)
         int np = 1;
         loff_t offset = 0;
 
-        ENTRY("4k aligned i/o sanity");
+        ENTER("4k aligned i/o sanity");
         while (np <= _npages) {
                 printf("%3d per xfer(total %d)...\t", np, _npages);
                 fflush(stdout);
@@ -986,9 +981,9 @@ int t50b(char *name)
         loff_t off_array[] = {1, 17, 255, 258, 4095, 4097, 8191,
                               1024*1024*1024*1024ULL};
         int i;
-        loff_t offset;
+        long long offset;
 
-        ENTRY("4k un-aligned i/o sanity");
+        ENTER("4k un-aligned i/o sanity");
         for (i = 0; i < sizeof(off_array)/sizeof(loff_t); i++) {
                 offset = off_array[i];
                 printf("16 per xfer(total %d), offset %10lld...\t",
@@ -1012,10 +1007,10 @@ int t51(char *name)
 {
         char file[MAX_PATH_LENGTH] = "";
         int fd;
-        off_t size;
+        long long size;
         int result;
 
-        ENTRY("truncate() should truncate file to proper length");
+        ENTER("truncate() should truncate file to proper length");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t51_file", lustre_path);
 
         for (size = 0; size < T51_NR * T51_STEP; size += T51_STEP) {
@@ -1064,7 +1059,7 @@ int t52(char *name)
         time_t diff;
         int fd, i;
 
-        ENTRY("atime should be updated during read");
+        ENTER("atime should be updated during read");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t52_file", lustre_path);
 
         t_echo_create(file, "check atime update during read");
@@ -1103,7 +1098,7 @@ int t53(char *name)
         struct stat stat_buf;   /* struct buffer to hold file info. */
         time_t mtime, atime;
  
-        ENTRY("mtime/atime should be updated by utime() call");
+        ENTER("mtime/atime should be updated by utime() call");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t53_file", lustre_path);
 
         t_echo_create(file, "check mtime/atime update by utime() call");
@@ -1140,7 +1135,7 @@ int t54(char *name)
         struct flock lock;
         int fd, err;
 
-        ENTRY("fcntl should return 0 when succeed in getting flock");
+        ENTER("fcntl should return 0 when succeed in getting flock");
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t54_file", lustre_path);
 
         t_echo_create(file, "fcntl should return 0 when succeed");
@@ -1170,7 +1165,9 @@ int t54(char *name)
 }
 
 /* for O_DIRECTORY */
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #define STRIPE_SIZE       (2048 * 2048)
 #define STRIPE_OFFSET           0
@@ -1183,7 +1180,7 @@ int t55(char *name)
         struct lov_user_ost_data *lo = NULL;
         int index, fd, buflen, rc;
 
-        ENTRY("setstripe/getstripe");
+        ENTER("setstripe/getstripe");
         snprintf(path, MAX_PATH_LENGTH, "%s/test_t55", lustre_path);
         snprintf(file, MAX_PATH_LENGTH, "%s/test_t55/file_t55", lustre_path);
       
@@ -1346,7 +1343,7 @@ int t56(char *name)
         ssize_t rc = 0;
         struct dirent dir;
 
-        ENTRY("getdirentries should fail if nbytes is too small");
+        ENTER("getdirentries should fail if nbytes is too small");
 
         /* Set count to be very small.  The result should be EINVAL */
         nbytes = 8;
@@ -1357,12 +1354,12 @@ int t56(char *name)
         rc = getdirentries(fd, (char *)&dir, nbytes, &basep);
 
         if (rc != -1) {
-                printf("Test failed: getdirentries returned %d\n", rc);
+                printf("Test failed: getdirentries returned %ld\n", rc);
                 t_close(fd);
                 return -1;
         }
         if (errno != EINVAL) {
-                printf("Test failed: getdirentries returned %d but errno is set"
+                printf("Test failed: getdirentries returned %ld but errno is set"
                                 " to %d (should be EINVAL)\n", rc, errno);
                 t_close(fd);
                 return -1;
@@ -1372,7 +1369,6 @@ int t56(char *name)
         LEAVE();
 }
 
-
 extern void __liblustre_setup_(void);
 extern void __liblustre_cleanup_(void);