From: Ralph Boehme Date: Sun, 10 May 2015 09:58:32 +0000 (+0200) Subject: s4:torture:vfs_fruit: add a test for stream names X-Git-Tag: talloc-2.1.4~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7258061e5e9cd4b68f1c010c3667c3fd2b0663cc;p=thirdparty%2Fsamba.git s4:torture:vfs_fruit: add a test for stream names Bug: https://bugzilla.samba.org/show_bug.cgi?id=11278 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 7ceb4fa5b55..4638b16caf5 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1466,7 +1466,8 @@ sub provision($$$$$$$$) [vfs_fruit] path = $shrdir - vfs objects = catia fruit streams_xattr + vfs objects = catia fruit streams_xattr acl_xattr + ea support = yes fruit:ressource = file fruit:metadata = netatalk fruit:locking = netatalk diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 8e7ac944c7d..16d4b28b947 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -1070,7 +1070,8 @@ sub provision($$$$$$$$$$) [vfs_fruit] path = $ctx->{share} - vfs objects = catia fruit streams_xattr + vfs objects = catia fruit streams_xattr acl_xattr + ea support = yes fruit:ressource = file fruit:metadata = netatalk fruit:locking = netatalk diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index 87102bed8df..a74dd7d2425 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -29,6 +29,7 @@ #include "param/param.h" #include "libcli/resolve/resolve.h" #include "MacExtensions.h" +#include "lib/util/tsort.h" #include "torture/torture.h" #include "torture/util.h" @@ -58,6 +59,16 @@ goto done; \ }} while (0) +static int qsort_string(char * const *s1, char * const *s2) +{ + return strcmp(*s1, *s2); +} + +static int qsort_stream(const struct stream_struct * s1, const struct stream_struct *s2) +{ + return strcmp(s1->stream_name.s, s2->stream_name.s); +} + /* * REVIEW: * This is hokey, but what else can we do? @@ -2165,6 +2176,133 @@ done: return true; } +static bool check_stream_list(struct smb2_tree *tree, + struct torture_context *tctx, + const char *fname, + int num_exp, + const char **exp, + struct smb2_handle h) +{ + union smb_fileinfo finfo; + NTSTATUS status; + int i; + TALLOC_CTX *tmp_ctx = talloc_new(tctx); + char **exp_sort; + struct stream_struct *stream_sort; + + finfo.generic.level = RAW_FILEINFO_STREAM_INFORMATION; + finfo.generic.in.file.handle = h; + + status = smb2_getinfo_file(tree, tctx, &finfo); + torture_assert_ntstatus_ok(tctx, status, "get stream info"); + + torture_assert_int_equal(tctx, finfo.stream_info.out.num_streams, num_exp, + "stream count"); + + if (num_exp == 0) { + TALLOC_FREE(tmp_ctx); + return true; + } + + exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp)); + torture_assert(tctx, exp_sort != NULL, __location__); + + TYPESAFE_QSORT(exp_sort, num_exp, qsort_string); + + stream_sort = talloc_memdup(tmp_ctx, finfo.stream_info.out.streams, + finfo.stream_info.out.num_streams * + sizeof(*stream_sort)); + torture_assert(tctx, stream_sort != NULL, __location__); + + TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream); + + for (i=0; i