r25443: Enhance the WINBINDD-STRUCT-SHOW_SEQUENCE test:
authorMichael Adam <obnox@samba.org>
Mon, 1 Oct 2007 15:45:01 +0000 (15:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:07:34 +0000 (15:07 -0500)
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

source/torture/winbind/struct_based.c

index 0d30c2f07282de8e5b854c5e218f95874d1ae4aa..0b9391bcd86d8c5334cb1b68e5f8308c1018f818 100644 (file)
@@ -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;