Whamcloud - gitweb
LU-8847 tests: llapi_fid_test uses incorrect parameters 39/23939/2
authorSteve Guminski <stephenx.guminski@intel.com>
Thu, 24 Nov 2016 12:57:33 +0000 (07:57 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 17 Dec 2016 05:48:49 +0000 (05:48 +0000)
Several function calls in test12 were providing incorrect parameters.
The value "0600" was provided, in an attempt to create a file with
read/write access for the owner.  However, the parameters actually
represent the open flags, so the incorrect parameters were instead
requesting (O_EXCL | O_NOCTTY).

Since llapi_create_volatile_idx by default already uses
(O_RDWR | O_CREAT) and a mask of (S_IRUSR | S_IWUSR), there are no
further flags required.  For llapi_open_by_fid, only the minimum
O_RDONLY is required (the call should not attempt to create the
file).

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: I5a1c9a014ab19a1a6a1901e2a8a091d4d65548f6
Reviewed-on: https://review.whamcloud.com/23939
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/llapi_fid_test.c

index 574bf43..c0fe8c4 100644 (file)
@@ -279,7 +279,7 @@ static void test12(void)
        rc = mkdir(mainpath, 0);
        ASSERTF(rc == 0, "mkdir failed for '%s': %s",
                mainpath, strerror(errno));
-       fd = llapi_create_volatile_idx(mainpath, -1, 0600);
+       fd = llapi_create_volatile_idx(mainpath, -1, 0);
        ASSERTF(fd >= 0, "creat failed for '%s': %s",
                mainpath, strerror(errno));
 
@@ -288,7 +288,7 @@ static void test12(void)
                mainpath, strerror(-rc));
 
        /* No many ways to test, except to open by fid. */
-       fd2 = llapi_open_by_fid(mainpath, &fid, 0600);
+       fd2 = llapi_open_by_fid(mainpath, &fid, O_RDONLY);
        ASSERTF(fd2 >= 0, "llapi_open_by_fid for " DFID_NOBRACE ": %s",
                PFID(&fid), strerror(errno));
 
@@ -296,7 +296,7 @@ static void test12(void)
 
        /* Check the file can still be opened, since fd2 is not
         * closed. */
-       fd3 = llapi_open_by_fid(mainpath, &fid, 0600);
+       fd3 = llapi_open_by_fid(mainpath, &fid, O_RDONLY);
        ASSERTF(fd3 >= 0, "llapi_open_by_fid for " DFID_NOBRACE ": %s",
                PFID(&fid), strerror(errno));
 
@@ -304,7 +304,7 @@ static void test12(void)
        close(fd3);
 
        /* The volatile file is gone now. */
-       fd = llapi_open_by_fid(mainpath, &fid, 0600);
+       fd = llapi_open_by_fid(mainpath, &fid, O_RDONLY);
        ASSERTF(fd < 0, "llapi_open_by_fid for " DFID_NOBRACE ": %d",
                PFID(&fid), fd);
 }