s4-smbtorture: add optional very simple reply checks to lsa lookup name tests.
authorGünther Deschner <gd@samba.org>
Mon, 11 May 2009 14:40:26 +0000 (16:40 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 11 May 2009 14:44:39 +0000 (16:44 +0200)
Guenther

source4/torture/rpc/lsa.c

index e10bc7791189bb43666599d1b7aad764948593ad..04a8854031a510f2bcfe8ae8663c9b4112df4ea2 100644 (file)
@@ -319,7 +319,8 @@ static bool test_LookupNames_wellknown(struct dcerpc_pipe *p,
 static bool test_LookupNames2(struct dcerpc_pipe *p,
                              struct torture_context *tctx,
                              struct policy_handle *handle,
-                             struct lsa_TransNameArray2 *tnames)
+                             struct lsa_TransNameArray2 *tnames,
+                             bool check_result)
 {
        struct lsa_LookupNames2 r;
        struct lsa_TransSidArray2 sids;
@@ -357,6 +358,14 @@ static bool test_LookupNames2(struct dcerpc_pipe *p,
                return false;
        }
 
+       if (check_result) {
+               torture_assert_int_equal(tctx, count, sids.count,
+                       "unexpected number of results returned");
+               if (sids.count > 0) {
+                       torture_assert(tctx, sids.sids, "invalid sid buffer");
+               }
+       }
+
        printf("\n");
 
        return true;
@@ -366,7 +375,8 @@ static bool test_LookupNames2(struct dcerpc_pipe *p,
 static bool test_LookupNames3(struct dcerpc_pipe *p,
                              struct torture_context *tctx,
                              struct policy_handle *handle,
-                             struct lsa_TransNameArray2 *tnames)
+                             struct lsa_TransNameArray2 *tnames,
+                             bool check_result)
 {
        struct lsa_LookupNames3 r;
        struct lsa_TransSidArray3 sids;
@@ -404,6 +414,14 @@ static bool test_LookupNames3(struct dcerpc_pipe *p,
                return false;
        }
 
+       if (check_result) {
+               torture_assert_int_equal(tctx, count, sids.count,
+                       "unexpected number of results returned");
+               if (sids.count > 0) {
+                       torture_assert(tctx, sids.sids, "invalid sid buffer");
+               }
+       }
+
        printf("\n");
 
        return true;
@@ -411,7 +429,8 @@ static bool test_LookupNames3(struct dcerpc_pipe *p,
 
 static bool test_LookupNames4(struct dcerpc_pipe *p,
                              struct torture_context *tctx,
-                             struct lsa_TransNameArray2 *tnames)
+                             struct lsa_TransNameArray2 *tnames,
+                             bool check_result)
 {
        struct lsa_LookupNames4 r;
        struct lsa_TransSidArray3 sids;
@@ -448,6 +467,14 @@ static bool test_LookupNames4(struct dcerpc_pipe *p,
                return false;
        }
 
+       if (check_result) {
+               torture_assert_int_equal(tctx, count, sids.count,
+                       "unexpected number of results returned");
+               if (sids.count > 0) {
+                       torture_assert(tctx, sids.sids, "invalid sid buffer");
+               }
+       }
+
        printf("\n");
 
        return true;
@@ -530,11 +557,11 @@ static bool test_LookupSids2(struct dcerpc_pipe *p,
 
        printf("\n");
 
-       if (!test_LookupNames2(p, tctx, handle, &names)) {
+       if (!test_LookupNames2(p, tctx, handle, &names, false)) {
                return false;
        }
 
-       if (!test_LookupNames3(p, tctx, handle, &names)) {
+       if (!test_LookupNames3(p, tctx, handle, &names, false)) {
                return false;
        }
 
@@ -580,7 +607,7 @@ static bool test_LookupSids3(struct dcerpc_pipe *p,
 
        printf("\n");
 
-       if (!test_LookupNames4(p, tctx, &names)) {
+       if (!test_LookupNames4(p, tctx, &names, false)) {
                return false;
        }
 
@@ -668,7 +695,7 @@ bool test_many_LookupSids(struct dcerpc_pipe *p,
                               nt_errstr(status));
                        return false;
                }
-               if (!test_LookupNames4(p, tctx, &names)) {
+               if (!test_LookupNames4(p, tctx, &names, false)) {
                        return false;
                }
        }