1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light user test program
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <sys/types.h>
34 #include <sys/queue.h>
40 #include "test_common.h"
47 {"MDS_REQUEST", 0x123},
52 static int drop_index = 0;
54 static char mds_server[1024] = {0, };
56 int do_stat(const char *name, struct stat *buf)
61 rc = lstat(name, &stat);
63 printf("error %d stat %s\n", rc, name);
67 memcpy(buf, &stat, sizeof(*buf));
72 void prepare_reg(const char *path)
76 fd = open(path, O_RDWR|O_CREAT, 00644);
78 printf("error %d create %s\n", fd, path);
84 printf("error %d close %s\n", rc, path);
89 void cleanup_reg(const char *path)
95 printf("error %d unlink %s\n", rc, path);
100 void prepare_dir(const char *path)
104 rc = mkdir(path, 00644);
106 printf("error %d mkdir %s\n", rc, path);
111 void cleanup_dir(const char *path)
117 printf("error %d unlink %s\n", rc, path);
127 if (drop_arr[drop_index].name) { \
128 printf("server drops next %s\n", drop_arr[drop_index].name); \
130 "ssh %s \"echo %lu > /proc/sys/lustre/fail_loc\"", \
131 mds_server, drop_arr[drop_index].code); \
133 printf("error excuting remote command: %d\n", rc); \
143 if (drop_arr[drop_index].name) { \
144 sprintf(cmd, "ssh %s \"echo 0 > /proc/sys/lustre/fail_loc\"", \
154 sprintf(buf, "===== START: %s ", (str)); \
157 memset(buf+len, '=', 100-len); \
166 printf("----- END TEST successfully ---"); \
167 printf("-----------------------------"); \
168 printf("-------------------\n"); \
174 char *path="/mnt/lustre/test_t1";
175 ENTRY("create/delete");
188 char *path="/mnt/lustre/test_t2";
189 ENTRY("mkdir/rmdir");
202 char *path="/mnt/lustre/test_t3";
203 ENTRY("regular stat");
207 t_check_stat(path, NULL);
215 char *path="/mnt/lustre/test_t4";
220 t_check_stat(path, NULL);
228 char *path="/mnt/lustre/test_t5";
229 const int bufsize = 4096;
230 char wbuf[bufsize], rbuf[bufsize];
233 ENTRY("sequential page aligned file I/O");
239 for (i = 0; i < npages; i++ ) {
240 memset(wbuf, i, bufsize);
241 rc = write(fd, wbuf, bufsize);
243 printf("write error %d (i = %d)\n", rc, i);
247 printf("succefully write %d pages\n", npages);
249 lseek(fd, 0, SEEK_SET);
251 for (i = 0; i < npages; i++ ) {
252 memset(rbuf, 0, bufsize);
253 rc = read(fd, rbuf, bufsize);
255 printf("read error %d (i = %d)\n", rc, i);
259 printf("succefully read & verified %d pages\n", npages);
269 char *path="/mnt/lustre/test_t6";
270 char *path2="/mnt/lustre/test_t6_link";
275 t_symlink(path, path2);
277 t_check_stat(path2, NULL);
285 char *path="/mnt/lustre/test_t7";
289 t_mknod(path, S_IFCHR | 0644, 5, 4);
291 t_check_stat(path, NULL);
296 extern int portal_debug;
297 extern int portal_subsystem_debug;
299 extern void __liblustre_setup_(void);
300 extern void __liblustre_cleanup_(void);
302 void usage(const char *cmd)
304 printf("Usage: \t%s -s mds_hostname --target mdsnid:/mdsname/profile\n", cmd);
305 printf(" \t%s -s mds_hostname --dumpfile dumpfile\n", cmd);
309 int main(int argc, char * argv[])
313 static struct option long_opts[] = {
315 {"dumpfile", 1, 0, 0},
322 while ((c = getopt_long(argc, argv, "s:", long_opts, &opt_index)) != -1) {
328 if (!strcmp(long_opts[opt_index].name, "target")) {
329 setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
330 } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
331 setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
337 strcpy(mds_server, optarg);
347 if (strlen(mds_server) == 0)
350 sprintf(cmd, "ssh %s cat /dev/null", mds_server);
352 printf("can't access server node: %s\n", mds_server);
356 setenv(ENV_LUSTRE_TIMEOUT, "10", 1);
358 __liblustre_setup_();
360 while (drop_arr[drop_index].name) {
372 printf("liblustre is about shutdown\n");
373 __liblustre_cleanup_();
375 printf("complete successfully\n");