• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Crackerjack Project
3  *
4  * Copyright (C) 2007-2008, Hitachi, Ltd.
5  * Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
6  *            Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
7  *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program 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.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22  *
23  * $Id: include_j_h.h,v 1.2 2009/09/27 17:34:22 subrata_modak Exp $
24  *
25  */
26 #ifndef __CJK_SYSCALL_J_H__
27 #define __CJK_SYSCALL_J_H__
28 
29 #include <sys/time.h>
30 #include <sys/resource.h>
31 
32 
33 #define REG_RESULT_LOG_FP	stdout
34 #define REG_DETAIL_LOG_FP	stderr
35 
36 
37 /*
38  * RPRINTF : macro to output test result
39  */
40 #define RPRINTF(...)						\
41 	do {							\
42 		fprintf(REG_RESULT_LOG_FP, __VA_ARGS__);	\
43 	} while (0)
44 
45 
46 /*
47  * PRINTF : macro to output detail log
48  */
49 #define PRINTF(...)						\
50 	do {							\
51 		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
52 	} while (0)
53 
54 
55 /*
56  * EPRINTF : macro to output error message
57  */
58 #define EPRINTF(...)						\
59 	do {							\
60 		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
61 	} while (0)
62 
63 /*
64  * PRINT_XXX : macro to output test result and expect
65  */
66 #define __PRINT_EXPECT(rc_has_range, rc, errno)				\
67 	do {								\
68 		if (rc_has_range)					\
69 			PRINTF("EXPECT: return value(ret)=%s",		\
70 			       (rc) >= 0 ? "(N >= 0)" : "(N <  0)");	\
71 		else							\
72 			PRINTF("EXPECT: return value(ret)=%d", rc);	\
73 		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
74 	} while (0)
75 
76 #define __PRINT_RESULT(rc_has_range, rc, errno)				\
77 	do {								\
78 		if (rc_has_range)					\
79 			PRINTF("RESULT: return value(ret)=%8d", rc);	\
80 		else							\
81 			PRINTF("RESULT: return value(ret)=%d", rc);	\
82 		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
83 	} while (0)
84 
85 #define PRINT_RESULT(rc_has_range, e_rc, e_errno, r_rc, r_errno)	\
86 	do {								\
87 		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
88 		PRINTF("\n");						\
89 		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
90 		PRINTF("\n");						\
91 	} while (0)
92 
93 #define PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
94 			   str, extra_ok)				\
95 	do {								\
96 		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
97 		if ((extra_ok))						\
98 			PRINTF("\n");					\
99 		else							\
100 			PRINTF(", %s=OK\n", str);			\
101 		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
102 		if ((extra_ok))						\
103 			PRINTF("\n");					\
104 		else							\
105 			PRINTF(", %s=NG\n", str);			\
106 	} while (0)
107 
108 #define PRINT_RESULT_CMP(rc_has_range, e_rc, e_errno, r_rc, r_errno, cmp_ok) \
109 	PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
110 			   "r/w check", cmp_ok)
111 
112 
113 /*
114  * Definitions
115  */
116 enum result_val {
117 	RESULT_OK,
118 	RESULT_NG
119 };
120 
121 
122 /*
123  * Prototype
124  */
125 int setup_uid(char *uname);
126 int setup_euid(char *uname, uid_t *old_uid);
127 int cleanup_euid(uid_t old_uid);
128 
129 pid_t create_sig_proc(unsigned long usec, int sig, unsigned count);
130 
131 int _setup_file(char *testdir, char *fname, char *path, int flags, mode_t mode);
132 int setup_file(char *testdir, char *fname, char *path);
133 int cleanup_file(char *path);
134 
135 int setup_swapfile(char *testdir, char *fname, char *path, size_t size);
136 int cleanup_swapfile(char *path);
137 
138 #define QUEUE_NAME	"/test_mqueue"
139 pid_t create_echo_msg_proc(void);
140 
141 pid_t get_unexist_pid(void);
142 
143 #endif /* __CJK_SYSCALL_J_H__ */
144