From: ericm Date: Fri, 14 Nov 2003 11:13:26 +0000 (+0000) Subject: liblustre: X-Git-Tag: v1_7_0_51~2^7~247 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7502d9fe7282287e540274895ebb93a970f07cc8;p=fs%2Flustre-release.git liblustre: add more test items into replay_single. --- diff --git a/lustre/liblustre/replay_single.c b/lustre/liblustre/replay_single.c index 267e838..e9537d4 100755 --- a/lustre/liblustre/replay_single.c +++ b/lustre/liblustre/replay_single.c @@ -112,7 +112,7 @@ void t1() void t2a() { - char *path="/mnt/lustre/f1a"; + char *path="/mnt/lustre/f2a"; ENTRY("touch"); replay_barrier(); @@ -125,7 +125,7 @@ void t2a() void t2b() { - char *path="/mnt/lustre/f1a"; + char *path="/mnt/lustre/f2b"; ENTRY("mcreate+touch"); t_create(path); @@ -138,51 +138,56 @@ void t2b() } -void t3() +void n_create_delete(int nfiles) { char *base="/mnt/lustre/f3_"; char path[100]; char str[100]; - char buf[100]; int i; - ENTRY("10 create/delete"); replay_barrier(); - for (i = 0; i < 10; i++) { + for (i = 0; i < nfiles; i++) { sprintf(path, "%s%d\n", base, i); sprintf(str, "TEST#%d CONTENT\n", i); t_echo_create(path, str); } mds_failover(); - for (i = 0; i < 10; i++) { + for (i = 0; i < nfiles; i++) { sprintf(path, "%s%d\n", base, i); sprintf(str, "TEST#%d CONTENT\n", i); - t_pread_once(path, buf, 100, 0); - if (!strstr(buf, str)) { - printf("f%d: content error !\n", i); - exit(-1); - } + t_grep(path, str); } replay_barrier(); - for (i = 0; i < 10; i++) { + for (i = 0; i < nfiles; i++) { sprintf(path, "%s%d\n", base, i); t_unlink(path); } mds_failover(); - for (i = 0; i < 10; i++) { + for (i = 0; i < nfiles; i++) { sprintf(path, "%s%d\n", base, i); - if (!stat(path, NULL)) { - printf("f%d still exist!\n", i); - exit(-1); - } + t_check_stat_fail(path); } LEAVE(); } +void t3a() +{ + ENTRY("10 create/delete"); + n_create_delete(10); + LEAVE(); +} + +void t3b() +{ + ENTRY("60 create/delete(>1'st block precreated)"); + n_create_delete(60); + LEAVE(); +} + void t4() { - char *dir="/mnt/lustre/d2"; - char *path="/mnt/lustre/d2/f2"; + char *dir="/mnt/lustre/d4"; + char *path="/mnt/lustre/d4/f1"; ENTRY("mkdir + contained create"); replay_barrier(); @@ -191,15 +196,21 @@ void t4() mds_failover(); t_check_stat(dir, NULL); t_check_stat(path, NULL); + sleep(2); /* wait for log process thread */ + + replay_barrier(); t_unlink(path); t_rmdir(dir); + mds_failover(); + t_check_stat_fail(dir); + t_check_stat_fail(path); LEAVE(); } void t5() { - char *dir="/mnt/lustre/d3"; - char *path="/mnt/lustre/d3/f3"; + char *dir="/mnt/lustre/d5"; + char *path="/mnt/lustre/d5/f1"; ENTRY("mkdir |X| contained create"); t_mkdir(dir); @@ -215,7 +226,7 @@ void t5() void t6() { - char *path="/mnt/lustre/f4"; + char *path="/mnt/lustre/f6"; int fd; ENTRY("open |X| close"); @@ -227,6 +238,72 @@ void t6() t_check_stat(path, NULL); t_close(fd); t_unlink(path); + LEAVE(); +} + +void t7() +{ + char *path="/mnt/lustre/f7"; + char *path2="/mnt/lustre/f7-2"; + ENTRY("create |X| rename unlink"); + + t_create(path); + replay_barrier(); + t_rename(path, path2); + mds_failover(); + t_check_stat_fail(path); + t_check_stat(path2, NULL); + t_unlink(path2); +} + +void t8() +{ + char *path="/mnt/lustre/f8"; + char *path2="/mnt/lustre/f8-2"; + ENTRY("create open write rename |X| create-old-name read"); + + t_create(path); + t_echo_create(path, "old"); + t_rename(path, path2); + replay_barrier(); + t_echo_create(path, "new"); + mds_failover(); + t_grep(path, "new"); + t_grep(path2, "old"); + t_unlink(path); + t_unlink(path2); +} + +void t9() +{ + char *path="/mnt/lustre/f9"; + char *path2="/mnt/lustre/f9-2"; + ENTRY("|X| open(O_CREAT), unlink, touch new, unlink new"); + + replay_barrier(); + t_create(path); + t_unlink(path); + t_create(path2); + mds_failover(); + t_check_stat_fail(path); + t_check_stat(path2, NULL); + t_unlink(path2); +} + +void t10() +{ + char *path="/mnt/lustre/f10"; + char *path2="/mnt/lustre/f10-2"; + ENTRY("|X| mcreate, open write, rename"); + + replay_barrier(); + t_create(path); + t_echo_create(path, "old"); + t_rename(path, path2); + t_grep(path2, "old"); + mds_failover(); + t_grep(path2, "old"); + t_unlink(path2); } extern int portal_debug; @@ -313,10 +390,15 @@ int main(int argc, char * const argv[]) t1(); t2a(); t2b(); - t3(); + t3a(); + t3b(); t4(); t5(); t6(); + t7(); + t8(); + t9(); + t10(); printf("liblustre is about shutdown\n"); __liblustre_cleanup_(); diff --git a/lustre/liblustre/test_common.c b/lustre/liblustre/test_common.c index 21f088d..210d57e 100644 --- a/lustre/liblustre/test_common.c +++ b/lustre/liblustre/test_common.c @@ -207,6 +207,20 @@ int t_check_stat(const char *name, struct stat *buf) return 0; } +int t_check_stat_fail(const char *name) +{ + struct stat stat; + int rc; + + rc = lstat(name, &stat); + if (!rc) { + printf("%s still exists\n", name); + EXIT(-1); + } + + return 0; +} + void t_echo_create(const char *path, const char *str) { int fd, rc; @@ -229,21 +243,38 @@ 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, int should_contain) { + char buf[1024]; int fd; int rc; - memset(buf, 0, size); - fd = t_open_readonly(path); - if (lseek(fd, offset, SEEK_SET) == -1) { - printf("pread_once: seek to %lu error: %s\n", - offset, strerror(errno)); + if (lseek(fd, 0, SEEK_SET) == -1) { + printf("pread_once: seek to 0 error: %s\n", strerror(errno)); EXIT(fd); } - rc = read(fd, buf, size); + rc = read(fd, buf, 1023); + if (rc < 0) { + printf("grep: read error: %s\n", strerror(errno)); + EXIT(-1); + } close(fd); - return rc; + buf[rc] = 0; + + if ((strstr(buf, str) != 0) ^ should_contain) { + printf("grep: can't find string %s\n", str); + EXIT(-1); + } +} + +void t_grep(const char *path, char *str) +{ + _t_grep(path, str, 1); +} + +void t_grep_v(const char *path, char *str) +{ + _t_grep(path, str, 0); } diff --git a/lustre/liblustre/test_common.h b/lustre/liblustre/test_common.h index aee0552..af638f2 100644 --- a/lustre/liblustre/test_common.h +++ b/lustre/liblustre/test_common.h @@ -22,7 +22,10 @@ int t_open_readonly(const char *path); int t_open(const char *path); 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); +//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); #endif