Whamcloud - gitweb
liblustre:
authorericm <ericm>
Wed, 17 Dec 2003 14:04:15 +0000 (14:04 +0000)
committerericm <ericm>
Wed, 17 Dec 2003 14:04:15 +0000 (14:04 +0000)
  add sanity test for readdir, but one test still fail, need to be fixed
  tomorrow.

lustre/liblustre/tests/sanity.c
lustre/liblustre/tests/test_common.c
lustre/liblustre/tests/test_common.h

index 62af498..8b855fc 100644 (file)
@@ -280,7 +280,7 @@ void t10()
         LEAVE();
 }
 
-void t100()
+void t11()
 {
         char *base="/mnt/lustre";
         char path[4096], path2[4096];
@@ -316,6 +316,58 @@ void t100()
         LEAVE();
 }
 
+void t12()
+{
+        char *dir="/mnt/lustre/test_t11_dir";
+        char *file1="/mnt/lustre/test_t11_dir/file1";
+        char *file2="/mnt/lustre/test_t11_dir/file2";
+        char *file3="/mnt/lustre/test_t11_dir/file3";
+        char buf[1024*128];
+        int fd;
+        ENTRY("simple readdir");
+
+        t_mkdir(dir);
+        t_touch(file1);
+        t_touch(file2);
+        t_touch(file3);
+        fd = t_open(dir);
+        t_ls(fd, buf, sizeof(buf));
+        t_close(fd);
+        t_unlink(file1);
+        t_unlink(file2);
+        t_unlink(file3);
+        t_rmdir(dir);
+        LEAVE();
+}
+
+void t13()
+{
+        char *dir="/mnt/lustre/test_t12_dir/";
+        char name[1024];
+        char buf[1024*4];
+        const int nfiles = 300;
+        char *prefix = "test12_file_name_prefix_PPPPPPPPPP___";
+        int fd, i;
+        ENTRY("large directory readdir");
+
+        t_mkdir(dir);
+        printf("Creating %d files...\n", nfiles);
+        for (i = 0; i < nfiles; i++) {
+                sprintf(name, "%s%s%05d", dir, prefix, i);
+                t_touch(name);
+        }
+        fd = t_open(dir);
+        t_ls(fd, buf, sizeof(buf));
+        t_close(fd);
+        printf("Cleanup...\n");
+        for (i = 0; i < nfiles; i++) {
+                sprintf(name, "%s%s%05d", dir, prefix, i);
+                t_unlink(name);
+        }
+        t_rmdir(dir);
+        LEAVE();
+}
+
 extern void __liblustre_setup_(void);
 extern void __liblustre_cleanup_(void);
 
@@ -374,8 +426,11 @@ int main(int argc, char * const argv[])
         t8();
         t9();
         t10();
-
-        t100();
+        t11();
+        t12();
+/*
+        t13();
+*/
 #endif
 
        printf("liblustre is about shutdown\n");
index 210d57e..c5c6e45 100644 (file)
@@ -6,6 +6,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <dirent.h>
 
 #include "test_common.h"
 
@@ -278,3 +279,25 @@ void t_grep_v(const char *path, char *str)
 {
        _t_grep(path, str, 0);
 }
+
+void t_ls(int fd, char *buf, int size)
+{
+       struct dirent *ent;
+       int rc, pos;
+       off_t base = 0;
+
+       printf("dir entries listing...\n");
+       while ((rc = getdirentries(fd, buf, size, &base)) > 0) {
+               pos = 0;
+               while (pos < rc) {
+                       ent = (struct dirent *) ((char*) buf + pos);
+                       printf("%s\n", ent->d_name);
+                       pos += ent->d_reclen;
+               }
+       }
+
+       if (rc < 0) {
+               printf("getdents error %d\n", rc);
+               EXIT(-1);
+       }
+}
index af638f2..91d9906 100644 (file)
@@ -24,8 +24,8 @@ void t_close(int fd);
 int t_check_stat(const char *name, struct stat *buf);
 int t_check_stat_fail(const char *name);
 void t_echo_create(const char *path, const char *str);
-//int t_pread_once(const char *path, char *buf, size_t size, off_t offset);
 void t_grep(const char *path, char *str);
 void t_grep_v(const char *path, char *str);
+void t_ls(int fd, char *buf, int size);
 
 #endif