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>
62 #include <afs/errors.h>
63 #include <afs/sys_prototypes.h>
64 #include <rx/rx_prototypes.h>
65 #ifdef AFS_PTHREAD_ENV
69 const char *prog = "lockharness";
71 #ifndef AFS_PTHREAD_ENV
72 #error compilation without pthreads is not supported
77 main(int argc, char **argv)
80 rpc_test_request_ctx *c1, *c2;
81 AFSFetchStatus outstatus;
83 printf("%s: start\n", prog);
85 code = rpc_test_PkgInit();
87 /* replace with appropriate test addresses */
88 code = init_fs_channel(&c1, "eth0", "10.1.1.213", "24",
89 "10.1.1.81", /* fs */ RPC_TEST_REQ_CTX_FLAG_NONE);
90 code = init_fs_channel(&c2, "eth0", "10.1.1.213", "24",
91 "10.1.1.81" /* fs */, RPC_TEST_REQ_CTX_FLAG_XCB);
93 printf("%s: channels initialized\n", prog);
98 /* XXXX fid members should be...dynamic */
99 AFSFid fid = { 536870915, 12, 4016};
100 code = rpc_test_afs_fetch_status(c1, &fid, &outstatus);
101 printf("%s: c1 call returned %d\n", prog, code);
105 /* XXXX fid members should be...dynamic */
106 AFSFid fid = { 536870915, 12, 4016};
107 code = rpc_test_afs_fetch_status(c2, &fid, &outstatus);
108 printf("%s: c2 call returned %d\n", prog, code);
111 /* force bcb at c1 */
113 AFSFid fid = { 536870915, 12, 4016};
114 AFSStoreStatus instatus;
116 instatus.SegSize = 0;
117 instatus.Owner = outstatus.Owner;
118 instatus.Group = outstatus.Group;
119 instatus.UnixModeBits = outstatus.UnixModeBits;
120 instatus.ClientModTime = time(NULL);
121 code = rpc_test_afs_store_status(c2, &fid, &instatus, &outstatus);
122 printf("%s: c2 store status returned %d\n", prog, code);
125 /* force bcb at c2 */
127 AFSFid fid = { 536870915, 12, 4016};
128 AFSStoreStatus instatus;
130 instatus.SegSize = 0;
131 instatus.Owner = outstatus.Owner;
132 instatus.Group = outstatus.Group;
133 instatus.UnixModeBits = outstatus.UnixModeBits;
134 instatus.ClientModTime = time(NULL);
135 code = rpc_test_afs_store_status(c1, &fid, &instatus, &outstatus);
136 printf("%s: c1 store status returned %d\n", prog, code);
142 #if defined(AFS_BYTE_RANGE_FLOCKS)
143 /* set a lock on c1 */
145 AFSFid fid = { 536870915, 12, 4016};
146 AFSByteRangeLock lock;
147 memset(&lock, 0, sizeof(AFSByteRangeLock));
149 lock.Type = LockWrite;
155 code = rpc_test_afs_set_byterangelock(c1, &lock);
156 printf("%s: c1 set lock returned %d\n", prog, code);
159 /* try to set the same lock in c2 (should FAIL) */
161 AFSFid fid = { 536870915, 12, 4016};
162 AFSByteRangeLock lock;
163 memset(&lock, 0, sizeof(AFSByteRangeLock));
165 lock.Type = LockWrite;
171 code = rpc_test_afs_set_byterangelock(c2, &lock);
172 printf("%s: c2 set lock returned %d\n", prog, code);
175 /* release lock on c1 */
177 AFSFid fid = { 536870915, 12, 4016};
178 AFSByteRangeLock lock;
179 memset(&lock, 0, sizeof(AFSByteRangeLock));
181 lock.Type = LockWrite;
187 code = rpc_test_afs_release_byterangelock(c1, &lock);
188 printf("%s: c1 set lock returned %d\n", prog, code);
190 #endif /* AFS_BYTE_RANGE_FLOCKS */
192 printf("%s: wait %d sec for processing\n", prog, 5);
195 code = destroy_fs_channel(c1);
196 code = destroy_fs_channel(c2);
198 rpc_test_PkgShutdown();
200 printf("%s: finish\n", prog);