[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Aug 29 19:29:02 UTC 2018


The branch, master has been updated
       via  7a7d95f s4:torture: Add a test for listing shares
       via  30ee1d3 selftest: Schedule libsmbclient tests against ad_dc
       via  81f4971 s4:torture: Improve torture_libsmbclient_init_context()
      from  825d67f autobuild: Avoid subshell for tail -f invocation

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7a7d95fc2c2f65f5c1268229595a523627eac96c
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Aug 27 15:59:59 2018 +0200

    s4:torture: Add a test for listing shares
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Aug 29 21:28:41 CEST 2018 on sn-devel-144

commit 30ee1d3dad611610adfbb60669d723adcaad0db5
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Aug 23 14:12:43 2018 +0200

    selftest: Schedule libsmbclient tests against ad_dc
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 81f4971fc9a0cd597fcfaf5285170447a6482808
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Aug 23 14:00:29 2018 +0200

    s4:torture: Improve torture_libsmbclient_init_context()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/selftest/tests.py                   | 19 ++++---
 source4/selftest/tests.py                   | 16 ++++--
 source4/torture/libsmbclient/libsmbclient.c | 82 +++++++++++++++++++++++++++--
 3 files changed, 102 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index ed241f0..3b67352 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -431,7 +431,10 @@ unix = ["unix.info2", "unix.whoami"]
 
 nbt = ["nbt.dgram"]
 
-libsmbclient = ["libsmbclient"]
+libsmbclient = ["libsmbclient.version", "libsmbclient.initialize",
+		"libsmbclient.configuration", "libsmbclient.setConfiguration",
+		"libsmbclient.options", "libsmbclient.opendir",
+		"libsmbclient.list_shares", "libsmbclient.readdirplus"]
 
 vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id", "vfs.fruit_timemachine"]
 
@@ -579,13 +582,17 @@ for t in tests:
     elif t == "rpc.samba3.netlogon" or t == "rpc.samba3.sessionkey":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
-    elif t == "libsmbclient":
+    elif t.startswith("libsmbclient"):
+	url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp"
+	if t == "libsmbclient.list_shares":
+		url = "smb://$USERNAME:$PASSWORD@$SERVER"
+
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%%$PASSWORD '
-                                    '--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp '
-                                    '--option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf"))
+                                    '--option=torture:smburl=' + url +
+                                    ' --option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf"))
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%%$PASSWORD '
-                                    '--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp '
-                                    '--option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf"))
+                                    '--option=torture:smburl=' + url +
+                                    ' --option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf"))
     elif t == "smb2.streams":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index f884d27..eb85fec 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -322,12 +322,18 @@ base = smbtorture4_testsuites("base.")
 
 netapi = smbtorture4_testsuites("netapi.")
 
-libsmbclient = smbtorture4_testsuites("libsmbclient.")
-libsmbclient_testargs = ["--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp",
-                         "--option=torture:replace_smbconf=%s/testdata/samba3/smb_new.conf" % srcdir()]
+for t in base + raw + smb2 + netapi:
+    plansmbtorture4testsuite(t, "ad_dc_ntvfs", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + ntvfsargs)
 
-for t in base + raw + smb2 + netapi + libsmbclient:
-    plansmbtorture4testsuite(t, "ad_dc_ntvfs", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + ntvfsargs + libsmbclient_testargs)
+libsmbclient = smbtorture4_testsuites("libsmbclient.")
+for t in libsmbclient:
+    url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp"
+    if t == "libsmbclient.list_shares":
+        url = "smb://$USERNAME:$PASSWORD@$SERVER"
+
+    libsmbclient_testargs = ["--option=torture:smburl=" + url,
+                             "--option=torture:replace_smbconf=%s/testdata/samba3/smb_new.conf" % srcdir()]
+    plansmbtorture4testsuite(t, "ad_dc", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + libsmbclient_testargs)
 
 plansmbtorture4testsuite("raw.qfileinfo.ipc", "ad_dc_ntvfs", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
 
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c
index e84ce01..fb27ddd 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -43,11 +43,23 @@ static void debug_callback(void *private_ptr, int level, const char *msg)
 bool torture_libsmbclient_init_context(struct torture_context *tctx,
 				       SMBCCTX **ctx_p)
 {
-	SMBCCTX *ctx;
+	SMBCCTX *ctx = NULL;
+	SMBCCTX *p = NULL;
+	bool ok = true;
 
 	ctx = smbc_new_context();
-	torture_assert(tctx, ctx, "failed to get new context");
-	torture_assert(tctx, smbc_init_context(ctx), "failed to init context");
+	torture_assert_not_null_goto(tctx,
+				     ctx,
+				     ok,
+				     out,
+				     "Failed to create new context");
+
+	p = smbc_init_context(ctx);
+	torture_assert_not_null_goto(tctx,
+				     p,
+				     ok,
+				     out,
+				     "Failed to initialize context");
 
 	smbc_setDebug(ctx, DEBUGLEVEL);
 	smbc_setOptionDebugToStderr(ctx, 1);
@@ -57,7 +69,12 @@ bool torture_libsmbclient_init_context(struct torture_context *tctx,
 
 	*ctx_p = ctx;
 
-	return true;
+out:
+	if (!ok) {
+		smbc_free_context(ctx, 1);
+	}
+
+	return ok;
 }
 
 static bool torture_libsmbclient_version(struct torture_context *tctx)
@@ -505,6 +522,62 @@ done:
 	return ok;
 }
 
+static bool torture_libsmbclient_list_shares(struct torture_context *tctx)
+{
+	const char *smburl = torture_setting_string(tctx, "smburl", NULL);
+	struct smbc_dirent *dirent = NULL;
+	SMBCCTX *ctx = NULL;
+	int dhandle = -1;
+	bool ipc_share_found = false;
+	bool ok = true;
+
+	if (smburl == NULL) {
+		torture_fail(tctx,
+			     "option --option=torture:smburl="
+			     "smb://user:password@server missing\n");
+	}
+
+	ok = torture_libsmbclient_init_context(tctx, &ctx);
+	torture_assert_goto(tctx,
+			    ok,
+			    ok,
+			    out,
+			    "Failed to init context");
+	smbc_set_context(ctx);
+
+	torture_comment(tctx, "Listing: %s\n", smburl);
+	dhandle = smbc_opendir(smburl);
+	torture_assert_int_not_equal_goto(tctx,
+					  dhandle,
+					  -1,
+					  ok,
+					  out,
+					  "Failed to open smburl");
+
+	while((dirent = smbc_readdir(dhandle)) != NULL) {
+		torture_comment(tctx, "DIR: %s\n", dirent->name);
+		torture_assert_not_null_goto(tctx,
+					     dirent->name,
+					     ok,
+					     out,
+					     "Failed to read name");
+
+		if (strequal(dirent->name, "IPC$")) {
+			ipc_share_found = true;
+		}
+	}
+
+	torture_assert_goto(tctx,
+			    ipc_share_found,
+			    ok,
+			    out,
+			    "Failed to list IPC$ share");
+
+out:
+	smbc_closedir(dhandle);
+	return ok;
+}
+
 NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
@@ -517,6 +590,7 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
 	torture_suite_add_simple_test(suite, "setConfiguration", torture_libsmbclient_setConfiguration);
 	torture_suite_add_simple_test(suite, "options", torture_libsmbclient_options);
 	torture_suite_add_simple_test(suite, "opendir", torture_libsmbclient_opendir);
+	torture_suite_add_simple_test(suite, "list_shares", torture_libsmbclient_list_shares);
 	torture_suite_add_simple_test(suite, "readdirplus",
 		torture_libsmbclient_readdirplus);
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list