summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-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);