[SCM] Samba Shared Repository - branch master updated
Matthieu Patou
mat at samba.org
Mon Oct 11 08:30:01 MDT 2010
The branch, master has been updated
via 6633a7b unit tests: do some cleanup after tests
via 77cdef5 torture: Add debug on what we are removing
via 58294ff s4:smbtorture Create a new random output directory each time, and delete it
via 74ed86c lib/torture: Add function to clean up the output directory
from 13ba346 ldb The use of a private event context isn't a hack
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6633a7b37907373ebd93f5a1f5b297ec3d5e483d
Author: Matthieu Patou <mat at matws.net>
Date: Mon Oct 11 13:44:35 2010 +0400
unit tests: do some cleanup after tests
fix
Autobuild-User: Matthieu Patou <mat at samba.org>
Autobuild-Date: Mon Oct 11 14:29:10 UTC 2010 on sn-devel-104
commit 77cdef53595de4837046c5f5bf6ce47020998dee
Author: Matthieu Patou <mat at matws.net>
Date: Mon Oct 11 13:44:10 2010 +0400
torture: Add debug on what we are removing
commit 58294ffdee2066e3e051b6cb914f2708e6114089
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Jul 6 15:25:54 2010 +1000
s4:smbtorture Create a new random output directory each time, and delete it
This ensures we don't delete an exiting directory.
Andrew Bartlett
Signed-off-by: Matthieu Patou <mat at matws.net>
commit 74ed86c4e3d997a283e1ac03237ece9397242d81
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Jul 6 15:22:31 2010 +1000
lib/torture: Add function to clean up the output directory
This helps to avoid leaving 85MB of provision around for every
NET-API-BECOME-DC test.
Andrew Bartlett
Signed-off-by: Matthieu Patou <mat at matws.net>
-----------------------------------------------------------------------
Summary of changes:
lib/torture/torture.c | 67 +++++++++++++++++++++-
lib/torture/torture.h | 1 +
source4/setup/tests/blackbox_provision.sh | 7 ++
source4/setup/tests/blackbox_upgradeprovision.sh | 8 +++
source4/torture/smbtorture.c | 16 +++++-
5 files changed, 96 insertions(+), 3 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/torture/torture.c b/lib/torture/torture.c
index 74dfce1..9d77ab4 100644
--- a/lib/torture/torture.c
+++ b/lib/torture/torture.c
@@ -23,6 +23,7 @@
#include "../lib/util/dlinklist.h"
#include "param/param.h"
#include "system/filesys.h"
+#include "system/dir.h"
struct torture_results *torture_results_init(TALLOC_CTX *mem_ctx, const struct torture_ui_ops *ui_ops)
@@ -75,7 +76,7 @@ struct torture_context *torture_context_child(struct torture_context *parent)
}
/**
- create a temporary directory.
+ create a temporary directory under the output dir
*/
_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
const char *prefix, char **tempdir)
@@ -93,6 +94,70 @@ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
return NT_STATUS_OK;
}
+static int local_deltree(const char *path)
+{
+ int ret;
+ struct dirent *dirent;
+ DIR *dir = opendir(path);
+ if (!dir) {
+ char *error = talloc_asprintf(NULL, "Could not open directory %s", path);
+ perror(error);
+ talloc_free(error);
+ return -1;
+ }
+ while ((dirent = readdir(dir))) {
+ char *name;
+ if ((strcmp(dirent->d_name, ".") == 0) || (strcmp(dirent->d_name, "..") == 0)) {
+ continue;
+ }
+ name = talloc_asprintf(NULL, "%s/%s", path,
+ dirent->d_name);
+ if (name == NULL) {
+ closedir(dir);
+ return -1;
+ }
+ DEBUG(0, ("About to remove %s\n", name));
+ ret = remove(name);
+ if (ret == 0) {
+ talloc_free(name);
+ continue;
+ }
+
+ if (errno == ENOTEMPTY) {
+ ret = local_deltree(name);
+ if (ret == 0) {
+ ret = remove(name);
+ }
+ }
+ talloc_free(name);
+ if (ret != 0) {
+ char *error = talloc_asprintf(NULL, "Could not remove %s", path);
+ perror(error);
+ talloc_free(error);
+ break;
+ }
+ }
+ closedir(dir);
+ return ret;
+}
+
+_PUBLIC_ NTSTATUS torture_deltree_outputdir(struct torture_context *tctx)
+{
+ SMB_ASSERT(tctx->outputdir != NULL);
+ if ((strcmp(tctx->outputdir, "/") == 0)
+ || (strcmp(tctx->outputdir, "") == 0)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (local_deltree(tctx->outputdir) == -1) {
+ if (errno != 0) {
+ return map_nt_error_from_unix(errno);
+ }
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ return NT_STATUS_OK;
+}
+
/**
* Comment on the status/progress of a test
*/
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 01947e7..605ba34 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -488,6 +488,7 @@ unsigned long torture_setting_ulong(struct torture_context *test,
NTSTATUS torture_temp_dir(struct torture_context *tctx,
const char *prefix,
char **tempdir);
+NTSTATUS torture_deltree_outputdir(struct torture_context *tctx);
struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
const char *name,
diff --git a/source4/setup/tests/blackbox_provision.sh b/source4/setup/tests/blackbox_provision.sh
index 6b2c227..126905e 100755
--- a/source4/setup/tests/blackbox_provision.sh
+++ b/source4/setup/tests/blackbox_provision.sh
@@ -42,5 +42,12 @@ reprovision() {
}
testit "reprovision" reprovision
+rm -rf $PREFIX/simple-default
+rm -rf $PREFIX/simple-dc
+rm -rf $PREFIX/blank-dc
+rm -rf $PREFIX/simple-member
+rm -rf $PREFIX/simple-standalone
+rm -rf $PREFIX/partitions-only-dc
+rm -rf $PREFIX/reprovision
exit $failed
diff --git a/source4/setup/tests/blackbox_upgradeprovision.sh b/source4/setup/tests/blackbox_upgradeprovision.sh
index f32d71d..2d2325c 100755
--- a/source4/setup/tests/blackbox_upgradeprovision.sh
+++ b/source4/setup/tests/blackbox_upgradeprovision.sh
@@ -31,4 +31,12 @@ upgradeprovision_full() {
testit "upgradeprovision" upgradeprovision
testit "upgradeprovision_full" upgradeprovision_full
+if [ -d $PREFIX/upgradeprovision ]; then
+ rm -fr $PREFIX/upgradeprovision
+fi
+
+if [ -d $PREFIX/upgradeprovision_full ]; then
+ rm -fr $PREFIX/upgradeprovision_full
+fi
+
exit $failed
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 8989bdf..36b8c0f 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -404,6 +404,7 @@ int main(int argc,char *argv[])
int shell = false;
static const char *ui_ops_name = "subunit";
const char *basedir = NULL;
+ char *outputdir;
const char *extra_module = NULL;
static int list_tests = 0;
int num_extra_users = 0;
@@ -626,14 +627,22 @@ int main(int argc,char *argv[])
fprintf(stderr, "Please specify an absolute path to --basedir\n");
return 1;
}
- torture->outputdir = basedir;
+ outputdir = talloc_asprintf(torture, "%s/smbtortureXXXXXX", basedir);
} else {
char *pwd = talloc_size(torture, PATH_MAX);
if (!getcwd(pwd, PATH_MAX)) {
fprintf(stderr, "Unable to determine current working directory\n");
return 1;
}
- torture->outputdir = pwd;
+ outputdir = talloc_asprintf(torture, "%s/smbtortureXXXXXX", pwd);
+ }
+ if (!outputdir) {
+ fprintf(stderr, "Could not allocate per-run output dir\n");
+ return 1;
+ }
+ torture->outputdir = mkdtemp(outputdir);
+ if (!torture->outputdir) {
+ perror("Failed to make temp output dir");
}
torture->lp_ctx = cmdline_lp_ctx;
@@ -670,6 +679,9 @@ int main(int argc,char *argv[])
}
}
+ /* Now delete the temp dir we created */
+ torture_deltree_outputdir(torture);
+
if (torture->results->returncode && correct) {
return(0);
} else {
--
Samba Shared Repository
More information about the samba-cvs
mailing list