2 * Copyright (c) 2010, Linux Box Corporation.
5 * Portions Copyright (c) 2007, Hartmut Reuter,
6 * RZG, Max-Planck-Institut f. Plasmaphysik.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <afsconfig.h>
32 #include <afs/param.h>
38 #include "rpc_test_procs.h"
41 #include <sys/types.h>
49 #include <afs/cellconfig.h>
50 #include <afs/com_err.h>
58 #include <sys/malloc.h>
60 #include <afs/errors.h>
61 #include <afs/sys_prototypes.h>
62 #include <rx/rx_prototypes.h>
63 #ifdef AFS_PTHREAD_ENV
67 const char *prog
= "lockharness";
69 #ifndef AFS_PTHREAD_ENV
70 #error compilation without pthreads is not supported
75 main(int argc
, char **argv
)
78 rpc_test_request_ctx
*c1
, *c2
;
79 AFSFetchStatus outstatus
;
81 printf("%s: start\n", prog
);
83 code
= rpc_test_PkgInit();
85 /* replace with appropriate test addresses */
86 code
= init_fs_channel(&c1
, "eth0", "10.1.1.213", "24",
87 "10.1.1.81", /* fs */ RPC_TEST_REQ_CTX_FLAG_NONE
);
88 code
= init_fs_channel(&c2
, "eth0", "10.1.1.213", "24",
89 "10.1.1.81" /* fs */, RPC_TEST_REQ_CTX_FLAG_XCB
);
91 printf("%s: channels initialized\n", prog
);
96 /* XXXX fid members should be...dynamic */
97 AFSFid fid
= { 536870915, 12, 4016};
98 code
= rpc_test_afs_fetch_status(c1
, &fid
, &outstatus
);
99 printf("%s: c1 call returned %d\n", prog
, code
);
103 /* XXXX fid members should be...dynamic */
104 AFSFid fid
= { 536870915, 12, 4016};
105 code
= rpc_test_afs_fetch_status(c2
, &fid
, &outstatus
);
106 printf("%s: c2 call returned %d\n", prog
, code
);
109 /* force bcb at c1 */
111 AFSFid fid
= { 536870915, 12, 4016};
112 AFSStoreStatus instatus
;
114 instatus
.SegSize
= 0;
115 instatus
.Owner
= outstatus
.Owner
;
116 instatus
.Group
= outstatus
.Group
;
117 instatus
.UnixModeBits
= outstatus
.UnixModeBits
;
118 instatus
.ClientModTime
= time(NULL
);
119 code
= rpc_test_afs_store_status(c2
, &fid
, &instatus
, &outstatus
);
120 printf("%s: c2 store status returned %d\n", prog
, code
);
123 /* force bcb at c2 */
125 AFSFid fid
= { 536870915, 12, 4016};
126 AFSStoreStatus instatus
;
128 instatus
.SegSize
= 0;
129 instatus
.Owner
= outstatus
.Owner
;
130 instatus
.Group
= outstatus
.Group
;
131 instatus
.UnixModeBits
= outstatus
.UnixModeBits
;
132 instatus
.ClientModTime
= time(NULL
);
133 code
= rpc_test_afs_store_status(c1
, &fid
, &instatus
, &outstatus
);
134 printf("%s: c1 store status returned %d\n", prog
, code
);
140 #if defined(AFS_BYTE_RANGE_FLOCKS)
141 /* set a lock on c1 */
143 AFSFid fid
= { 536870915, 12, 4016};
144 AFSByteRangeLock lock
;
145 memset(&lock
, 0, sizeof(AFSByteRangeLock
));
147 lock
.Type
= LockWrite
;
153 code
= rpc_test_afs_set_byterangelock(c1
, &lock
);
154 printf("%s: c1 set lock returned %d\n", prog
, code
);
157 /* try to set the same lock in c2 (should FAIL) */
159 AFSFid fid
= { 536870915, 12, 4016};
160 AFSByteRangeLock lock
;
161 memset(&lock
, 0, sizeof(AFSByteRangeLock
));
163 lock
.Type
= LockWrite
;
169 code
= rpc_test_afs_set_byterangelock(c2
, &lock
);
170 printf("%s: c2 set lock returned %d\n", prog
, code
);
173 /* release lock on c1 */
175 AFSFid fid
= { 536870915, 12, 4016};
176 AFSByteRangeLock lock
;
177 memset(&lock
, 0, sizeof(AFSByteRangeLock
));
179 lock
.Type
= LockWrite
;
185 code
= rpc_test_afs_release_byterangelock(c1
, &lock
);
186 printf("%s: c1 set lock returned %d\n", prog
, code
);
188 #endif /* AFS_BYTE_RANGE_FLOCKS */
190 printf("%s: wait %d sec for processing\n", prog
, 5);
193 code
= destroy_fs_channel(c1
);
194 code
= destroy_fs_channel(c2
);
196 rpc_test_PkgShutdown();
198 printf("%s: finish\n", prog
);