/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Lustre Light user test program
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * This file is part of Lustre, http://www.lustre.org.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/liblustre/tests/sanity.c
+ *
+ * Lustre Light user test program
*/
#define _BSD_SOURCE
do { \
char buf[100]; \
int len; \
- sprintf(buf, "===== START %s: %s ", __FUNCTION__, (str)); \
+ gettimeofday(&start, NULL); \
+ sprintf(buf, "===== START %s: %s %ld", __FUNCTION__, \
+ (str), (long)start.tv_sec); \
len = strlen(buf); \
if (len < 79) { \
memset(buf+len, '=', 100-len); \
buf[80] = 0; \
} \
printf("%s", buf); \
- gettimeofday(&start, NULL); \
} while (0)
#define LEAVE() \
{
char path[MAX_PATH_LENGTH] = "";
+ ENTER("touch+unlink");
snprintf(path, MAX_PATH_LENGTH, "%s/test_t1", lustre_path);
if (opt_verbose)
return(1);
}
if (statbuf.st_size != size) {
- printf("size of %s: %ld != %lld\n", file, statbuf.st_size, size);
+ printf("size of %s: %lld != %lld\n", file,
+ (long long)statbuf.st_size, size);
return(-1);
}
return 0;
ret = write(fd, NULL, 20);
if (ret != -1 || errno != EFAULT) {
- printf("write 1: ret %ld, errno %d\n", ret, errno);
+ printf("write 1: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
ret = write(fd, (void *)-1, 20);
if (ret != -1 || errno != EFAULT) {
- printf("write 2: ret %ld, errno %d\n", ret, errno);
+ printf("write 2: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
iov[0].iov_base = NULL;
iov[1].iov_len = 10;
ret = writev(fd, iov, 2);
if (ret != -1 || errno != EFAULT) {
- printf("writev 1: ret %ld, errno %d\n", ret, errno);
+ printf("writev 1: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
iov[0].iov_base = NULL;
iov[1].iov_len = sizeof(buf);
ret = writev(fd, iov, 2);
if (ret != sizeof(buf)) {
- printf("write 3 ret %ld, error %d\n", ret, errno);
+ printf("writev 2: ret %lld, error %d\n", (long long)ret, errno);
return(1);
}
lseek(fd, 0, SEEK_SET);
ret = read(fd, NULL, 20);
if (ret != -1 || errno != EFAULT) {
- printf("read 1: ret %ld, errno %d\n", ret, errno);
+ printf("read 1: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
ret = read(fd, (void *)-1, 20);
if (ret != -1 || errno != EFAULT) {
- printf("read 2: ret %ld, errno %d\n", ret, errno);
+ printf("read 2: ret %lld, error %d\n", (long long)ret, errno);
return(1);
}
iov[0].iov_base = NULL;
iov[1].iov_len = 10;
ret = readv(fd, iov, 2);
if (ret != -1 || errno != EFAULT) {
- printf("readv 1: ret %ld, errno %d\n", ret, errno);
+ printf("readv 1: ret %lld, error %d\n", (long long)ret, errno);
return(1);
}
iov[0].iov_base = NULL;
iov[1].iov_len = sizeof(buf);
ret = readv(fd, iov, 2);
if (ret != sizeof(buf)) {
- printf("read 3 ret %ld, error %d\n", ret, errno);
+ printf("readv 2: ret %lld, error %d\n", (long long)ret, errno);
return(1);
}
lseek(fd, 100, SEEK_SET);
ret = write(fd, str, strlen(str));
if (ret != strlen(str)) {
- printf("write 1: ret %ld, errno %d\n", ret, errno);
+ printf("write 1: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
lseek(fd, 0, SEEK_SET);
ret = read(fd, buf, sizeof(buf));
if (ret != strlen(str)) {
- printf("read 1 got %ld\n", ret);
+ printf("read 1: ret %lld\n", (long long)ret);
return(1);
}
lseek(fd, 100, SEEK_SET);
ret = write(fd, str, strlen(str));
if (ret != strlen(str)) {
- printf("write 2: ret %ld, errno %d\n", ret, errno);
+ printf("write 2: ret %lld, errno %d\n", (long long)ret, errno);
return(1);
}
lseek(fd, 100, SEEK_SET);
ret = read(fd, buf, sizeof(buf));
if (ret != strlen(str)) {
- printf("read 2 got %ld\n", ret);
+ printf("read 2: ret %lld\n", (long long)ret);
return(1);
}
close(fd);
t_unlink(file);
return -1;
- }
- atime = statbuf.st_atime;
+ }
+ atime = statbuf.st_atime;
}
close(fd);
t_unlink(file);
struct utimbuf times; /* struct. buffer for utime() */
struct stat stat_buf; /* struct buffer to hold file info. */
time_t mtime, atime;
-
+
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");
-
+
/* Initialize the modification and access time in the times arg */
times.actime = NEW_TIME+10;
times.modtime = NEW_TIME;
-
+
/* file modification/access time */
utime(file, ×);
-
+
if (stat(file, &stat_buf) < 0) {
printf("stat(2) of %s failed, error:%d %s\n",
- file, errno, strerror(errno));
+ file, errno, strerror(errno));
}
mtime = stat_buf.st_mtime;
atime = stat_buf.st_atime;
-
+
if ((mtime == NEW_TIME) && (atime == NEW_TIME + 10)) {
t_unlink(file);
LEAVE();
printf("mod time %ld, expected %ld\n", mtime, (long)NEW_TIME);
printf("acc time %ld, expected %ld\n", atime, (long)NEW_TIME + 10);
-
+
t_unlink(file);
return (-1);
}
lock.l_whence = 0;
lock.l_len = 1;
if ((err = t_fcntl(fd, F_SETLKW, &lock)) != 0) {
- fprintf(stderr, "fcntl returned: %d (%s)\n",
+ fprintf(stderr, "fcntl returned: %d (%s)\n",
err, strerror(err));
close(fd);
t_unlink(file);
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);
-
+
buflen = sizeof(struct lov_user_md);
buflen += STRIPE_COUNT * sizeof(struct lov_user_ost_data);
lum = (struct lov_user_md *)malloc(buflen);
free(lum);
return -1;
}
-
+
lum->lmm_magic = LOV_USER_MAGIC;
lum->lmm_stripe_count = STRIPE_COUNT;
rc = ioctl(fd, LL_IOC_LOV_GETSTRIPE, lum);
printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count);
printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size);
printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern);
-
+
for (index = 0; index < lum->lmm_stripe_count; index++) {
lo = lum->lmm_objects + index;
printf("object %d:\n", index);
}
fd = open(file, O_RDWR, 0644);
if (fd < 0) {
- printf("failed to open(%s): rc = %d (%s)\n",
+ printf("failed to open(%s): rc = %d (%s)\n",
file, fd, strerror(errno));
t_unlink(file);
t_rmdir(path);
printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count);
printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size);
printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern);
-
+
for (index = 0; index < lum->lmm_stripe_count; index++) {
lo = lum->lmm_objects + index;
printf("object %d:\n", index);
rc = getdirentries(fd, (char *)&dir, nbytes, &basep);
if (rc != -1) {
- printf("Test failed: getdirentries returned %ld\n", rc);
+ printf("Test failed: getdirentries returned %lld\n",
+ (long long)rc);
t_close(fd);
return -1;
}
if (errno != EINVAL) {
- printf("Test failed: getdirentries returned %ld but errno is set"
- " to %d (should be EINVAL)\n", rc, errno);
+ printf("Test failed: getdirentries returned %lld but errno is "
+ "set to %d (should be EINVAL)\n", (long long)rc, errno);
t_close(fd);
return -1;
}
void usage(char *cmd)
{
printf("\n"
- "usage: %s [--only {test}] --target mgsnid:/fsname\n",
- cmd);
+ "usage: %s [-o test][-e test][-v] --target mgsnid:/fsname\n",
+ cmd);
printf(" %s --dumpfile dumpfile\n", cmd);
exit(-1);
}
int main(int argc, char * const argv[])
{
struct testlist *test;
- int opt_index, c, rc = 0, numonly = 0;
- char *only[100];
+ int opt_index, c, rc = 0, numonly = 0, numexcept = 0;
+ char *only[100], *except[100];
static struct option long_opts[] = {
{"dumpfile", 1, 0, 'd'},
{"only", 1, 0, 'o'},
+ {"except", 1, 0, 'e'},
{"target", 1, 0, 't'},
{"verbose", 1, 0, 'v'},
{0, 0, 0, 0}
};
- while ((c = getopt_long(argc, argv, "d:o:t:v", long_opts, &opt_index)) != -1) {
+ while ((c = getopt_long(argc, argv, "d:e:o:t:v", long_opts, &opt_index)) != -1) {
switch (c) {
case 'd':
setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
break;
+ case 'e':
+ if (numexcept == 0)
+ printf("Not running test(s): ");
+ printf("%s ", optarg);
+ except[numexcept++] = optarg;
+ break;
case 'o':
if (numonly == 0)
printf("Only running test(s): ");
for (test = testlist; test->test != NULL; test++) {
int run = 1, i;
+ int len, olen;
- if (numonly > 0) {
- int len;
+ if (numexcept > 0) {
+ len = strlen(test->name);
+ for (i = 0; i < numexcept; i++) {
+ olen = strlen(except[i]);
+ if (len < olen)
+ continue;
+
+ if (strncmp(except[i], test->name, olen) == 0) {
+ switch(test->name[olen]) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ break;
+ default:
+ run = 0;
+ break;
+ }
+ }
+ }
+ }
+
+ if (numonly > 0) {
run = 0;
len = strlen(test->name);
for (i = 0; i < numonly; i++) {
- int olen = strlen(only[i]);
+ olen = strlen(only[i]);
if (len < olen)
continue;