From bca38ba866b8368fa49353ecdb750f2f2de9adf3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 07:58:08 +0000 Subject: r18371: made the directory depth notify test independent of timing (This used to be commit 39458e62f576c551df016a7be4d35175dc21696e) --- source4/torture/raw/notify.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'source4/torture/raw/notify.c') diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 0036f10f40..966b32ce91 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -979,12 +979,14 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_notify notify; union smb_open io; struct smbcli_request *req; + struct timeval tv; struct { const char *path; BOOL recursive; uint32_t filter; int expected; int fnum; + int counted; } dirs[] = { {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 30 }, {BASEDIR "\\zqy", True, FILE_NOTIFY_CHANGE_NAME, 8 }, @@ -1009,6 +1011,7 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) }; int i; NTSTATUS status; + BOOL all_done = False; printf("TESTING CHANGE NOTIFY FOR DIFFERENT DEPTHS\n"); @@ -1053,20 +1056,35 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) talloc_free(path); } - /* give a bit of time for all the events to propogate */ - sleep(4); + /* give a bit of time for the events to propogate */ + tv = timeval_current(); + + do { + /* count events that have happened in each dir */ + for (i=0;itree, ¬ify); + smb_raw_ntcancel(req); + notify.nttrans.out.num_changes = 0; + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + dirs[i].counted += notify.nttrans.out.num_changes; + } + + all_done = True; + + for (i=0;itree, ¬ify); - smb_raw_ntcancel(req); - notify.nttrans.out.num_changes = 0; - status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); - if (notify.nttrans.out.num_changes != dirs[i].expected) { + if (dirs[i].counted != dirs[i].expected) { printf("ERROR: i=%d expected %d got %d for '%s'\n", - i, dirs[i].expected, notify.nttrans.out.num_changes, - dirs[i].path); + i, dirs[i].expected, dirs[i].counted, dirs[i].path); ret = False; } } -- cgit