Whamcloud - gitweb
LU-11490 tests: fix rr_alloc() test to use FSNAME
[fs/lustre-release.git] / lustre / tests / llapi_layout_test.c
index 805d235..385b886 100644 (file)
@@ -20,6 +20,9 @@
  * GPL HEADER END
  */
 /*
+ * Copyright (c) 2016, 2017, Intel Corporation.
+ */
+/*
  * These tests exercise the llapi_layout API which abstracts the layout
  * of a Lustre file behind an opaque data type.  They assume a Lustre
  * file system with at least 2 OSTs and a pool containing at least the
@@ -200,7 +203,7 @@ void test3(void)
 {
        int rc;
        struct llapi_layout *layout;
-       lustre_fid fid;
+       struct lu_fid fid;
        char fidstr[4096];
        char path[PATH_MAX];
 
@@ -709,7 +712,9 @@ void test16(void)
 
        rc = llapi_layout_stripe_count_get(filelayout, &fcount);
        ASSERTF(rc == 0, "errno = %d", errno);
-       ASSERTF(fcount == dcount, "%"PRIu64" != %"PRIu64, fcount, dcount);
+       ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
+               dcount == LLAPI_LAYOUT_WIDE,
+               "%"PRIu64" != %"PRIu64, fcount, dcount);
 
        rc = llapi_layout_stripe_size_get(filelayout, &fsize);
        ASSERTF(rc == 0, "errno = %d", errno);
@@ -730,7 +735,9 @@ void test16(void)
        ASSERTF(rc == 0, "errno = %d", errno);
        rc = llapi_layout_stripe_size_get(filelayout, &fsize);
        ASSERTF(rc == 0, "errno = %d", errno);
-       ASSERTF(fcount == dcount, "%"PRIu64" != %"PRIu64, fcount, dcount);
+       ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
+               dcount == LLAPI_LAYOUT_WIDE,
+               "%"PRIu64" != %"PRIu64, fcount, dcount);
        ASSERTF(fsize == dsize, "%"PRIu64" != %"PRIu64, fsize, dsize);
 
        llapi_layout_free(filelayout);
@@ -888,7 +895,9 @@ void test20(void)
        ASSERTF(rc == 0, "errno = %d", errno);
        rc = llapi_layout_stripe_count_get(deflayout, &dcount);
        ASSERTF(rc == 0, "errno = %d", errno);
-       ASSERTF(fcount == dcount, "%"PRIu64" != %"PRIu64, fcount, dcount);
+       ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
+               dcount == LLAPI_LAYOUT_WIDE,
+               "%"PRIu64" != %"PRIu64, fcount, dcount);
 
        rc = llapi_layout_stripe_size_get(filelayout, &fsize);
        ASSERTF(rc == 0, "errno = %d", errno);
@@ -1483,13 +1492,28 @@ void test31(void)
                i++;
        } while (rc == 0);
 
+       /* Verify reverse iteration gives the same IDs as forward iteration */
+       rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_LAST);
+       ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
+       do {
+               __u32 comp_id;
+
+               --i;
+               rc = llapi_layout_comp_id_get(layout, &comp_id);
+               ASSERTF(rc == 0 && comp_id == id[i],
+                       "i %d, errno %d, id[] %u/%u", i, errno, id[i], comp_id);
+
+               rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_PREV);
+               ASSERTF(rc == 0 || i == 0, "i=%d rc=%d errno=%d", i, rc, errno);
+       } while (rc == 0);
+
        llapi_layout_free(layout);
 
        /* delete non-tail component will fail */
-       rc = llapi_layout_file_comp_del(path, id[0]);
+       rc = llapi_layout_file_comp_del(path, id[0], 0);
        ASSERTF(rc < 0 && errno == EINVAL, "rc %d, errno %d", rc, errno);
 
-       rc = llapi_layout_file_comp_del(path, id[1]);
+       rc = llapi_layout_file_comp_del(path, id[1], 0);
        ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
 
        /* verify the composite layout after deleting */