From patchwork Mon Oct 15 20:29:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10642453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57C6815E2 for ; Mon, 15 Oct 2018 20:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479662A08D for ; Mon, 15 Oct 2018 20:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 386542A08F; Mon, 15 Oct 2018 20:29:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 594622A08D for ; Mon, 15 Oct 2018 20:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbeJPEQU (ORCPT ); Tue, 16 Oct 2018 00:16:20 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37384 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbeJPEQU (ORCPT ); Tue, 16 Oct 2018 00:16:20 -0400 Received: by mail-wm1-f68.google.com with SMTP id 185-v6so21031528wmt.2; Mon, 15 Oct 2018 13:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k+EF2VsWkLmYuzru0mwoZb3mrM7SXoHOMJnp02pvtn0=; b=Sh3a5FH8Kvqd/wxmaqo9R4aaHqxynNgt8r7sZldH+F0ZwX8lK8m6kXawAQli1N0Faw /u7lethcFn9OokORvYcVoNrYezkPcob/9MHN76Y0ugGz8lAV3xSyA8bGNZejR1JXn4ZF kYCMhOvFTZ0TvJ1To3wXmkv001AjqED2N1A1NkCAIZh4C9ugIBwVKqG+RkDi8Ftxxol+ c/QdKs/0T0cSZ68A0q1+EiooVW3+TvVZnFbFcN9gCPdRQF/Cws+1/Xt0aL2CcZvplzH8 7lhKkOsKTLnp8Rrvlrd8sSOxTv4T3KOsSyqJ9vJEqGIQfLXJmMfjbc110MIvs/5otfV1 crCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k+EF2VsWkLmYuzru0mwoZb3mrM7SXoHOMJnp02pvtn0=; b=CxkvewqV08MLGchS5ZWIWqg8F6Vxi1DvqbD3jR8LLHpEBVoFqP0bBJfpFln0CWJk2t cshQZF0e966bfr1mYjwcVkFi+13+AE4bZtCBxu0t4WYOTxNPiSBgPuwjfEnzE9OS9zEo 8uz+Pmu8fcVqeHi4FFerA1EP9GiHNMJRc9uL47223tD+JK4TpSCTCv9HSphNxSXw5esz T+X1AOWGeIEh+BQcFqRDu5fYBgK8a0cDBAKZwiM1iXUf3D0KzpI3CthQVE2seqpAWHEc GFhkxnvtNXc6mdFl5l1bL//YcPEnjmLTN3wNh6idvKU1G5omoJIkevEcKhzVhnIvYsHD lHJA== X-Gm-Message-State: ABuFfohMcrB4+/sD7G3ahLpz+sk09VS5s6fwFtoESVg1Idl9zRlRRCHh 4J2qOzpK5pJzeamvx32Sw+Y= X-Google-Smtp-Source: ACcGV63QT9v34nNnY8PumZLrsbmla9bQGB3Q0LwVRTZF6LAM2qBqsBbl3ktCpoJdPsf0ldC8HcHtew== X-Received: by 2002:a1c:1fc2:: with SMTP id f185-v6mr13636776wmf.18.1539635367593; Mon, 15 Oct 2018 13:29:27 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id b5-v6sm8722505wrr.94.2018.10.15.13.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 13:29:26 -0700 (PDT) From: Amir Goldstein To: zhangyi Cc: Eryu Guan , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] overlay: check expected fsck.overlay exit codes Date: Mon, 15 Oct 2018 23:29:19 +0300 Message-Id: <20181015202919.23679-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The latest version of fsck.overlay now conforms to e2fsck exit codes. Adjust the tests to correctly check the expected exit codes. Signed-off-by: Amir Goldstein --- Zhangyi, With fsck.overlay from your master branch all the -g overlay/fsck test fail. Please confirm that this patch correctly describes expected behavior. The test overlay/045 still fails on "fsck should be happy" assertions. Does fsck.overlay actually fixes anything in those cases? or is not returning FSCK_OK an oversight? Thanks, Amir. tests/overlay/045 | 35 +++++++++++++++++++---------------- tests/overlay/046 | 46 ++++++++++++++++++++++++---------------------- tests/overlay/056 | 12 ++++++------ 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/tests/overlay/045 b/tests/overlay/045 index acc70871..4d06f7a1 100755 --- a/tests/overlay/045 +++ b/tests/overlay/045 @@ -96,8 +96,8 @@ echo "+ Orphan whiteout" make_test_dirs make_whiteout $lowerdir/foo $upperdir/{foo,bar} -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" ls $lowerdir ls $upperdir @@ -108,7 +108,8 @@ touch $lowerdir2/{foo,bar} make_whiteout $upperdir/foo $lowerdir/bar _overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" + $seqres.full 2>&1 +[ $? = 0 ] || echo "fsck should be happy" check_whiteout $upperdir/foo $lowerdir/bar # Test orphan whiteout in opaque directory, should remove @@ -119,8 +120,8 @@ touch $lowerdir/testdir/foo make_opaque_dir $upperdir/testdir make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" ls $upperdir/testdir # Test orphan whiteout whose parent path is not an merged directory, @@ -136,7 +137,8 @@ make_opaque_dir $lowerdir/testdir3 make_whiteout $upperdir/{testdir1/foo,/testdir2/foo,testdir3/foo,testdir4/foo} _overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" + $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" ls $upperdir/testdir1 ls $upperdir/testdir2 ls $upperdir/testdir3 @@ -150,8 +152,8 @@ touch $lowerdir/testdir/foo make_redirect_dir $upperdir/testdir "origin" make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" ls $upperdir/testdir # Test valid whiteout in redirect directory cover file in lower @@ -163,8 +165,8 @@ touch $lowerdir/origin/foo make_redirect_dir $upperdir/testdir "origin" make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 0 ] || echo "fsck should be happy" check_whiteout $upperdir/testdir/foo # Test valid whiteout covering lower target whose parent directory @@ -177,8 +179,9 @@ make_redirect_dir $lowerdir/testdir "origin" mkdir -p $upperdir/testdir/subdir make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p \ - >> $seqres.full 2>&1 || echo "fsck should not fail" +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ + $seqres.full 2>&1 +[ $? = 0 ] || echo "fsck should be happy" check_whiteout $upperdir/testdir/subdir/foo # Test invalid whiteout in opaque subdirectory in a redirect directory, @@ -191,8 +194,8 @@ make_redirect_dir $upperdir/testdir "origin" make_opaque_dir $upperdir/testdir/subdir make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" ls $upperdir/testdir/subdir # Test valid whiteout in reidrect subdirectory in a opaque directory @@ -205,8 +208,8 @@ make_opaque_dir $upperdir/testdir make_redirect_dir $upperdir/testdir/subdir "/origin" make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 0 ] || echo "fsck should be happy" check_whiteout $upperdir/testdir/subdir/foo # success, all done diff --git a/tests/overlay/046 b/tests/overlay/046 index 6338a383..d4dc0977 100755 --- a/tests/overlay/046 +++ b/tests/overlay/046 @@ -121,8 +121,8 @@ echo "+ Invalid redirect" make_test_dirs make_redirect_dir $upperdir/testdir "invalid" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_no_redirect $upperdir/testdir # Test invalid redirect xattr point to a file origin, should remove @@ -131,8 +131,8 @@ make_test_dirs touch $lowerdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_no_redirect $upperdir/testdir # Test valid redirect xattr point to a directory origin in the same directory, @@ -143,8 +143,8 @@ mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_redirect $upperdir/testdir "origin" # Test valid redirect xattr point to a directory origin in different directories @@ -155,8 +155,8 @@ mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir1/testdir2 "/origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_redirect $upperdir/testdir1/testdir2 "/origin" # Test valid redirect xattr but missing whiteout to cover lower target, @@ -166,8 +166,8 @@ make_test_dirs mkdir $lowerdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_redirect $upperdir/testdir "origin" check_whiteout $upperdir/origin @@ -178,8 +178,8 @@ mkdir $lowerdir/{testdir1,testdir2} make_redirect_dir $upperdir/testdir1 "testdir2" make_redirect_dir $upperdir/testdir2 "testdir1" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_redirect $upperdir/testdir1 "testdir2" check_redirect $upperdir/testdir2 "testdir1" @@ -191,8 +191,8 @@ mkdir $lowerdir/testdir make_redirect_dir $upperdir/testdir "invalid" # Question get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_no_redirect $upperdir/testdir check_opaque $upperdir/testdir @@ -206,11 +206,13 @@ make_redirect_dir $lowerdir/testdir2 "origin" make_redirect_dir $upperdir/testdir3 "origin" _overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 && echo "fsck should fail" + $seqres.full 2>&1 +[ $? = 4 ] || echo "fsck should fail to correct errors" # Question get yes answer: Duplicate redirect directory, remove xattr ? _overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -y >> \ - $seqres.full 2>&1 || echo "fsck should not fail" + $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" redirect_1=`check_redirect $lowerdir/testdir1 "origin" 2>/dev/null` redirect_2=`check_redirect $lowerdir/testdir2 "origin" 2>/dev/null` [[ $redirect_1 == $redirect_2 ]] && echo "Redirect xattr incorrect" @@ -223,12 +225,12 @@ make_test_dirs mkdir $lowerdir/origin $upperdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 && \ - echo "fsck should fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 4 ] || echo "fsck should fail to correct errors" # Question get yes answer: Duplicate redirect directory, remove xattr ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_no_redirect $upperdir/testdir # Test duplicate redirect xattr with lower same name directory exists, @@ -240,8 +242,8 @@ make_redirect_dir $upperdir/testdir "invalid" # Question one get yes answer: Duplicate redirect directory, remove xattr? # Question two get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_no_redirect $upperdir/testdir check_opaque $upperdir/testdir diff --git a/tests/overlay/056 b/tests/overlay/056 index 44ffb54a..9fccaaea 100755 --- a/tests/overlay/056 +++ b/tests/overlay/056 @@ -96,8 +96,8 @@ $UMOUNT_PROG $SCRATCH_MNT remove_impure $upperdir/testdir1 remove_impure $upperdir/testdir2 -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_impure $upperdir/testdir1 check_impure $upperdir/testdir2 @@ -108,8 +108,8 @@ make_test_dirs mkdir $lowerdir/origin make_redirect_dir $upperdir/testdir/subdir "/origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_impure $upperdir/testdir # Test missing impure xattr in directory which has merge directories, @@ -118,8 +118,8 @@ echo "+ Missing impure(3)" make_test_dirs mkdir $lowerdir/testdir $upperdir/testdir -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 +[ $? = 1 ] || echo "fsck should correct errors" check_impure $upperdir # success, all done