From patchwork Mon Sep 18 07:35:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9955613 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 C44D460208 for ; Mon, 18 Sep 2017 07:36:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AB428B5F for ; Mon, 18 Sep 2017 07:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A971628BA0; Mon, 18 Sep 2017 07:36:15 +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.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 0585128B5F for ; Mon, 18 Sep 2017 07:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751912AbdIRHgN (ORCPT ); Mon, 18 Sep 2017 03:36:13 -0400 Received: from mout.gmx.net ([212.227.15.15]:65520 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbdIRHgJ (ORCPT ); Mon, 18 Sep 2017 03:36:09 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LqiJO-1dFoow0Q8w-00eHiy; Mon, 18 Sep 2017 09:36:04 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v3.1 11/14] btrfs-progs: tests/mkfs: Add basic test case for rootdir parameter Date: Mon, 18 Sep 2017 16:35:59 +0900 Message-Id: <20170918073559.6446-1-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170918072139.6300-12-quwenruo.btrfs@gmx.com> References: <20170918072139.6300-12-quwenruo.btrfs@gmx.com> X-Provags-ID: V03:K0:ThaOUe6Doate229V4d8MfKIuWZF894kOctMxwGPym+jn8sUcA55 8IXtk0kb3lx00hf4Kpwfn6mQ4aQK8YlsuDuli+6IkIpBDyYPLsnglhsTsO39OH2tKaRdB1G /MzQok3xVnakb+1r8tbsbuP//zmM3nfcwr8OyAYPqBI1RGQQOiJ8MYPTQDJzGCXzXfTvVDh 9Z9eFJncsCEsWvUI1Jemg== X-UI-Out-Filterresults: notjunk:1; V01:K0:UFT8pHs6/g4=:zujJAyVyFdZ3McoOIYdHCv /qhxQtbYGYdks2P32mcKZOfkezZWtbTAPK7m+zp+i6MI/62jqxzehmJ/7PR06wHP0ifYc4USi mE8I0vvYN5AsElUz8oIS/c5+2ethjTJJ1jDC8AW7ADpfqXfeepd5ibHWHqYhdlZhZ1Ax4rwQM vJwY/6H1Axx0v5xpzNhttS67YHdaI3qiHKa3pXOCQ9DkAIl8OvPHdXGwheuGxVf0t4LQwFPa6 L9ipQ0v3JiJwmU19WpI/GtdklQgqv4Qw+B4wQuI/0ebY2c9v4Sl2H6ZUMVhufin7alvGHJsqY Kznhm8EFNRNyZXJrSpbd+9X4d1xY9bRDAJxKRoC+oYjacDWZ1Bv0Ozg7Pe3R5Z8shXMsRl8FF 3AOLlS5sau2YqvpNh2t3Cra/NUeMQzyeWubwlCuyKivGcXbXxyoje9eQoZNIhfh0f4iQr9xG3 Wu6I8meTsNB0sb5+XDLl1MIaM50r8Zye4W2JzIxwwf6QHcjTUbUDPotgg7SH74wtA5ksButGY qEweUeMj1lMZmtMrFoxhfV+ssLLx098gsjJcyd9R3D/Tr4xwJXl5Iccg+Qbh1f6V6j7R5ZIff 7HE9h532xzI9PTMts36Eh1Lpmx7tJRIAOphbfmb9mT/H3U1kyFYWMIuoEj/HoJhAY+jQaOKPy leWuTCwbfw3pA+WDbTj4GIEu2p2QKRY41Thd48FHN5JKgKF5cn9giLnKsayeHP5Dno9MDYfpS Qtz1BRoQvBNzvAO7Fnm3kKKtzt1iSmYf6MKzGMF520t9gMtzconCD9Bg8YsolziYZwhU7jih4 vvhfQuXiqCxOeUCEv4zbmKGoQgDrg== 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 --- changelog: v3.1: Cleanup the temporary rootdir directory. --- tests/mkfs-tests/010-basic-rootdir/test.sh | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 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..49f9b860 --- /dev/null +++ b/tests/mkfs-tests/010-basic-rootdir/test.sh @@ -0,0 +1,79 @@ +#!/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" + run_check $SUDO_HELPER rm -rf -- "$src_dir" +} + +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