#include <sysio.h>
#include <mount.h>
+#include "test_common.h"
static struct {
const char *name;
static int drop_index = 0;
-char mds_server[1024];
+static char mds_server[1024];
int do_stat(const char *name, struct stat *buf)
{
} \
} while (0)
-#define ENTRY(str) \
- do { \
- printf("+++++ start test (%s) +++++\n", (str)); \
- } while (0)
+#define ENTRY(str) \
+ do { \
+ char buf[100]; \
+ int len; \
+ sprintf(buf, "===== START: %s ", (str)); \
+ len = strlen(buf); \
+ if (len < 79) { \
+ memset(buf+len, '=', 100-len); \
+ buf[79] = '\n'; \
+ buf[80] = 0; \
+ } \
+ printf("%s", buf); \
+ } while (0)
+
+#define LEAVE() \
+ do { \
+ printf("----- END TEST successfully ---"); \
+ printf("-----------------------------"); \
+ printf("-------------------\n"); \
+ } while (0)
-#define LEAVE() \
- do { \
- printf("----- end test successfully -----\n"); \
- } while (0)
void t1()
{
ENTRY("create/delete");
FAIL();
- prepare_reg(path);
+ t_touch(path);
RECOVER();
FAIL();
- cleanup_reg(path);
+ t_unlink(path);
RECOVER();
LEAVE();
}
ENTRY("mkdir/rmdir");
FAIL();
- prepare_dir(path);
+ t_mkdir(path);
RECOVER();
FAIL();
- cleanup_dir(path);
+ t_rmdir(path);
RECOVER();
LEAVE();
}
char *path="/mnt/lustre/test_t3";
ENTRY("regular stat");
- prepare_reg(path);
+ t_touch(path);
FAIL();
- do_stat(path, NULL);
+ t_check_stat(path, NULL);
RECOVER();
- cleanup_reg(path);
+ t_unlink(path);
LEAVE();
}
char *path="/mnt/lustre/test_t4";
ENTRY("dir stat");
- prepare_dir(path);
+ t_mkdir(path);
FAIL();
- do_stat(path, NULL);
+ t_check_stat(path, NULL);
RECOVER();
- cleanup_dir(path);
+ t_rmdir(path);
LEAVE();
}
int fd, rc, i;
ENTRY("sequential page aligned file I/O");
- prepare_reg(path);
+ t_touch(path);
- fd = open(path, O_RDWR, 00664);
- if (fd < 0) {
- printf("error %d open %s\n", fd, path);
- exit(1);
- }
+ fd = t_open(path);
for (i = 0; i < npages; i++ ) {
memset(wbuf, i, bufsize);
}
printf("succefully read & verified %d pages\n", npages);
- rc = close(fd);
- if (rc) {
- printf("close() err %d\n", rc);
- exit(1);
- }
+ t_close(fd);
- cleanup_reg(path);
+ t_unlink(path);
LEAVE();
}
{
char *path="/mnt/lustre/test_t6";
char *path2="/mnt/lustre/test_t6_link";
- int rc;
ENTRY("symlink");
- prepare_reg(path);
+ t_touch(path);
FAIL();
- rc = symlink(path, path2);
- if (rc) {
- printf("error %d symlink %s -< %s\n", rc, path, path2);
- exit(1);
- }
+ t_symlink(path, path2);
RECOVER();
- do_stat(path2, NULL);
- rc = unlink(path2);
- if (rc) {
- printf("error %d sym unlink %s\n", rc, path2);
- exit(1);
- }
- cleanup_reg(path);
+ t_check_stat(path2, NULL);
+ t_unlink(path2);
+ t_unlink(path);
LEAVE();
}
void t7()
{
char *path="/mnt/lustre/test_t7";
- int rc;
ENTRY("mknod");
-#define MKDEV(a,b) (((a) << 8) | (b))
-
FAIL();
- rc = mknod(path, S_IFCHR | 0644, MKDEV(5, 4));
- if (rc < 0) {
- printf("error %d mknod %s\n", rc, path);
- exit(1);
- }
+ t_mknod(path, S_IFCHR | 0644, 5, 4);
RECOVER();
- do_stat(path, NULL);
- rc = unlink(path);
- if (rc) {
- printf("error %d node unlink %s\n", rc, path);
- exit(1);
- }
+ t_check_stat(path, NULL);
+ t_unlink(path);
LEAVE();
}
#include <sysio.h>
#include <mount.h>
-extern errno;
+#include "test_common.h"
}
}
-/******************************************************************
- * util functions
- ******************************************************************/
-static void touch(const char *filename)
-{
- int fd, rc;
-
- fd = open(filename, O_RDWR|O_CREAT, 0644);
- if (fd < 0) {
- printf("open(%s) error: %s\n", filename, strerror(errno));
- exit(1);
- }
-
- rc = close(fd);
- if (rc) {
- printf("close(%s) error: %s\n", filename, strerror(errno));
- exit(1);
- }
-}
-
-/* XXX Now libsysio don't support mcreate */
-static void mcreate(const char *filename)
-{
- return touch(filename);
-#if 0
- int rc;
-
- rc = mknod(filename, S_IFREG | 0644, 0);
- if (rc) {
- printf("mknod(%s) error: %s\n", filename, strerror(errno));
- exit(-1);
- }
-#endif
-}
-
-static void munlink(const char *filename)
-{
- int rc;
-
- rc = unlink(filename);
- if (rc) {
- printf("unlink(%s) error: %s\n", filename, strerror(errno));
- exit(-1);
- }
-}
-
-static void mmkdir(const char *filename)
-{
- int rc;
-
- rc = mkdir(filename, 00644);
- if (rc < 0) {
- printf("mkdir(%s) error: %s\n", filename, strerror(errno));
- exit(1);
- }
-}
-
-static void mrmdir(const char *filename)
-{
- int rc;
-
- rc = rmdir(filename);
- if (rc) {
- printf("rmdir(%s) error: %s\n", filename, strerror(errno));
- exit(1);
- }
-}
-
-static int mopen(const char *filename)
-{
- int fd;
-
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
- printf("open(%s) error: %s\n", filename, strerror(errno));
- exit(1);
- }
- return fd;
-}
-
-static void mclose(int fd)
-{
- int rc;
-
- rc = close(fd);
- if (rc < 0) {
- printf("close(%d) error: %s\n", fd, strerror(errno));
- exit(1);
- }
-}
-
-static int check_stat(const char *name, struct stat *buf)
-{
- struct stat stat;
- int rc;
-
- rc = lstat(name, &stat);
- if (rc) {
- printf("error %d stat %s\n", rc, name);
- exit(1);
- }
- if (buf)
- memcpy(buf, &stat, sizeof(*buf));
-
- return 0;
-}
-
-
-
-#define ENTRY(str) \
- do { \
- printf("===== start test (%s) =====", (str)); \
- printf("===========================\n"); \
+#define ENTRY(str) \
+ do { \
+ char buf[100]; \
+ int len; \
+ sprintf(buf, "===== START: %s ", (str)); \
+ len = strlen(buf); \
+ if (len < 79) { \
+ memset(buf+len, '=', 100-len); \
+ buf[79] = '\n'; \
+ buf[80] = 0; \
+ } \
+ printf("%s", buf); \
} while (0)
-#define LEAVE() \
- do { \
- printf("--- end test successfully ---"); \
- printf("-----------------------------\n"); \
+#define LEAVE() \
+ do { \
+ printf("----- END TEST successfully ---"); \
+ printf("-----------------------------"); \
+ printf("-------------------\n"); \
} while (0)
void t1()
ENTRY("simple create");
replay_barrier();
- mcreate(path);
+ t_create(path);
mds_failover();
- check_stat(path, NULL);
- munlink(path);
+ t_check_stat(path, NULL);
+ t_unlink(path);
LEAVE();
}
ENTRY("touch");
replay_barrier();
- touch(path);
+ t_touch(path);
mds_failover();
- check_stat(path, NULL);
- munlink(path);
+ t_check_stat(path, NULL);
+ t_unlink(path);
LEAVE();
}
ENTRY("mkdir + contained create");
replay_barrier();
- mmkdir(dir);
- mcreate(path);
+ t_mkdir(dir);
+ t_create(path);
mds_failover();
- check_stat(dir, NULL);
- check_stat(path, NULL);
- munlink(path);
- mrmdir(dir);
+ t_check_stat(dir, NULL);
+ t_check_stat(path, NULL);
+ t_unlink(path);
+ t_rmdir(dir);
LEAVE();
}
char *path="/mnt/lustre/d3/f3";
ENTRY("mkdir |X| contained create");
- mmkdir(dir);
+ t_mkdir(dir);
replay_barrier();
- mcreate(path);
+ t_create(path);
mds_failover();
- check_stat(dir, NULL);
- check_stat(path, NULL);
- munlink(path);
- mrmdir(dir);
+ t_check_stat(dir, NULL);
+ t_check_stat(path, NULL);
+ t_unlink(path);
+ t_rmdir(dir);
LEAVE();
}
ENTRY("open |X| close");
replay_barrier();
- mcreate(path);
- fd = mopen(path);
+ t_create(path);
+ fd = t_open(path);
sleep(1);
mds_failover();
- check_stat(path, NULL);
- mclose(fd);
- munlink(path);
+ t_check_stat(path, NULL);
+ t_close(fd);
+ t_unlink(path);
}
extern int portal_debug;
__liblustre_setup_();
-#ifndef __CYGWIN__
t1();
t1a();
t2();
t3();
t4();
-#endif
printf("liblustre is about shutdown\n");
__liblustre_cleanup_();