summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-10-24 00:00:20 +0200
committerMichael Adam <obnox@samba.org>2008-10-27 13:02:40 +0100
commit9c09d545bfae9e4abde317364b1586b691ba4d89 (patch)
treea1f3ffb9d130b55a72c4dbc01ed47e96e4936384
parentb23106745c500e0e440eacd1bcd3250979df9db6 (diff)
downloadsamba-9c09d545bfae9e4abde317364b1586b691ba4d89.tar.gz
samba-9c09d545bfae9e4abde317364b1586b691ba4d89.tar.bz2
samba-9c09d545bfae9e4abde317364b1586b691ba4d89.zip
[s3]libsmbconf: create text config in smbconftort
Michael
-rw-r--r--source3/lib/smbconf/testsuite.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
index cffd239df6..100fbe8440 100644
--- a/source3/lib/smbconf/testsuite.c
+++ b/source3/lib/smbconf/testsuite.c
@@ -173,17 +173,46 @@ done:
return ret;
}
+static bool create_conf_file(const char *filename)
+{
+ FILE *f;
+
+ printf("creating file\n");
+ f = sys_fopen(filename, "w");
+ if (!f) {
+ printf("failure: failed to open %s for writing: %s\n",
+ filename, strerror(errno));
+ return false;
+ }
+
+ fprintf(f, "[global]\n");
+ fprintf(f, "\tserver string = smbconf testsuite\n");
+ fprintf(f, "\tworkgroup = SAMBA\n");
+ fprintf(f, "\tsecurity = user\n");
+
+ fclose(f);
+
+ printf("success: create file\n");
+ return true;
+}
+
static bool torture_smbconf_txt(void)
{
WERROR werr;
bool ret = true;
+ const char *filename = "/tmp/smb.conf.smbconf_testsuite";
struct smbconf_ctx *conf_ctx = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
printf("test: text backend\n");
+ if (!create_conf_file(filename)) {
+ ret = false;
+ goto done;
+ }
+
printf("test: init\n");
- werr = smbconf_init_txt(mem_ctx, &conf_ctx, NULL);
+ werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
if (!W_ERROR_IS_OK(werr)) {
printf("failure: init failed: %s\n", dos_errstr(werr));
ret = false;
@@ -195,6 +224,14 @@ static bool torture_smbconf_txt(void)
smbconf_shutdown(conf_ctx);
+ printf("unlinking file\n");
+ if (unlink(filename) != 0) {
+ printf("failure: unlink failed: %s\n", strerror(errno));
+ ret = false;
+ goto done;
+ }
+ printf("success: unlink file\n");
+
printf("%s: text backend\n", ret ? "success" : "failure");
done: