summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-08-24 19:34:11 +0000
committerAndrew Tridgell <tridge@samba.org>2001-08-24 19:34:11 +0000
commitb34d17e49811df341054038ebb01734c9c83623c (patch)
treef10c48c8d1e7a2e93b4012f6b9c05b6b3621ff84
parentc1f0d99013e0c29d76d51b81ec2396d055471a82 (diff)
downloadsamba-b34d17e49811df341054038ebb01734c9c83623c.tar.gz
samba-b34d17e49811df341054038ebb01734c9c83623c.tar.bz2
samba-b34d17e49811df341054038ebb01734c9c83623c.zip
tests for 0 length locks
(This used to be commit 8fbd1d0f978a349ec4fcc0d34fca55314d3dec31)
-rw-r--r--source3/torture/locktest.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 54cf0dd351..4c62b8dafc 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -33,8 +33,9 @@ static BOOL hide_unlock_fails;
static BOOL use_oplocks;
#define FILENAME "\\locktest.dat"
-#define LOCKRANGE 1000
+#define LOCKRANGE 5
#define LOCKBASE 0
+#define MINLENGTH 0
/*
#define LOCKBASE (0x40000000 - 50)
@@ -260,9 +261,9 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
start, len, LOCK_TIMEOUT, op);
}
if (showall || ret[0] != ret[1]) {
- printf("lock conn=%u f=%u range=%.0f:%.0f(%.0f) op=%s -> %u:%u\n",
+ printf("lock conn=%u f=%u range=%.0f(%.0f) op=%s -> %u:%u\n",
conn, f,
- (double)start, (double)start+len-1, (double)len,
+ (double)start, (double)len,
op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
ret[0], ret[1]);
}
@@ -276,9 +277,9 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
start, len);
}
if (showall || (!hide_unlock_fails && (ret[0] != ret[1]))) {
- printf("unlock conn=%u f=%u range=%.0f:%.0f(%.0f) -> %u:%u\n",
+ printf("unlock conn=%u f=%u range=%.0f(%.0f) -> %u:%u\n",
conn, f,
- (double)start, (double)start+len-1, (double)len,
+ (double)start, (double)len,
ret[0], ret[1]);
}
if (showall || ret[0] != ret[1]) show_locks();
@@ -372,7 +373,7 @@ static void test_locks(char *share[NSERVERS])
{
struct cli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
- int n, i, n1;
+ int n, i, n1, skip;
ZERO_STRUCT(fnum);
ZERO_STRUCT(cli);
@@ -388,7 +389,7 @@ static void test_locks(char *share[NSERVERS])
recorded[n].conn = random() % NCONNECTIONS;
recorded[n].f = random() % NFILES;
recorded[n].start = LOCKBASE + ((unsigned)random() % (LOCKRANGE-1));
- recorded[n].len =
+ recorded[n].len = MINLENGTH +
random() % (LOCKRANGE-(recorded[n].start-LOCKBASE));
recorded[n].start *= RANGE_MULTIPLE;
recorded[n].len *= RANGE_MULTIPLE;
@@ -407,6 +408,8 @@ static void test_locks(char *share[NSERVERS])
if (n == numops || !analyze) return;
n++;
+ skip = n/2;
+
while (1) {
n1 = n;
@@ -414,26 +417,36 @@ static void test_locks(char *share[NSERVERS])
reconnect(cli, fnum, share);
open_files(cli, fnum);
- for (i=0;i<n-1;i++) {
- int m;
- recorded[i].needed = False;
+ for (i=0;i<n-skip;i++) {
+ int m, j;
+ for (j=i;j<i+skip;j++) {
+ recorded[j].needed = False;
+ }
close_files(cli, fnum);
open_files(cli, fnum);
m = retest(cli, fnum, n);
if (m == n) {
- recorded[i].needed = True;
+ for (j=i;j<i+skip;j++) {
+ recorded[j].needed = True;
+ }
} else {
- if (i < m) {
- memmove(&recorded[i], &recorded[i+1],
- (m-i)*sizeof(recorded[0]));
+ if (i+(skip-1) < m) {
+ memmove(&recorded[i], &recorded[i+skip],
+ (m-(i+skip-1))*sizeof(recorded[0]));
}
- n = m;
+ n = m-(skip-1);
i--;
}
}
+ if (skip > 1) {
+ skip = skip/2;
+ printf("skip=%d\n", skip);
+ continue;
+ }
+
if (n1 == n) break;
}