summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-29 16:05:36 +0100
committerVolker Lendecke <vl@samba.org>2009-11-29 16:12:51 +0100
commit7bbee8dc17744a838834ea21b2acb2b7f8366194 (patch)
treea7579f123c1d418ca3cf3d7be5ceb1d1854d6925 /source3/torture
parent603a3ba19efb0d1757c7a9ef158d2fe907e48238 (diff)
downloadsamba-7bbee8dc17744a838834ea21b2acb2b7f8366194.tar.gz
samba-7bbee8dc17744a838834ea21b2acb2b7f8366194.tar.bz2
samba-7bbee8dc17744a838834ea21b2acb2b7f8366194.zip
s3: Add a regression test for bug 6898
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/proto.h6
-rw-r--r--source3/torture/test_posix_append.c97
-rw-r--r--source3/torture/torture.c1
3 files changed, 104 insertions, 0 deletions
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 56396fe4c0..d78a39d85a 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -77,4 +77,10 @@ NTSTATUS torture_setup_unix_extensions(struct cli_state *cli);
bool torture_utable(int dummy);
bool torture_casetable(int dummy);
+/*
+ * Misc
+ */
+
+bool run_posix_append(int dummy);
+
#endif /* __TORTURE_H__ */
diff --git a/source3/torture/test_posix_append.c b/source3/torture/test_posix_append.c
new file mode 100644
index 0000000000..36336aafbc
--- /dev/null
+++ b/source3/torture/test_posix_append.c
@@ -0,0 +1,97 @@
+/*
+ Unix SMB/CIFS implementation.
+ async getpwsid
+ Copyright (C) Volker Lendecke 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "torture/proto.h"
+
+/*
+ * Make sure that GENERIC_WRITE does not trigger append. See
+ * https://bugzilla.samba.org/show_bug.cgi?id=6898
+ */
+
+bool run_posix_append(int dummy)
+{
+ struct cli_state *cli;
+ const char *fname = "append";
+ NTSTATUS status;
+ uint16_t fnum;
+ ssize_t written;
+ SMB_OFF_T size;
+ char c = '\0';
+ bool ret = false;
+
+ printf("Starting POSIX_APPEND\n");
+
+ if (!torture_open_connection(&cli, 0)) {
+ return false;
+ }
+
+ status = torture_setup_unix_extensions(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("torture_setup_unix_extensions failed: %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+
+ status = cli_ntcreate(
+ cli, fname, 0,
+ GENERIC_WRITE_ACCESS|GENERIC_READ_ACCESS|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL|FILE_FLAG_POSIX_SEMANTICS,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF,
+ FILE_NON_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE,
+ 0, &fnum);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_ntcreate failed: %s\n", nt_errstr(status));
+ goto fail;
+ }
+
+ /*
+ * Write two bytes at offset 0. With bug 6898 we would end up
+ * with a file of 2 byte length.
+ */
+
+ written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
+ if (written != sizeof(c)) {
+ printf("cli_write failed\n");
+ goto fail;
+ }
+ written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
+ if (written != sizeof(c)) {
+ printf("cli_write failed\n");
+ goto fail;
+ }
+
+ status = cli_getattrE(cli, fnum, NULL, &size, NULL, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_getatrE failed: %s\n", nt_errstr(status));
+ goto fail;
+ }
+
+ if (size != sizeof(c)) {
+ printf("BUG: Writing with O_APPEND!!\n");
+ goto fail;
+ }
+
+ ret = true;
+fail:
+ torture_close_connection(cli);
+ return ret;
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 4b5e8b2dfb..5a0a300092 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7176,6 +7176,7 @@ static struct {
{"RW3", run_readwritelarge, 0},
{"OPEN", run_opentest, 0},
{"POSIX", run_simple_posix_open_test, 0},
+ {"POSIX-APPEND", run_posix_append, 0},
{ "UID-REGRESSION-TEST", run_uid_regression_test, 0},
{ "SHORTNAME-TEST", run_shortname_test, 0},
#if 1