torture: add LOCAL-sid_to_string testcase
authorJeff Layton <jlayton@samba.org>
Wed, 31 Jul 2013 14:38:23 +0000 (10:38 -0400)
committerJeremy Allison <jra@samba.org>
Wed, 31 Jul 2013 22:16:18 +0000 (15:16 -0700)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/selftest/tests.py
source3/torture/torture.c

index 3fc66846653dd471cdb9b5ebda0ce1f70b58c784..afab6872a0f1f9500ffff098252768bf86fc1244 100755 (executable)
@@ -99,6 +99,7 @@ local_tests = [
     "LOCAL-STREAM-NAME",
     "LOCAL-WBCLIENT",
     "LOCAL-string_to_sid",
+    "LOCAL-sid_to_string",
     "LOCAL-binary_to_sid",
     "LOCAL-DBTRANS",
     "LOCAL-TEVENT-SELECT",
index 25561e230d38c97d942116a34d51561ee48389a7..b0b498f1fe844fdbe5e28240315f55d1ee5c9bd8 100644 (file)
@@ -8497,6 +8497,35 @@ static bool run_local_string_to_sid(int dummy) {
        return true;
 }
 
+static bool sid_to_string_test(char *expected) {
+       char *str;
+       bool res = true;
+       struct dom_sid sid;
+
+       if (!string_to_sid(&sid, expected)) {
+               printf("could not parse %s\n", expected);
+               return false;
+       }
+
+       str = dom_sid_string(NULL, &sid);
+       if (strcmp(str, expected)) {
+               printf("Comparison failed (%s != %s)\n", str, expected);
+               res = false;
+       }
+       TALLOC_FREE(str);
+       return res;
+}
+
+static bool run_local_sid_to_string(int dummy) {
+       if (!sid_to_string_test("S-1-0xffffffffffff-1-1-1-1-1-1-1-1-1-1-1-1"))
+               return false;
+       if (!sid_to_string_test("S-1-545"))
+               return false;
+       if (!sid_to_string_test("S-255-3840-1-1-1-1"))
+               return false;
+       return true;
+}
+
 static bool run_local_binary_to_sid(int dummy) {
        struct dom_sid *sid = talloc(NULL, struct dom_sid);
        static const char good_binary_sid[] = {
@@ -9538,6 +9567,7 @@ static struct {
        { "LOCAL-STREAM-NAME", run_local_stream_name, 0},
        { "LOCAL-WBCLIENT", run_local_wbclient, 0},
        { "LOCAL-string_to_sid", run_local_string_to_sid, 0},
+       { "LOCAL-sid_to_string", run_local_sid_to_string, 0},
        { "LOCAL-binary_to_sid", run_local_binary_to_sid, 0},
        { "LOCAL-DBTRANS", run_local_dbtrans, 0},
        { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},