From patchwork Mon Sep 18 07:21:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9955595 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 22D5460385 for ; Mon, 18 Sep 2017 07:22:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A6528A50 for ; Mon, 18 Sep 2017 07:22:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08C5328AEF; Mon, 18 Sep 2017 07:22:11 +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,FREEMAIL_FROM, 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 3668628BAF for ; Mon, 18 Sep 2017 07:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752498AbdIRHWF (ORCPT ); Mon, 18 Sep 2017 03:22:05 -0400 Received: from mout.gmx.net ([212.227.17.21]:50219 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbdIRHWD (ORCPT ); Mon, 18 Sep 2017 03:22:03 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lfppu-1d4nJK3ySQ-00pORo; Mon, 18 Sep 2017 09:22:01 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v3 11/14] btrfs-progs: tests/mkfs: Add basic test case for rootdir parameter Date: Mon, 18 Sep 2017 16:21:36 +0900 Message-Id: <20170918072139.6300-12-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170918072139.6300-1-quwenruo.btrfs@gmx.com> References: <20170918072139.6300-1-quwenruo.btrfs@gmx.com> X-Provags-ID: V03:K0:1OR5cMgONodW4fx3+vdg+M0jLGOMSJ5yJ2hkrPCyr3uZSlVLjbl QH/Kq/7a8fGiQF46tSKzhMlz3WqrdChYFmxaGhax0O23Zbt+8rV3GxE417I2mEE/D1j/+tJ JpZGk2HeIDbm24ltwUHnXtkS7+7NCAU7ktGJJMwFr2oti2++1f3EB6uBveqjAxHN7YYQDbR PQIScLbqZKTDPtpBbLqGA== X-UI-Out-Filterresults: notjunk:1; V01:K0:K//9AmMRdHU=:4nLhFrlB2yqwyjTDyp+rHI x4R6sY8wumoVXzkPNzGQfAuHkMg6UaI3AUbjRWWqBqQMOdBIXGZD4k13xBIwys26iJxNTcuzT Y0sc1pF8MLMFXm/pH6/QUPBE+4g24iish7tq92PxVZrVqPA0fbjj/zxs8UCtRxWIED1BW3LpD VpX8kVq5qM3iRqX60mTuweI+Sfvrcm0PDi3IHtKToXY1hTJ2VU23Tucak5tKplLKapMxkytDY L63EhR17fDPIQBFdPFtFSdOS6s4QWdeeAPcOPi8cb3CYzGBrgDAz8oythdrj5r/KhdnaLNnbW aNPj5s59KXEWvnaaF4FGmFkmacYv9jbKj+1iupdV7lQInq9kLvXKtvZRVgq5yck+BOfOSF1wk UduqgTBIdkyDFvzN4qFZrGlAzChiO55bVYD85E63qFTl+jKZdvrqjJXr5Zm66FByiRQM6dBJn jHEobVoXObRoGgUPCglJuPna0QgNzkTJ4GO/ELp3vi+IKtkrBPiV+s4+gMt+47lJAf5TcuiOY zgU3XnSv3LJp6S2bZdMAv/7n7PylM8fTi+jds622IVd0BTnljULC0teHG5vz+sOyCXzJNPd/r iYKXJ98+M7YI7HA9zZ+jKDObWMwkWc8UwjPevL33RNFdwm6rut3xMYIrz8atgaLRyHlB4i26l 2vtDUfsLm/wkiYBwZqTSqEd6Lp3Fn+tuCsuN53gT9D2zA1KwFSIqAsVWh9rZkiaUYb5I+AvNM CvAImyzGqVLfrlT+sxdOmdXLNcbcDgoUah0jGuKd0M7xz3z9IaEerDfZbTz2tbP/jRzP1qEaB sHV/Oq3QFiB8FNwJqvDD2nY7znAtA== 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 a new test case to check if "--rootdir" option of mkfs.btrfs can handle the file content, perrmission and xattr correctly. The new test case reuses the convert facility, and looks just like convert-tests/001-ext2-basic. Signed-off-by: Qu Wenruo --- tests/mkfs-tests/010-basic-rootdir/test.sh | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 tests/mkfs-tests/010-basic-rootdir/test.sh diff --git a/tests/mkfs-tests/010-basic-rootdir/test.sh b/tests/mkfs-tests/010-basic-rootdir/test.sh new file mode 100755 index 00000000..6ff3e1af --- /dev/null +++ b/tests/mkfs-tests/010-basic-rootdir/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Check basic operations for "mkfs.btrfs --rootdir", including: +# 1) Checksum, permission and acl +# Should be consistent with source directory +# 2) Failure condition +# 2.1) Non-existent file/block as destination +# 2.2) Too small destination file +# 2.3) No privilege to read source directory +# All failure condition should fail, but without segfault/backtrace + +source "$TOP/tests/common" +source "$TOP/tests/common.convert" + +setup_root_helper +prepare_test_dev 512M +check_prereq mkfs.btrfs +check_global_prereq dd +check_global_prereq sed + +# Since our test dir will be in /tmp, which is nowadays tmpfs for most +# distributions, and tmpfs xattr doesn't support user xattr, here we +# use a special populate_fs() which won't create user xattr. +# +# Don't worry, both acl and user xattr is implemented by xattr in btrfs, +# so "acls" should cover the case. +populate_tmpfs() { + _assert_path "$1" + + for dataset_type in 'small' 'hardlink' 'fast_symlink' 'brokenlink' 'perm' 'sparse' 'acls' 'fifo' 'slow_symlink'; do + generate_dataset "$dataset_type" "$1" + done +} + +# Basic content checker for difference nodesize/features +content_test() { + local features + local nodesize + local src_dir + local csum_tmp + local perm_tmp + local acl_tmp + + features="$1" + nodesize="$2" + src_dir=$(mktemp --tmpdir --directory btrfs-progs-mkfs-rootdir.XXXXXXX) + + echo " [TEST/mkfs_rootdir] nodesize=$nodesize" "${features:-defaults}" + echo "creating test dir at $src_dir" >> "$RESULTS" + + populate_tmpfs "$src_dir" + csum_tmp=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX) + perm_tmp=$(mktemp --tmpdir btrfs-progs-convert.permXXXXXX) + acl_tmp=$(mktemp --tmpdir btrfs-progs-convert.aclsXXXXXXX) + convert_test_gen_checksums "$csum_tmp" "$src_dir" + convert_test_perm "$perm_tmp" "$src_dir" + convert_test_acl "$acl_tmp" "$src_dir" + + run_check "$TOP/mkfs.btrfs" ${1:+-O "$1"} ${2:+-n "$2"} \ + "--rootdir" "$src_dir" "$TEST_DEV" + run_check "$TOP/btrfs" check "$TEST_DEV" + run_check_mount_test_dev + convert_test_post_check_checksums "$csum_tmp" + convert_test_post_check_permissions "$perm_tmp" + convert_test_post_check_acl "$acl_tmp" + run_check_umount_test_dev + + rm -- "$csum_tmp" + rm -- "$perm_tmp" + rm -- "$acl_tmp" +} + +for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do + content_test "$feature" 4096 + content_test "$feature" 8192 + content_test "$feature" 16384 + content_test "$feature" 32768 + content_test "$feature" 65536 +done