Whamcloud - gitweb
LU-10443 test: Handle file lifecycle correctly 54/31254/2
authorPatrick Farrell <paf@cray.com>
Fri, 9 Feb 2018 15:00:13 +0000 (09:00 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 22 Feb 2018 05:40:54 +0000 (05:40 +0000)
The current lockahead_test.c removes the test file on exit,
which will destroy the locks which sanity.sh counts to
verify correct operation.  This usually works because
sanity.sh wins the race with the object destroy command
from the MDS to the OSS.

Change lockahead_test.c to remove the test file on entry,
and to use $tfile rather than its own file, so it is
automatically cleaned up by sanity.

Change-Id: I3cd1fdb7f33da167ca21476a7b3cbe5f57fd5782
Signed-off-by: Patrick Farrell <paf@cray.com>
Reviewed-on: https://review.whamcloud.com/31254
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Wei Liu <wei3.liu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/lockahead_test.c
lustre/tests/sanity.sh

index 7e05e31..07ce3ab 100644 (file)
                rc = testfn();                                          \
                fprintf(stderr, "Finishing test " #testfn " at %lld\n", \
                        (unsigned long long)time(NULL));                \
-               cleanup();                                              \
        } while (0)
 
 /* Name of file/directory. Will be set once and will not change. */
 static char mainpath[PATH_MAX];
-static const char *mainfile = "lockahead_test_654";
+static char *mainfile;
 
 static char fsmountdir[PATH_MAX];      /* Lustre mountpoint */
 static char *lustre_dir;               /* Test directory inside Lustre */
@@ -1088,8 +1087,11 @@ static void process_args(int argc, char *argv[])
 {
        int c;
 
-       while ((c = getopt(argc, argv, "d:t:")) != -1) {
+       while ((c = getopt(argc, argv, "d:f:t:")) != -1) {
                switch (c) {
+               case 'f':
+                       mainfile = optarg;
+                       break;
                case 'd':
                        lustre_dir = optarg;
                        break;
@@ -1113,6 +1115,8 @@ int main(int argc, char *argv[])
        process_args(argc, argv);
        if (lustre_dir == NULL)
                lustre_dir = "/mnt/lustre";
+       if (mainfile == NULL)
+               mainfile = "lockahead_test_654";
 
        rc = llapi_search_mounts(lustre_dir, 0, fsmountdir, fsname);
        if (rc != 0) {
@@ -1131,8 +1135,6 @@ int main(int argc, char *argv[])
        ASSERTF(rc > 0 && rc < sizeof(mainpath), "invalid name for mainpath");
        cleanup();
 
-       atexit(cleanup);
-
        switch (single_test) {
        case 0:
                PERFORM(test10);
index 7a30605..683c60e 100755 (executable)
@@ -15775,7 +15775,7 @@ test_255c() {
 
        #test 10 returns only success/failure
        i=10
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15787,7 +15787,7 @@ test_255c() {
                $LCTL get_param -n ost.OSS.ost.stats)
        count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
 
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15813,7 +15813,7 @@ test_255c() {
                count=$($LCTL get_param -n \
                       ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
 
-               lockahead_test -d $DIR/$tdir -t $i
+               lockahead_test -d $DIR/$tdir -t $i -f $tfile
                rc=$?
                if [ $rc -eq 255 ]; then
                        error "Ladvise test ${i} failed, ${rc}"
@@ -15836,12 +15836,11 @@ test_255c() {
 
        #test 22 returns only success/failure
        i=22
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
        fi
-
 }
 run_test 255c "suite of ladvise lockahead tests"