svn commit: samba r24662 - in branches/4.0-regwrite: . source/lib/registry source/lib/registry/tests source/torture source/torture/local

jelmer at samba.org jelmer at samba.org
Sun Aug 26 11:35:44 GMT 2007


Author: jelmer
Date: 2007-08-26 11:35:41 +0000 (Sun, 26 Aug 2007)
New Revision: 24662

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24662

Log:
Some initial work on testing registry diffs.
Modified:
   branches/4.0-regwrite/
   branches/4.0-regwrite/source/lib/registry/tests/diff.c
   branches/4.0-regwrite/source/lib/registry/tests/generic.c
   branches/4.0-regwrite/source/lib/registry/tests/hive.c
   branches/4.0-regwrite/source/lib/registry/tests/registry.c
   branches/4.0-regwrite/source/lib/registry/util.c
   branches/4.0-regwrite/source/torture/local/config.mk
   branches/4.0-regwrite/source/torture/ui.h


Changeset:

Property changes on: branches/4.0-regwrite
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-regwrite/source/lib/registry/tests/diff.c
===================================================================
--- branches/4.0-regwrite/source/lib/registry/tests/diff.c	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/lib/registry/tests/diff.c	2007-08-26 11:35:41 UTC (rev 24662)
@@ -25,26 +25,81 @@
 #include "torture/torture.h"
 #include "librpc/gen_ndr/winreg.h"
 
+static bool test_generate_diff(struct torture_context *test)
+{
+	/* WERROR reg_generate_diff(struct registry_context *ctx1, 
+				  struct registry_context *ctx2, 
+				  const struct reg_diff_callbacks *callbacks,
+				  void *callback_data)
+				  */
+	return true;
+}
+
+
+static bool test_diff_load(struct torture_context *test)
+{
+	/* WERROR reg_diff_load(const char *filename, const struct reg_diff_callbacks *callbacks, void *callback_data) */
+
+	return true;
+}
+
+static bool test_diff_apply(struct torture_context *test)
+{
+	/*
+_PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx)
+	*/
+
+	return true;
+}
+
+static const char *added_key = NULL;
+
+static WERROR test_add_key (void *callback_data, const char *key_name)
+{
+	added_key = talloc_strdup(callback_data, key_name);
+
+	return WERR_OK;
+}
+
+static bool test_generate_diff_key_add(struct torture_context *test)
+{
+	struct reg_diff_callbacks cb;
+	struct registry_key rk;
+
+	return true;
+
+	ZERO_STRUCT(cb);
+
+	cb.add_key = test_add_key;
+
+	if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, test)))
+		return false;
+
+	torture_assert_str_equal(test, added_key, "bla", "key added");
+
+	return true;
+}
+
+static bool test_generate_diff_key_null(struct torture_context *test)
+{
+	struct reg_diff_callbacks cb;
+
+	ZERO_STRUCT(cb);
+
+	if (!W_ERROR_IS_OK(reg_generate_diff_key(NULL, NULL, "", &cb, NULL)))
+		return false;
+
+	return true;
+}
+
 struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx) 
 {
 	struct torture_suite *suite = torture_suite_create(mem_ctx, 
 													   "DIFF");
-	torture_suite_add_simple_test(suite, "str_regtype", test_str_regtype);
-	torture_suite_add_simple_test(suite, "reg_val_data_string dword", 
-								  test_reg_val_data_string_dword);
-	torture_suite_add_simple_test(suite, "reg_val_data_string sz", 
-								  test_reg_val_data_string_sz);
-	torture_suite_add_simple_test(suite, "reg_val_data_string binary", 
-								  test_reg_val_data_string_binary);
-	torture_suite_add_simple_test(suite, "reg_val_data_string empty", 
-								  test_reg_val_data_string_empty);
-	torture_suite_add_simple_test(suite, "reg_val_description", 
-								  test_reg_val_description);
-	torture_suite_add_simple_test(suite, "reg_val_description null", 
-								  test_reg_val_description_nullname);
-
-	torture_suite_add_suite(suite, torture_registry_hive(mem_ctx));
-	torture_suite_add_suite(suite, torture_registry_registry(mem_ctx));
-
+	torture_suite_add_simple_test(suite, "test_generate_diff_key_add", test_generate_diff_key_add);
+	torture_suite_add_simple_test(suite, "test_generate_diff_key_null", test_generate_diff_key_null);
+	torture_suite_add_simple_test(suite, "test_diff_apply", test_diff_apply);
+	torture_suite_add_simple_test(suite, "test_generate_diff", test_generate_diff);
+	torture_suite_add_simple_test(suite, "test_diff_load", test_diff_load);
 	return suite;
 }

