static fstring workgroup;
static int got_pass;
static int numops = 1000;
+static BOOL showall;
#define FILENAME "locktest.dat"
#define LOCKRANGE 100
-#define READ_PCT 75
+#define READ_PCT 50
#define LOCK_PCT 45
#define UNLOCK_PCT 45
static void test_locks(struct cli_state *cli[2][2])
{
int fnum[2][2][2];
- int server, conn, f;
+ int server, conn, f, n;
cli_unlink(cli[0][0], FILENAME);
cli_unlink(cli[1][0], FILENAME);
}
}
- while (numops--) {
+ for (n=0; n<numops; n++) {
int start, len, op, r;
BOOL ret1, ret2;
}
r = random() % 100;
-
+
if (r < LOCK_PCT) {
/* set a lock */
ret1 = cli_lock(cli[0][conn],
ret2 = cli_lock(cli[1][conn],
fnum[1][conn][f],
start, len, 0, op);
- if (ret1 != ret2) {
- printf("lock(%d): server1 gave %d server2 gave %d\n",
- numops, (int)ret1, (int)ret2);
- return;
+ if (showall || ret1 != ret2) {
+ printf("%5d lock conn=%d f=%d %d:%d op=%s -> %d:%d\n",
+ n, conn, f, start, len, op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
+ ret1, ret2);
}
+ if (ret1 != ret2) return;
} else if (r < LOCK_PCT+UNLOCK_PCT) {
/* unset a lock */
/* set a lock */
ret2 = cli_unlock(cli[1][conn],
fnum[1][conn][f],
start, len);
- if (ret1 != ret2) {
- printf("unlock(%d): server1 gave %d server2 gave %d\n",
- numops, (int)ret1, (int)ret2);
- return;
+ if (showall || ret1 != ret2) {
+ printf("%5d unlock conn=%d f=%d %d:%d -> %d:%d\n",
+ n, conn, f, start, len,
+ ret1, ret2);
}
} else {
/* reopen the file */
printf("failed to reopen on share2\n");
return;
}
+ if (showall) {
+ printf("%5d reopen conn=%d f=%d\n",
+ n, conn, f);
+ }
+ if (ret1 != ret2) return;
}
- if (numops % 100 == 0) {
- printf("%d\n", numops);
+ if (n % 100 == 0) {
+ printf("%d\n", n);
}
}
}
options:\n\
-U user%%pass\n\
-s seed\n\
+ -o numops\n\
+ -a (show all ops)\n\
");
}
seed = time(NULL);
- while ((opt = getopt(argc, argv, "U:s:ho:")) != EOF) {
+ while ((opt = getopt(argc, argv, "U:s:ho:a")) != EOF) {
switch (opt) {
case 'U':
pstrcpy(username,optarg);
case 'o':
numops = atoi(optarg);
break;
+ case 'a':
+ showall = True;
+ break;
case 'h':
usage();
exit(1);