summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-03 14:49:15 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-03 14:49:15 +0000
commit380d02c219eb35f2d7b6585c3b7644b80c561b78 (patch)
tree2fa0026d033b5f493e3d7c1e1a272cf9bb6fa56f
parentc6230f64313feb596def5685141a5de958b07d43 (diff)
downloadsamba-380d02c219eb35f2d7b6585c3b7644b80c561b78.tar.gz
samba-380d02c219eb35f2d7b6585c3b7644b80c561b78.tar.bz2
samba-380d02c219eb35f2d7b6585c3b7644b80c561b78.zip
improved the lock test program
(This used to be commit a0a3931c6e5824121bf4a8d075ef24b9b70e8aa1)
-rw-r--r--source3/utils/locktest.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/source3/utils/locktest.c b/source3/utils/locktest.c
index 44b5d92469..025a473370 100644
--- a/source3/utils/locktest.c
+++ b/source3/utils/locktest.c
@@ -28,11 +28,12 @@ static fstring username;
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
@@ -45,7 +46,7 @@ static int numops = 1000;
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);
@@ -63,7 +64,7 @@ static void test_locks(struct cli_state *cli[2][2])
}
}
- while (numops--) {
+ for (n=0; n<numops; n++) {
int start, len, op, r;
BOOL ret1, ret2;
@@ -81,7 +82,7 @@ static void test_locks(struct cli_state *cli[2][2])
}
r = random() % 100;
-
+
if (r < LOCK_PCT) {
/* set a lock */
ret1 = cli_lock(cli[0][conn],
@@ -90,11 +91,12 @@ static void test_locks(struct cli_state *cli[2][2])
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 */
@@ -104,10 +106,10 @@ static void test_locks(struct cli_state *cli[2][2])
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 */
@@ -127,9 +129,14 @@ static void test_locks(struct cli_state *cli[2][2])
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);
}
}
}
@@ -238,6 +245,8 @@ static void usage(void)
options:\n\
-U user%%pass\n\
-s seed\n\
+ -o numops\n\
+ -a (show all ops)\n\
");
}
@@ -288,7 +297,7 @@ static void usage(void)
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);
@@ -305,6 +314,9 @@ static void usage(void)
case 'o':
numops = atoi(optarg);
break;
+ case 'a':
+ showall = True;
+ break;
case 'h':
usage();
exit(1);