Modified: branches/4.0-regwrite/source/lib/registry/tests/generic.c
===================================================================
--- branches/4.0-regwrite/source/lib/registry/tests/generic.c	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/lib/registry/tests/generic.c	2007-08-26 11:35:41 UTC (rev 24662)
@@ -27,6 +27,7 @@
 
 struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx);
 struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx);
+struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx);
 
 static bool test_str_regtype(struct torture_context *ctx)
 {
@@ -120,6 +121,7 @@
 
 	torture_suite_add_suite(suite, torture_registry_hive(mem_ctx));
 	torture_suite_add_suite(suite, torture_registry_registry(mem_ctx));
+	torture_suite_add_suite(suite, torture_registry_diff(mem_ctx));
 
 	return suite;
 }

Modified: branches/4.0-regwrite/source/lib/registry/tests/hive.c
===================================================================
--- branches/4.0-regwrite/source/lib/registry/tests/hive.c	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/lib/registry/tests/hive.c	2007-08-26 11:35:41 UTC (rev 24662)
@@ -27,7 +27,7 @@
 #include "librpc/gen_ndr/winreg.h"
 #include "system/filesys.h"
 
-NTSTATUS torture_temp_dir(TALLOC_CTX *mem_ctx, const char *prefix, 
+NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, 
 								   const char **tempdir);
 
 static bool test_del_nonexistant_key(struct torture_context *tctx,

Modified: branches/4.0-regwrite/source/lib/registry/tests/registry.c
===================================================================
--- branches/4.0-regwrite/source/lib/registry/tests/registry.c	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/lib/registry/tests/registry.c	2007-08-26 11:35:41 UTC (rev 24662)
@@ -27,7 +27,7 @@
 #include "librpc/gen_ndr/winreg.h"
 #include "system/filesys.h"
 
-NTSTATUS torture_temp_dir(TALLOC_CTX *mem_ctx, const char *prefix, 
+NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, 
 								   const char **tempdir);
 
 /**

Modified: branches/4.0-regwrite/source/lib/registry/util.c
===================================================================
--- branches/4.0-regwrite/source/lib/registry/util.c	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/lib/registry/util.c	2007-08-26 11:35:41 UTC (rev 24662)
@@ -170,7 +170,9 @@
 	}
 }
 
-static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, struct registry_key **parent, const char **name)
+static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx, 
+							 const char *path, struct registry_key **parent, 
+							 const char **name)
 {
 	char *parent_name;
 	WERROR error;

Modified: branches/4.0-regwrite/source/torture/local/config.mk
===================================================================
--- branches/4.0-regwrite/source/torture/local/config.mk	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/torture/local/config.mk	2007-08-26 11:35:41 UTC (rev 24662)
@@ -24,6 +24,7 @@
 		irpc.o \
 		../../lib/registry/tests/generic.o \
 		../../lib/registry/tests/hive.o \
+		../../lib/registry/tests/diff.o \
 		../../lib/registry/tests/registry.o \
 		resolve.o \
 		../../lib/util/tests/strlist.o \

Modified: branches/4.0-regwrite/source/torture/ui.h
===================================================================
--- branches/4.0-regwrite/source/torture/ui.h	2007-08-26 10:50:39 UTC (rev 24661)
+++ branches/4.0-regwrite/source/torture/ui.h	2007-08-26 11:35:41 UTC (rev 24662)
@@ -265,6 +265,20 @@
 	talloc_free(__got); \
 	} while(0)
 
+#define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\
+	do { const char *__got, *__expected = (expected); \
+	size_t __size; \
+	__got = file_load(filename, *size, torture_ctx); \
+	if (strcmp_safe(__got, __expected) != 0) { \
+		torture_result(torture_ctx, TORTURE_FAIL, \
+					   __location__": %s contained:\n%sExpected: %s%s\n", \
+					   __got, __expected, cmt); \
+		talloc_free(__got); \
+		return false; \
+	} \
+	talloc_free(__got); \
+	} while(0)
+
 #define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
 	do { int __got = (got), __expected = (expected); \
 	if (__got != __expected) { \



More information about the samba-cvs mailing list