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>
35 #include "rpc_test_procs.h"
38 #include <sys/types.h>
46 #include <afs/cellconfig.h>
47 #include <afs/com_err.h>
55 #include <sys/malloc.h>
59 #include <afs/errors.h>
60 #include <afs/sys_prototypes.h>
61 #include <rx/rx_prototypes.h>
62 #ifdef AFS_PTHREAD_ENV
66 const char *prog = "lockharness";
68 #ifndef AFS_PTHREAD_ENV
69 #error compilation without pthreads is not supported
74 main(int argc, char **argv)
77 rpc_test_request_ctx *c1, *c2;
78 AFSFetchStatus outstatus;
80 printf("%s: start\n", prog);
82 code = rpc_test_PkgInit();
84 /* replace with appropriate test addresses */
85 code = init_fs_channel(&c1, "eth0", "10.1.1.213", "24",
86 "10.1.1.81", /* fs */ RPC_TEST_REQ_CTX_FLAG_NONE);
87 code = init_fs_channel(&c2, "eth0", "10.1.1.213", "24",
88 "10.1.1.81" /* fs */, RPC_TEST_REQ_CTX_FLAG_XCB);
90 printf("%s: channels initialized\n", prog);
95 /* XXXX fid members should be...dynamic */
96 AFSFid fid = { 536870915, 12, 4016};
97 code = rpc_test_afs_fetch_status(c1, &fid, &outstatus);
98 printf("%s: c1 call returned %d\n", prog, code);
102 /* XXXX fid members should be...dynamic */
103 AFSFid fid = { 536870915, 12, 4016};
104 code = rpc_test_afs_fetch_status(c2, &fid, &outstatus);
105 printf("%s: c2 call returned %d\n", prog, code);
108 /* force bcb at c1 */
110 AFSFid fid = { 536870915, 12, 4016};
111 AFSStoreStatus instatus;
113 instatus.SegSize = 0;
114 instatus.Owner = outstatus.Owner;
115 instatus.Group = outstatus.Group;
116 instatus.UnixModeBits = outstatus.UnixModeBits;
117 instatus.ClientModTime = time(NULL);
118 code = rpc_test_afs_store_status(c2, &fid, &instatus, &outstatus);
119 printf("%s: c2 store status returned %d\n", prog, code);
122 /* force bcb at c2 */
124 AFSFid fid = { 536870915, 12, 4016};
125 AFSStoreStatus instatus;
127 instatus.SegSize = 0;
128 instatus.Owner = outstatus.Owner;
129 instatus.Group = outstatus.Group;
130 instatus.UnixModeBits = outstatus.UnixModeBits;
131 instatus.ClientModTime = time(NULL);
132 code = rpc_test_afs_store_status(c1, &fid, &instatus, &outstatus);
133 printf("%s: c1 store status returned %d\n", prog, code);
139 #if defined(AFS_BYTE_RANGE_FLOCKS)
140 /* set a lock on c1 */
142 AFSFid fid = { 536870915, 12, 4016};
143 AFSByteRangeLock lock;
144 memset(&lock, 0, sizeof(AFSByteRangeLock));
146 lock.Type = LockWrite;
152 code = rpc_test_afs_set_byterangelock(c1, &lock);
153 printf("%s: c1 set lock returned %d\n", prog, code);
156 /* try to set the same lock in c2 (should FAIL) */
158 AFSFid fid = { 536870915, 12, 4016};
159 AFSByteRangeLock lock;
160 memset(&lock, 0, sizeof(AFSByteRangeLock));
162 lock.Type = LockWrite;
168 code = rpc_test_afs_set_byterangelock(c2, &lock);
169 printf("%s: c2 set lock returned %d\n", prog, code);
172 /* release lock on c1 */
174 AFSFid fid = { 536870915, 12, 4016};
175 AFSByteRangeLock lock;
176 memset(&lock, 0, sizeof(AFSByteRangeLock));
178 lock.Type = LockWrite;
184 code = rpc_test_afs_release_byterangelock(c1, &lock);
185 printf("%s: c1 set lock returned %d\n", prog, code);
187 #endif /* AFS_BYTE_RANGE_FLOCKS */
189 printf("%s: wait %d sec for processing\n", prog, 5);
192 code = destroy_fs_channel(c1);
193 code = destroy_fs_channel(c2);
195 rpc_test_PkgShutdown();
197 printf("%s: finish\n", prog);