torture/smb2/dir: check create time match find
authorDavid Disseldorp <ddiss@samba.org>
Fri, 23 May 2014 17:11:59 +0000 (19:11 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 23 May 2014 20:42:24 +0000 (22:42 +0200)
This adds a check to ensure that the create time returned in the SMB2
create response matches the value found in the find response.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 23 22:42:24 CEST 2014 on sn-devel-104

source4/torture/smb2/dir.c

index 9cb85d7d57098ba5d3a073de4b885e78133bdd18..0e409f2b70af44201beedb65e3c4808285c0e348 100644 (file)
@@ -41,6 +41,7 @@
 
 struct file_elem {
        char *name;
+       NTTIME create_time;
        bool found;
 };
 
@@ -89,6 +90,7 @@ static NTSTATUS populate_tree(struct torture_context *tctx,
                    DNAME, files[i].name);
                status = smb2_create(tree, mem_ctx, &create);
                torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
+               files[i].create_time = create.out.create_time;
                smb2_util_close(tree, create.out.file.handle);
        }
  done:
@@ -130,17 +132,27 @@ static bool test_find(struct torture_context *tctx,
                for (i = 0; i < count; i++) {
                        bool expected;
                        const char *found = d[i].both_directory_info.name.s;
+                       NTTIME ctime = d[i].both_directory_info.create_time;
 
                        if (!strcmp(found, ".") || !strcmp(found, ".."))
                                continue;
 
                        expected = false;
                        for (j = 0; j < NFILES; j++) {
-                               if (!strcmp(files[j].name, found)) {
-                                       files[j].found = true;
-                                       expected = true;
-                                       break;
+                               if (strcmp(files[j].name, found) != 0) {
+                                       continue;
                                }
+
+                               if (files[j].create_time != ctime) {
+                                       torture_result(tctx, TORTURE_FAIL,
+                                           "(%s): create_time mismatch for %s"
+                                           "\n", __location__, found);
+                                       ret = false;
+                                       goto done;
+                               }
+                               files[j].found = true;
+                               expected = true;
+                               break;
                        }
 
                        if (expected)