Rev 11191: Use temporary locations rather than hard-coded ones. in file:///home/jelmer/bzr.samba-old/4.0-regwrite/

Jelmer Vernooij jelmer at samba.org
Wed Jun 13 17:37:23 GMT 2007


At file:///home/jelmer/bzr.samba-old/4.0-regwrite/

------------------------------------------------------------
revno: 11191
revision-id: jelmer at samba.org-20070613001344-qkqechdlu867mozv
parent: jelmer at samba.org-20070612234637-779h4pffu0ybx829
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-regwrite
timestamp: Wed 2007-06-13 02:13:44 +0200
message:
  Use temporary locations rather than hard-coded ones.
modified:
  source/lib/registry/tests/hive.c hive.c-20070612151642-hsxkm8j4r69ej3px-1
  source/torture/util.c          svn-v2:16518 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2ftorture%2futil.c
=== modified file 'source/lib/registry/tests/hive.c'
--- a/source/lib/registry/tests/hive.c	2007-06-12 23:11:37 +0000
+++ b/source/lib/registry/tests/hive.c	2007-06-13 00:13:44 +0000
@@ -25,6 +25,10 @@
 #include "lib/cmdline/popt_common.h"
 #include "torture/torture.h"
 #include "librpc/gen_ndr/winreg.h"
+#include "system/filesys.h"
+
+NTSTATUS torture_temp_dir(TALLOC_CTX *mem_ctx, const char *prefix, 
+								   const char **tempdir);
 
 static bool test_del_nonexistant_key(struct torture_context *tctx,
 									 const void *test_data)
@@ -93,8 +97,16 @@
 {
 	struct hive_key *key;
 	WERROR error;
-
-	error = reg_create_directory(tctx, "bla", &key);
+	const char *dirname;
+	NTSTATUS status;
+
+	status = torture_temp_dir(tctx, "hive-dir", &dirname);
+	if (!NT_STATUS_IS_OK(status))
+		return false;
+
+	rmdir(dirname);
+
+	error = reg_create_directory(tctx, dirname, &key);
 	if (!W_ERROR_IS_OK(error)) {
 		fprintf(stderr, "Unable to initialize dir hive\n");
 		return false;
@@ -109,8 +121,16 @@
 {
 	struct hive_key *key;
 	WERROR error;
-
-	error = reg_open_ldb_file(tctx, "bla-ldb", NULL, NULL, &key);
+	const char *dirname;
+	NTSTATUS status;
+
+	status = torture_temp_dir(tctx, "hive-ldb", &dirname);
+	if (!NT_STATUS_IS_OK(status))
+		return false;
+
+	rmdir(dirname);
+
+	error = reg_open_ldb_file(tctx, dirname, NULL, NULL, &key);
 	if (!W_ERROR_IS_OK(error)) {
 		fprintf(stderr, "Unable to initialize ldb hive\n");
 		return false;
@@ -125,8 +145,16 @@
 {
 	struct hive_key *key;
 	WERROR error;
-
-	error = reg_create_regf_file(tctx, "bla-regf", 5, &key);
+	const char *dirname;
+	NTSTATUS status;
+
+	status = torture_temp_dir(tctx, "hive-dir", &dirname);
+	if (!NT_STATUS_IS_OK(status))
+		return false;
+
+	rmdir(dirname);
+
+	error = reg_create_regf_file(tctx, dirname, 5, &key);
 	if (!W_ERROR_IS_OK(error)) {
 		fprintf(stderr, "Unable to create new regf file\n");
 		return false;

=== modified file 'source/torture/util.c'
--- a/source/torture/util.c	2007-04-17 00:30:01 +0000
+++ b/source/torture/util.c	2007-06-13 00:13:44 +0000
@@ -29,16 +29,22 @@
  create a temporary directory.
 */
 _PUBLIC_ NTSTATUS torture_temp_dir(TALLOC_CTX *mem_ctx, const char *prefix, 
-								   char **tempdir)
+								   const char **tempdir)
 {
 	const char *basedir = lp_parm_string(-1, "torture", "basedir");
-	if (basedir == NULL) basedir = ".";
-	*tempdir = talloc_asprintf(mem_ctx, "%s/%s.XXXXXX", 
+	char *path;
+
+	if (basedir == NULL) 
+		basedir = ".";
+
+	path = talloc_asprintf(mem_ctx, "%s/%s.XXXXXX", 
 							   basedir, prefix);
 
-	if (mkdtemp(*tempdir) == NULL)
+	if (mkdtemp(path) == NULL)
 		return NT_STATUS_UNSUCCESSFUL;
 
+	*tempdir = path;
+
 	return NT_STATUS_OK;
 }
 



More information about the samba-cvs mailing list