]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-torture: Add a test for ndr_syntax_id_from_string()
authorSamuel Cabrero <scabrero@samba.org>
Thu, 28 Jan 2021 12:14:49 +0000 (13:14 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 28 Jan 2021 16:58:35 +0000 (16:58 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/torture/ndr/ndr.c

index dd2cad15e299de3789b4257205b8284801d4b9ca..f73c6feda6c2961bd3ff943a5eab93059f72b978 100644 (file)
@@ -720,6 +720,32 @@ static bool test_compare_uuid(struct torture_context *tctx)
        return true;
 }
 
+static bool test_syntax_id_from_string(struct torture_context *tctx)
+{
+       struct ndr_syntax_id s, exp;
+       const char *id = "00000001-0002-0003-0405-060708090a0b/0x12345678";
+
+       exp.uuid.time_low = 1;
+       exp.uuid.time_mid = 2;
+       exp.uuid.time_hi_and_version = 3;
+       exp.uuid.clock_seq[0] = 4;
+       exp.uuid.clock_seq[1] = 5;
+       exp.uuid.node[0] = 6;
+       exp.uuid.node[1] = 7;
+       exp.uuid.node[2] = 8;
+       exp.uuid.node[3] = 9;
+       exp.uuid.node[4] = 10;
+       exp.uuid.node[5] = 11;
+       exp.if_version = 0x12345678;
+
+       torture_assert(tctx,
+                      ndr_syntax_id_from_string(id, &s),
+                      "invalid return code");
+       torture_assert(tctx, ndr_syntax_id_equal(&s, &exp),
+                      "NDR syntax id parsed incorrectly");
+       return true;
+}
+
 struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx)
 {
        struct torture_suite *suite = torture_suite_create(mem_ctx, "ndr");
@@ -786,6 +812,9 @@ struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx)
        torture_suite_add_simple_test(suite, "guid_into_long_blob",
                                      test_guid_into_long_blob);
 
+       torture_suite_add_simple_test(suite, "syntax_id_from_string",
+                                     test_syntax_id_from_string);
+
        return suite;
 }