summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-16 12:10:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:54 -0500
commit79f32d794ab65f8cde07779771d660589edb156a (patch)
tree884bdb1f5e7a712b5305ee40baa88c41a5ecd845 /source4/torture
parentab0fa0ba90b139231b9f345291ef8a655991765e (diff)
downloadsamba-79f32d794ab65f8cde07779771d660589edb156a.tar.gz
samba-79f32d794ab65f8cde07779771d660589edb156a.tar.bz2
samba-79f32d794ab65f8cde07779771d660589edb156a.zip
r4779: demonstrate doing 50 parallel loadfile operations, with a callback for completion
(This used to be commit b8c5269482cd7c2611d785bb8831eebae2f905d2)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/raw/composite.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 563705740d..f1fb6a9829 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -26,6 +26,12 @@
#define BASEDIR "\\composite"
+static void loadfile_complete(struct smbcli_composite *c)
+{
+ int *count = c->async.private;
+ (*count)++;
+}
+
/*
test a simple savefile/loadfile combination
*/
@@ -35,8 +41,11 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
NTSTATUS status;
struct smb_composite_savefile io1;
struct smb_composite_loadfile io2;
+ struct smbcli_composite **c;
char *data;
size_t len = random() % 100000;
+ const int num_ops = 50;
+ int i, count=0;
data = talloc_array(mem_ctx, uint8_t, len);
@@ -56,23 +65,41 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
io2.in.fname = fname;
- printf("testing loadfile\n");
+ printf("testing parallel loadfile with %d ops\n", num_ops);
- status = smb_composite_loadfile(cli->tree, mem_ctx, &io2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Loadfile failed: %s\n", nt_errstr(status));
- return False;
- }
+ c = talloc_array(mem_ctx, struct smbcli_composite *, num_ops);
- if (io2.out.size != len) {
- printf("wrong length in returned data - %d should be %d\n",
- io2.out.size, len);
- return False;
+ for (i=0;i<num_ops;i++) {
+ c[i] = smb_composite_loadfile_send(cli->tree, &io2);
+ c[i]->async.fn = loadfile_complete;
+ c[i]->async.private = &count;
}
- if (memcmp(io2.out.data, data, len) != 0) {
- printf("wrong data in loadfile!\n");
- return False;
+ printf("waiting for completion\n");
+ while (count != num_ops) {
+ event_loop_once(cli->transport->socket->event.ctx);
+ printf("count=%d\r", count);
+ fflush(stdout);
+ }
+ printf("count=%d\n", count);
+
+ for (i=0;i<num_ops;i++) {
+ status = smb_composite_loadfile_recv(c[i], mem_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("loadfile[%d] failed - %s\n", i, nt_errstr(status));
+ return False;
+ }
+
+ if (io2.out.size != len) {
+ printf("wrong length in returned data - %d should be %d\n",
+ io2.out.size, len);
+ return False;
+ }
+
+ if (memcmp(io2.out.data, data, len) != 0) {
+ printf("wrong data in loadfile!\n");
+ return False;
+ }
}
talloc_free(data);