summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-11-08 05:33:45 +0000
committerAndrew Tridgell <tridge@samba.org>1997-11-08 05:33:45 +0000
commitaf1f408a05a42a7ec5c2f4cc5b67c08b3c6cf61f (patch)
tree272ee8e9d4ee97c97cdb9f7abab4743243b1a06f /source
parent097781e2992f12c545170c82ada2f4023a9784f5 (diff)
downloadsamba-af1f408a05a42a7ec5c2f4cc5b67c08b3c6cf61f.tar.gz
samba-af1f408a05a42a7ec5c2f4cc5b67c08b3c6cf61f.tar.xz
samba-af1f408a05a42a7ec5c2f4cc5b67c08b3c6cf61f.zip
a few more tests added, including one that tests whether the server
understand the full range of byte offsets in locking requests. Samba doesn't (due to the 31 bit limitation in fcntl locking)
Diffstat (limited to 'source')
-rw-r--r--source/utils/torture.c158
1 files changed, 157 insertions, 1 deletions
diff --git a/source/utils/torture.c b/source/utils/torture.c
index 67a363df27b..506f31481c3 100644
--- a/source/utils/torture.c
+++ b/source/utils/torture.c
@@ -283,7 +283,7 @@ static void run_locktest1(void)
t2 = time(NULL);
if (t2 - t1 < 5) {
- printf("This server appears not to support timed lock requests\n");
+ printf("error: This server appears not to support timed lock requests\n");
}
if (!cli_close(&cli1, fnum2)) {
@@ -436,6 +436,160 @@ static void run_locktest2(void)
}
+/*
+ This test checks that
+
+ 1) the server supports the full offset range in lock requests
+*/
+static void run_locktest3(int numops)
+{
+ static struct cli_state cli1, cli2;
+ char *fname = "\\locktest.lck";
+ int fnum1, fnum2, i;
+ uint32 offset;
+
+#define NEXT_OFFSET offset += (~(uint32)0) / numops
+
+ if (!open_connection(&cli1) || !open_connection(&cli2)) {
+ return;
+ }
+ cli_sockopt(&cli1, sockops);
+ cli_sockopt(&cli2, sockops);
+
+ printf("starting locktest3\n");
+
+ cli_unlink(&cli1, fname);
+
+ fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ if (fnum1 == -1) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return;
+ }
+ fnum2 = cli_open(&cli2, fname, O_RDWR, DENY_NONE);
+ if (fnum2 == -1) {
+ printf("open2 of %s failed (%s)\n", fname, cli_errstr(&cli2));
+ return;
+ }
+
+ for (offset=i=0;i<numops;i++) {
+ NEXT_OFFSET;
+ if (!cli_lock(&cli1, fnum1, offset-1, 1, 0)) {
+ printf("lock1 %d failed (%s)\n",
+ i,
+ cli_errstr(&cli1));
+ return;
+ }
+
+ if (!cli_lock(&cli2, fnum2, offset-2, 1, 0)) {
+ printf("lock2 %d failed (%s)\n",
+ i,
+ cli_errstr(&cli1));
+ return;
+ }
+ }
+
+ for (offset=i=0;i<numops;i++) {
+ NEXT_OFFSET;
+
+ if (cli_lock(&cli1, fnum1, offset-2, 1, 0)) {
+ printf("error: lock1 %d succeeded!\n", i);
+ return;
+ }
+
+ if (cli_lock(&cli2, fnum2, offset-1, 1, 0)) {
+ printf("error: lock2 %d succeeded!\n", i);
+ return;
+ }
+
+ if (cli_lock(&cli1, fnum1, offset-1, 1, 0)) {
+ printf("error: lock3 %d succeeded!\n", i);
+ return;
+ }
+
+ if (cli_lock(&cli2, fnum2, offset-2, 1, 0)) {
+ printf("error: lock4 %d succeeded!\n", i);
+ return;
+ }
+ }
+
+ for (offset=i=0;i<numops;i++) {
+ NEXT_OFFSET;
+
+ if (!cli_unlock(&cli1, fnum1, offset-1, 1, 0)) {
+ printf("unlock1 %d failed (%s)\n",
+ i,
+ cli_errstr(&cli1));
+ return;
+ }
+
+ if (!cli_unlock(&cli2, fnum2, offset-2, 1, 0)) {
+ printf("unlock2 %d failed (%s)\n",
+ i,
+ cli_errstr(&cli1));
+ return;
+ }
+ }
+
+ if (!cli_close(&cli1, fnum1)) {
+ printf("close1 failed (%s)\n", cli_errstr(&cli1));
+ }
+
+ if (!cli_close(&cli2, fnum2)) {
+ printf("close2 failed (%s)\n", cli_errstr(&cli2));
+ }
+
+ if (!cli_unlink(&cli1, fname)) {
+ printf("unlink failed (%s)\n", cli_errstr(&cli1));
+ return;
+ }
+
+ close_connection(&cli1);
+ close_connection(&cli2);
+
+ printf("finished locktest3\n");
+}
+
+
+/*
+ This test checks that
+
+ 1) the server does not allow an unlink on a file that is open
+*/
+static void run_unlinktest(void)
+{
+ static struct cli_state cli;
+ char *fname = "\\unlink.tst";
+ int fnum;
+
+ if (!open_connection(&cli)) {
+ return;
+ }
+
+ cli_sockopt(&cli, sockops);
+
+ printf("starting unlink test\n");
+
+ cli_unlink(&cli, fname);
+
+ cli_setpid(&cli, 1);
+
+ fnum = cli_open(&cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ if (fnum == -1) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(&cli));
+ return;
+ }
+
+ if (cli_unlink(&cli, fname)) {
+ printf("error: server allowed unlink on an open file\n");
+ }
+
+ close_connection(&cli);
+
+ printf("unlink test finished\n");
+}
+
+
+
static void create_procs(int nprocs, int numops)
{
int i, status;
@@ -548,6 +702,8 @@ static void create_procs(int nprocs, int numops)
run_locktest1();
run_locktest2();
+ run_locktest3(numops);
+ run_unlinktest();
return(0);
}