summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-04-14 20:36:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:07 -0500
commitcf0343dfa9a477004cd21d7632032d86adf8b259 (patch)
tree365ca200d32f99eb19be681d0ba5e24c94100daf /source4/torture
parent3f9628ac7c613def7dcce740e88964638b4b6102 (diff)
downloadsamba-cf0343dfa9a477004cd21d7632032d86adf8b259.tar.gz
samba-cf0343dfa9a477004cd21d7632032d86adf8b259.tar.bz2
samba-cf0343dfa9a477004cd21d7632032d86adf8b259.zip
r15087: Quick stress test that does more or less what the tool "iometer" does.
Volker (This used to be commit 6a08b192bec95cc0bbe017a2ce692afce63e047f)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/base.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 050c092296..4358e60159 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1438,6 +1438,92 @@ static BOOL run_xcopy(struct torture_context *torture)
return correct;
}
+static BOOL run_iometer(struct torture_context *torture)
+{
+ struct smbcli_state *cli;
+ const char *fname = "\\iobw.tst";
+ int fnum;
+ size_t filesize;
+ NTSTATUS status;
+ char buf[2048];
+ int ops;
+ BOOL result = False;
+
+ printf("Starting iometer test\n");
+
+ memset(buf, 0, sizeof(buf));
+
+ if (!torture_open_connection(&cli)) {
+ return False;
+ }
+
+ status = smbcli_getatr(cli->tree, fname, NULL, &filesize, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("smbcli_getatr failed: %s\n", nt_errstr(status));
+ goto done;
+ }
+
+ printf("size: %d\n", filesize);
+
+ filesize -= (sizeof(buf) - 1);
+
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0x16,
+ 0x2019f, 0, 0x3, 3, 0x42, 0x3);
+ if (fnum == -1) {
+ printf("open failed: %s\n", smbcli_errstr(cli->tree));
+ goto done;
+ }
+
+ ops = 0;
+
+ while (True) {
+ int i, num_reads, num_writes;
+
+ num_reads = random() % 10;
+ num_writes = random() % 3;
+
+ for (i=0; i<num_reads; i++) {
+ ssize_t res;
+ if (ops++ > torture_numops) {
+ result = True;
+ goto done;
+ }
+ res = smbcli_read(cli->tree, fnum, buf,
+ random() % filesize, sizeof(buf));
+ if (res != sizeof(buf)) {
+ printf("read failed: %s\n",
+ smbcli_errstr(cli->tree));
+ goto done;
+ }
+ }
+ for (i=0; i<num_writes; i++) {
+ ssize_t res;
+ if (ops++ > torture_numops) {
+ result = True;
+ goto done;
+ }
+ res = smbcli_write(cli->tree, fnum, 0, buf,
+ random() % filesize, sizeof(buf));
+ if (res != sizeof(buf)) {
+ printf("read failed: %s\n",
+ smbcli_errstr(cli->tree));
+ goto done;
+ }
+ }
+ }
+
+ result = True;
+ done:
+
+ if (!torture_close_connection(cli)) {
+ printf("close_connection failed: %s\n",
+ smbcli_errstr(cli->tree));
+ return False;
+ }
+
+ return result;
+}
+
/**
tries variants of chkpath
*/
@@ -1554,6 +1640,7 @@ NTSTATUS torture_base_init(void)
register_torture_op("BASE-OPEN", run_opentest, 0);
register_torture_op("BASE-DEFER_OPEN", NULL, run_deferopen);
register_torture_op("BASE-XCOPY", run_xcopy, 0);
+ register_torture_op("BASE-IOMETER", run_iometer, 0);
register_torture_op("BASE-RENAME", torture_test_rename, 0);
register_torture_op("BASE-DELETE", torture_test_delete, 0);
register_torture_op("BASE-PROPERTIES", torture_test_properties, 0);