From patchwork Tue Sep 5 05:53:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 9937859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C56B1600CB for ; Tue, 5 Sep 2017 05:53:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3812203C0 for ; Tue, 5 Sep 2017 05:53:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FE028889; Tue, 5 Sep 2017 05:53: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=-6.9 required=2.0 tests=BAYES_00,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 1EB53203C0 for ; Tue, 5 Sep 2017 05:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750789AbdIEFx3 (ORCPT ); Tue, 5 Sep 2017 01:53:29 -0400 Received: from mgwym04.jp.fujitsu.com ([211.128.242.43]:16632 "EHLO mgwym04.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdIEFx3 (ORCPT ); Tue, 5 Sep 2017 01:53:29 -0400 Received: from yt-mxauth.gw.nic.fujitsu.com (unknown [192.168.229.68]) by mgwym04.jp.fujitsu.com with smtp id 03c2_1613_ca202507_c0f5_4935_adb9_fc2d88baac38; Tue, 05 Sep 2017 14:53:21 +0900 Received: from g01jpfmpwyt03.exch.g01.fujitsu.local (g01jpfmpwyt03.exch.g01.fujitsu.local [10.128.193.57]) by yt-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id D8F0FAC00B7 for ; Tue, 5 Sep 2017 14:53:21 +0900 (JST) Received: from g01jpexchyt35.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt03.exch.g01.fujitsu.local (Postfix) with ESMTP id 2D4A546E784; Tue, 5 Sep 2017 14:53:21 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: 6b502383ef8f44b493cc58300f1b08d0 From: "Misono, Tomohiro" Subject: [PATCH] btrfs-progs: test: add new test for inspect-internal rootid To: CC: Message-ID: Date: Tue, 5 Sep 2017 14:53:15 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This new test checks inspect-internal rootid - handle path to subvolume/directory/file as an argument - get different id for each subvolume - get the expected id for each file/directory (i.e. the same as containing subvolume) Signed-off-by: Tomohiro Misono --- .../cli-tests/007-inspect-internal-rootid/test.sh | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 tests/cli-tests/007-inspect-internal-rootid/test.sh diff --git a/tests/cli-tests/007-inspect-internal-rootid/test.sh b/tests/cli-tests/007-inspect-internal-rootid/test.sh new file mode 100755 index 0000000..a7105c7 --- /dev/null +++ b/tests/cli-tests/007-inspect-internal-rootid/test.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# test commands of inspect-internal rootid + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +prepare_test_dev 2g + +run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV" +run_check_mount_test_dev +run_check $SUDO_HELPER chmod a+rw $TEST_MNT +cd $TEST_MNT + +run_check "$TOP/btrfs" subvolume create sub +run_check "$TOP/btrfs" subvolume create sub/subsub +run_check mkdir dir +run_check touch file1 +run_check touch dir/file2 +run_check touch sub/file3 + +id1=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid .) || exit +id2=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub) || exit +id3=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/subsub) || exit +id4=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir) || exit +id5=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid file1) || exit +id6=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir/file2) || exit +id7=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/file3) || exit + +if ! ([ $id1 -ne $id2 ] && [ $id1 -ne $id3 ] && [ $id2 -ne $id3 ]); then + _fail "inspect-internal rootid: each subvolume must have different id" +fi + +if ! ([ $id1 -eq $id4 ] && [ $id1 -eq $id5 ] && [ $id1 -eq $id6 ]); then + _fail "inspect-internal rootid: rootid mismatch found" +fi + +if ! ([ $id2 -eq $id7 ]); then + _fail "inspect-internal rootid: rootid mismatch found" +fi + +run_mustfail "should fail for non exist file" \ + "$TOP/btrfs" inspect-internal rootid no_such_file +run_mustfail "should fail for non btrfs filesystem" \ + "$TOP/btrfs" inspect-internal rootid /dev/null + +cd .. +run_check_umount_test_dev