Whamcloud - gitweb
Don't upload to maloo by default
[fs/lustre-release.git] / lustre / tests / lp_utils.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/tests/lp_utils.h
37  *
38  * Author: You Feng <youfeng@clusterfs.com>
39  */
40
41 #ifndef __LP_UTILS_H__
42 #define __LP_UTILS_H__
43
44 #include "lustre/lustre_user.h"
45
46 #define FAIL(msg) \
47  \
48 do { \
49         printf("%s: Process %d (%s)\n", timestamp(), rank, hostname); \
50         if (debug) \
51                 printf("\tFAILED in %s:%d:%s()\n", __FILE__, __LINE__, __func__); \
52         else \
53                 printf("\tFAILED in %s()\n", __func__); \
54         printf("%s", msg); \
55         fflush(stdout); \
56         MPI_Abort(MPI_COMM_WORLD, 1); \
57 } while(0)
58
59 #define FILEMODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH
60 #define MAX_FILENAME_LEN 512
61
62 extern int verbose;
63 extern int debug;
64
65 extern int rank;
66 extern int size;
67
68 extern char hostname[];
69 extern char *timestamp();
70 extern char *testdir;
71
72 extern inline void begin(char *str);
73 extern inline void end(char *str);
74
75 extern void dump_diff(char *orig_buf, char *buf, int len, long off);
76 extern void lp_gethostname(void);
77
78 extern void create_file(char *name, long filesize, int fill);
79 extern void fill_file(char *name, long filesize);
80
81 #define LP_STAT_FMT \
82  \
83 "Stat error:\n \
84 \tfields\t\tvalue\told value\n \
85 \tst_dev\t\t%d\t%d\n \
86 \tst_ino\t\t%d\t%d\n \
87 \tst_mode\t\t%o\t%o\n \
88 \tst_nlink\t%d\t%d\n \
89 \tst_uid\t\t%d\t%d\n \
90 \tst_gid\t\t%d\t%d\n \
91 \tst_rdev\t\t%x.%x\t%x.%x\n \
92 \tst_size\t\t%lu\t%lu\n \
93 \tst_blksize\t%d\t%d\n \
94 \tst_blocks\t%u\t%u\n \
95 \tst_atime\t%d\t%d\n \
96 \tst_mtime\t%d\t%d\n \
97 \tst_ctime\t%d\t%d\n"
98                                                                                 
99 #define LP_STAT_ARGS \
100  \
101 (int)state->st_dev, (int)old_state->st_dev, \
102 (int)state->st_ino, (int)old_state->st_ino, \
103 state->st_mode & 07777, old_state->st_mode & 07777, \
104 (int)state->st_nlink, (int)old_state->st_nlink, \
105 state->st_uid, old_state->st_uid, \
106 state->st_gid, old_state->st_gid, \
107 (int)((state->st_rdev >> 8) & 0xff), (int)(state->st_rdev & 0xff), \
108 (int)((old_state->st_rdev >> 8) & 0xff), (int)(old_state->st_rdev & 0xff), \
109 (unsigned long)state->st_size, (unsigned long)old_state->st_size, \
110 (int)state->st_blksize, (int)old_state->st_blksize, \
111 (unsigned int)state->st_blocks, (unsigned int)old_state->st_blocks, \
112 (int)state->st_atime, (int)old_state->st_atime, \
113 (int)state->st_mtime, (int)old_state->st_mtime, \
114 (int)state->st_ctime, (int)old_state->st_ctime
115
116 extern void check_stat(char *filename, struct stat *state, struct stat *old_state);
117 extern void remove_file(char *name);
118 extern void remove_file_or_dir(char *name);
119 extern void fill_stride(char *buf, int buf_size, long long rank, long long _off);
120
121 #endif /* __LP_UTILS_H__ */