From patchwork Mon Jun 18 08:41:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10470175 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 25F36600CC for ; Mon, 18 Jun 2018 08:40:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1949528996 for ; Mon, 18 Jun 2018 08:40:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 182AF2899B; Mon, 18 Jun 2018 08:40:46 +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=-7.9 required=2.0 tests=BAYES_00,LOTS_OF_MONEY, 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 96346289AD for ; Mon, 18 Jun 2018 08:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030430AbeFRIiX (ORCPT ); Mon, 18 Jun 2018 04:38:23 -0400 Received: from mgwkm04.jp.fujitsu.com ([202.219.69.171]:63763 "EHLO mgwkm04.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968206AbeFRIiR (ORCPT ); Mon, 18 Jun 2018 04:38:17 -0400 Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [192.168.231.133]) by mgwkm04.jp.fujitsu.com with smtp id 78b7_4202_7519a9a7_1a9a_46b3_b6f3_2ad1ac97c35c; Mon, 18 Jun 2018 17:38:12 +0900 Received: from g01jpfmpwkw03.exch.g01.fujitsu.local (g01jpfmpwkw03.exch.g01.fujitsu.local [10.0.193.57]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 1E6B2AC0101 for ; Mon, 18 Jun 2018 17:38:12 +0900 (JST) Received: from g01jpexchkw33.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw03.exch.g01.fujitsu.local (Postfix) with ESMTP id 5F84ABD65F4 for ; Mon, 18 Jun 2018 17:38:11 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchkw33.g01.fujitsu.local (10.0.193.36) with Microsoft SMTP Server id 14.3.352.0; Mon, 18 Jun 2018 17:38:09 +0900 From: Misono Tomohiro To: Subject: [PATCH v2 20/20] btrfs-progs: test: Add cli-test/010 to check "subvolume list -f" option Date: Mon, 18 Jun 2018 17:41:08 +0900 Message-ID: X-Mailer: git-send-email 2.14.4 In-Reply-To: References: MIME-Version: 1.0 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 Signed-off-by: Misono Tomohiro --- tests/cli-tests/010-subvolume-list-follow/test.sh | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 tests/cli-tests/010-subvolume-list-follow/test.sh diff --git a/tests/cli-tests/010-subvolume-list-follow/test.sh b/tests/cli-tests/010-subvolume-list-follow/test.sh new file mode 100755 index 00000000..8fb746c6 --- /dev/null +++ b/tests/cli-tests/010-subvolume-list-follow/test.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# test for "subvolume list -f" + +source "$TEST_TOP/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +setup_loopdevs 2 +prepare_loopdevs +dev1=${loopdevs[1]} +dev2=${loopdevs[2]} + +# test if the ids returned by "sub list" match expected ids +# $1 ... option for subvolume list +# $2 ... PATH to be specified by sub list command +# $3~ ... expected return ids +test_list() +{ + result=$(run_check_stdout $SUDO "$TOP/btrfs" subvolume list $1 "$2" | \ + awk '{print $2}' | xargs | sort -n) + + shift + shift + expected=($(echo "$@" | tr " " "\n" | sort -n)) + expected=$(IFS=" "; echo "${expected[*]}") + + if [ "$result" != "$expected" ]; then + echo "result : $result" + echo "expected: $expected" + _fail "ids returned by sub list does not match expected ids" + fi +} + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev1" +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev2" + +run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT" +cd "$TEST_MNT" + +# Create some subvolumes and directories +# (id 5) +# |- AAA (id 256) +# | |- top +# | |- bbb +# | -- ccc +# | +# |- BBB (id 258) +# -- CCC (id 259) +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create AAA +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create BBB +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create CCC +run_check $SUDO_HELPER mkdir AAA/top +run_check $SUDO_HELPER mkdir AAA/bbb +run_check $SUDO_HELPER mkdir AAA/ccc + +test_list "" "." "256 258 259" +test_list "-f" "." "256 258 259" +cd .. +run_check $SUDO_HELPER umount "$TEST_MNT" + +# Mount as follows: +# +# "TEST_MNT" (AAA) +# |- top (FS_TREE) +# | |- AAA +# | |- BBB +# | -- CCC +# | +# |- bbb (BBB) +# -- ccc (CCC) +run_check $SUDO_HELPER mount -o subvol=AAA "$dev1" "$TEST_MNT" +run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT/top" +run_check $SUDO_HELPER mount -o subvol=BBB "$dev1" "$TEST_MNT/bbb" +run_check $SUDO_HELPER mount -o subvol=CCC "$dev1" "$TEST_MNT/ccc" + +cd "$TEST_MNT" +test_list "" "." "256" +# With -f option, subvolume AAA/BBB/CCC will be counted twice. +# Also, it will list FS_TREE (5) if it is mounted below the specified path. +test_list "-f" "." "5 256 256 258 258 259 259" + +cd .. +run_check $SUDO_HELPER umount -R "$TEST_MNT" +cleanup_loopdevs