[PATCH v3 6/6] torture: add LOCAL-sid_to_string testcase

Jeff Layton jlayton at samba.org
Wed Jul 31 08:38:23 MDT 2013


Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
 source3/selftest/tests.py |  1 +
 source3/torture/torture.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 3fc6684..afab687 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -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",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 25561e2..b0b498f 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -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},
-- 
1.8.3.1



More information about the samba-technical mailing list