From patchwork Wed Oct 18 02:00:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10013331 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 4AFB7602B3 for ; Wed, 18 Oct 2017 02:01:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CCD128A88 for ; Wed, 18 Oct 2017 02:01:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31BAB28A8B; Wed, 18 Oct 2017 02:01:08 +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 D111B28A88 for ; Wed, 18 Oct 2017 02:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932757AbdJRCBD (ORCPT ); Tue, 17 Oct 2017 22:01:03 -0400 Received: from mgwym04.jp.fujitsu.com ([211.128.242.43]:28547 "EHLO mgwym04.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932530AbdJRCBD (ORCPT ); Tue, 17 Oct 2017 22:01:03 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym04.jp.fujitsu.com with smtp id 2c33_9dde_d025f039_6553_4cec_a39e_ea7fdba97da6; Wed, 18 Oct 2017 11:01:01 +0900 Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 279F0AC00A7 for ; Wed, 18 Oct 2017 11:01:00 +0900 (JST) Received: from g01jpexchyt37.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id 671C56D6768; Wed, 18 Oct 2017 11:00:59 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: d0dc77d0815f40cbb8afb28358682253 To: linux-btrfs CC: From: "Misono, Tomohiro" Subject: [PATCH] btrfs-progs: test: add new cli-test for subvol get/set-default Message-ID: Date: Wed, 18 Oct 2017 11:00:43 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.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 Add new test to check functionality of subvol get/set-default. Signed-off-by: Tomohiro Misono --- .../008-subvolume-get-set-default/test.sh | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tests/cli-tests/008-subvolume-get-set-default/test.sh diff --git a/tests/cli-tests/008-subvolume-get-set-default/test.sh b/tests/cli-tests/008-subvolume-get-set-default/test.sh new file mode 100755 index 0000000..5ea473b --- /dev/null +++ b/tests/cli-tests/008-subvolume-get-set-default/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# test for "subvolume get-default/set-default" + +check_default_id() +{ + id=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" sub get-def .) \ + || { echo "$id"; exit 1; } + if $(echo "$id" | grep -vq "ID $1"); then + _fail "subvolume get-default: default id is not $1, but $id" + fi +} + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev 2g + +run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV" +run_check_mount_test_dev +cd "$TEST_MNT" + +check_default_id 5 + +# check "subvol set-default " +run_check "$TOP/btrfs" subvol create sub +run_check $SUDO_HELPER "$TOP/btrfs" subvol set-default 257 . +check_default_id 257 + +run_mustfail "set-default to non existent id" \ + $SUDO_HELPER "$TOP/btrfs" subvol set-default 100 . + +# check "subvol set-default " +run_check "$TOP/btrfs" subvol create sub2 +run_check $SUDO_HELPER "$TOP/btrfs" subvol set-default ./sub2 +check_default_id 258 + +run_check mkdir sub2/dir +run_mustfail "set-default to normal directory" \ + $SUDO_HELPER "$TOP/btrfs" subvol set-default ./sub2/dir + +cd .. +run_check_umount_test_dev