From e528677e1630093362394ae36d725c321d0da4f2 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 9 Feb 2018 09:00:13 -0600 Subject: [PATCH] LU-10443 test: Handle file lifecycle correctly 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 Reviewed-on: https://review.whamcloud.com/31254 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Nunez Reviewed-by: Wei Liu Reviewed-by: Oleg Drokin --- lustre/tests/lockahead_test.c | 12 +++++++----- lustre/tests/sanity.sh | 9 ++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lustre/tests/lockahead_test.c b/lustre/tests/lockahead_test.c index 7e05e31..07ce3ab 100644 --- a/lustre/tests/lockahead_test.c +++ b/lustre/tests/lockahead_test.c @@ -70,12 +70,11 @@ 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); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7a30605..683c60e 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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" -- 1.8.3.1