From 3f466b1aab78876852563e258bc690c7228950e2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 1 Oct 2007 15:45:01 +0000 Subject: r25443: Enhance the WINBINDD-STRUCT-SHOW_SEQUENCE test: Compare the lists of sequence numbers obtained by (a) calling SHOW_SEQUENCE without domain argument and (b) walking the list of trusted domains. output the sequence numbers of the individual domains upon success. Michael (This used to be commit 21db6eb43c796da7607260d783221c5ee42f1f41) --- source4/torture/winbind/struct_based.c | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c index 0d30c2f072..0b9391bcd8 100644 --- a/source4/torture/winbind/struct_based.c +++ b/source4/torture/winbind/struct_based.c @@ -585,14 +585,22 @@ static bool torture_winbind_struct_list_groups(struct torture_context *torture) return true; } +struct torture_domain_sequence { + const char *netbios_name; + uint32_t seq; +}; + static bool torture_winbind_struct_show_sequence(struct torture_context *torture) { struct winbindd_request req; struct winbindd_response rep; bool ok; + const char *extra_data; + fstring line; + uint32_t i; + uint32_t count = 0; struct torture_trust_domain *domlist = NULL; - int i; - + struct torture_domain_sequence *s = NULL; torture_comment(torture, "Running WINBINDD_SHOW_SEQUENCE (struct based)\n"); @@ -603,8 +611,39 @@ static bool torture_winbind_struct_show_sequence(struct torture_context *torture DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep); - if (rep.extra_data.data) { - torture_comment(torture, "%s", (char *)rep.extra_data.data); + extra_data = (char *)rep.extra_data.data; + torture_assert(torture, extra_data, "NULL sequence list"); + + torture_comment(torture, "%s", extra_data); + + while (next_token(&extra_data, line, "\n", sizeof(fstring))) { + char *p, *lp; + uint32_t seq; + + s = talloc_realloc(torture, s, struct torture_domain_sequence, + count + 2); + ZERO_STRUCT(s[count+1]); + + lp = line; + p = strchr(lp, ' '); + torture_assert(torture, p, "invalid line format"); + *p = 0; + s[count].netbios_name = talloc_strdup(s, lp); + + lp = p+1; + torture_assert(torture, strncmp(lp, ": ", 2) == 0, "invalid line format"); + lp += 2; + if (strcmp(lp, "DISCONNECTED") == 0) { + seq = (uint32_t)-1; + } else { + seq = (uint32_t)strtol(lp, &p, 10); + torture_assert(torture, (*p == '\0'), "invalid line format"); + torture_assert(torture, (seq != (uint32_t)-1), + "sequence number -1 encountered"); + } + s[count].seq = seq; + + count++; } torture_comment(torture, " - getting list of trusted domains\n"); @@ -612,15 +651,32 @@ static bool torture_winbind_struct_show_sequence(struct torture_context *torture torture_assert(torture, ok, "failed to get trust list"); for (i=0; domlist[i].netbios_name; i++) { + uint32_t seq; + + ok = (s[i].netbios_name != NULL); + torture_assert(torture, ok, "more domains recieved in second run"); + ok = (strcmp(domlist[i].netbios_name, s[i].netbios_name) == 0); + torture_assert(torture, ok, "inconsistent order of domain lists"); + ZERO_STRUCT(req); ZERO_STRUCT(rep); + fstrcpy(req.domain_name, domlist[i].netbios_name); + torture_comment(torture, " - Running WINBINDD_SHOW_SEQUENCE " "for domain %s:\n", req.domain_name); + DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep); - if (rep.extra_data.data) { - torture_comment(torture, "%s", (char *)rep.extra_data.data); + seq = rep.data.sequence_number; + + torture_comment(torture, "%s : ", req.domain_name); + if (seq == (uint32_t)-1) { + torture_comment(torture, "DISCONNECTED\n"); + } else { + torture_comment(torture, "%d\n", seq); } + torture_assert(torture, (seq >= s[i].seq), + "illegal sequence number encountered"); } return true; -- cgit