From patchwork Tue Mar 8 15:00:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lakshmipathi.G" X-Patchwork-Id: 8535101 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83A92C0553 for ; Tue, 8 Mar 2016 15:00:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 769F1200E7 for ; Tue, 8 Mar 2016 15:00:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FC11200DE for ; Tue, 8 Mar 2016 15:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752253AbcCHPAQ (ORCPT ); Tue, 8 Mar 2016 10:00:16 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35963 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751925AbcCHPAN (ORCPT ); Tue, 8 Mar 2016 10:00:13 -0500 Received: by mail-pa0-f50.google.com with SMTP id tt10so14271042pab.3 for ; Tue, 08 Mar 2016 07:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:date:to:cc:subject:mime-version:content-disposition :user-agent; bh=mbTxOsa+ckEJk+ohN6/k4JR6wLOvt1sboVgj5z10v0Y=; b=uqLJE2teiEpzrmAsuUiMTPTAqd4d6w9AkknG7tqeJiVdVGxQy82RECLOnihf7TnUX2 oSDl6IeAWi3pdr19Tnf7QO3LO+ej2oQ/+fZDctBaoDiFXAhTIweJSKWZJQHGUHZ55tj5 YNRQDDWNt7ieUnPdS3qLeUuQZ2M8m5sFSnutqoSUL+xiqNSOZ1D/dKva7FbU3LHbxCsV ahBsZ14bAXmgEYoyEWOsFMeKNLnQBQYMgst/LsaKgvFV/YLzxtE+qIiTntB08EZ7gu9D jhIfZHlFMsmY8cZRGeEzi2bh4Z5qBpbeKSQ01xAAh8Jpo95jA4kbBVzC4tDt6vQed9kD NG+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:date:to:cc:subject:mime-version :content-disposition:user-agent; bh=mbTxOsa+ckEJk+ohN6/k4JR6wLOvt1sboVgj5z10v0Y=; b=Jt4JeBRZYsulGj8JJX55/0TjaDFhshQJo+rnLzkV35b7ZxHMTs/ToWGg0UUuyDyBlQ 8YAIbjKyrOK9NwPZs3bJYxMXKDentBRvTssGdW5TjvzsKxKpU0eJ1WUbosBEgtXnPuqu jxwQY2UsMrcXdhr8X0FpTwFvCefErTFN2DrJXQ6u8JhTvI74q6AKfHd03WwrNSu9lIzK LPGVX8+zndv54pT8kh77WDIHq5PWzI95alXhjkkiSDNwLC8sPlAktoFnWJ+yJ/PBKM7X T7k3TH7HvOeiLPrx+OsQaRjPrmrI0xvXAClaY5BTsjKBTSCKjYcO2E5u+9HQuyLUZ8HK SZjw== X-Gm-Message-State: AD7BkJJTimt4Y6VfOXh8q1f5eemKdXDep45v8raMRPnYTaJF3o22/jlhxg/TAPtlFpxLow== X-Received: by 10.66.222.199 with SMTP id qo7mr42502053pac.38.1457449211884; Tue, 08 Mar 2016 07:00:11 -0800 (PST) Received: from . ([61.3.111.57]) by smtp.gmail.com with ESMTPSA id 23sm5678400pfs.34.2016.03.08.07.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2016 07:00:11 -0800 (PST) Message-ID: <56dee8fb.9712620a.c80b2.ffffbce5@mx.google.com> X-Google-Original-Message-ID: <20160308150006.GA31691@.> From: "Lakshmipathi.G" X-Google-Original-From: "Lakshmipathi.G" Date: Tue, 8 Mar 2016 20:30:06 +0530 To: linux-btrfs@vger.kernel.org Cc: lakshmipathi.g@giis.co.in Subject: [PATCH][btrfs-progs] populate fs with small dataset for convert-tests MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lakshmipathi.G --- tests/convert-tests.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh index 0bfb41f..c1f3de0 100644 --- a/tests/convert-tests.sh +++ b/tests/convert-tests.sh @@ -10,16 +10,91 @@ LANG=C SCRIPT_DIR=$(dirname $(readlink -f $0)) TOP=$(readlink -f $SCRIPT_DIR/../) RESULTS="$TOP/tests/convert-tests-results.txt" +DATASET_SIZE="50" # how many files to create. source $TOP/tests/common rm -f $RESULTS setup_root_helper -prepare_test_dev 256M +prepare_test_dev 512M CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX) +generate_dataset() { + + dataset_type="$1" + dirpath=$TEST_MNT/$dataset_type + mkdir -p $dirpath + + case $dataset_type in + small) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER dd if=/dev/urandom of=$dirpath/$dataset_type.$num bs=10K \ + count=1 1>/dev/null 2>&1 + done + ;; + + hardlink) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num + run_check $SUDO_HELPER ln $dirpath/$dataset_type.$num $dirpath/hlink.$num + done + ;; + + symlink) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num + run_check $SUDO_HELPER ln -s $dirpath/$dataset_type.$num $dirpath/slink.$num + done + ;; + + brokenlink) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER ln -s $dirpath/$dataset_type.$num $dirpath/blink.$num + done + ;; + + perm) + for modes in $(seq 1 7777);do + if [[ "$modes" == *9* ]] || [[ "$modes" == *8* ]] + then + continue; + else + run_check $SUDO_HELPER touch $dirpath/$dataset_type.$modes + run_check $SUDO_HELPER chmod $modes $dirpath/$dataset_type.$modes + fi + done + ;; + + sparse) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER dd if=/dev/urandom of=$dirpath/$dataset_type.$num bs=10K \ + count=1 1>/dev/null 2>&1 + run_check $SUDO_HELPER truncate -s 500K $dirpath/$dataset_type.$num + run_check $SUDO_HELPER dd if=/dev/urandom of=$dirpath/$dataset_type.$num bs=10K \ + oflag=append conv=notrunc count=1 1>/dev/null 2>&1 + run_check $SUDO_HELPER truncate -s 800K $dirpath/$dataset_type.$num + done + ;; + + acls) + for num in $(seq 1 $DATASET_SIZE);do + run_check $SUDO_HELPER touch $dirpath/$dataset_type.$num + run_check $SUDO_HELPER setfacl -m "u:root:x" $dirpath/$dataset_type.$num + run_check $SUDO_HELPER setfattr -n user.foo -v bar$num $dirpath/$dataset_type.$num + done + ;; + esac +} + +populate_fs() { + + for dataset_type in 'small' 'hardlink' 'symlink' 'brokenlink' 'perm' 'sparse' 'acls' ; do + generate_dataset "$dataset_type" + done +} + convert_test() { local features local nodesize @@ -39,15 +114,16 @@ convert_test() { # when test image is on NFS and would not be writable for root run_check truncate -s 0 $TEST_DEV # 256MB is the smallest acceptable btrfs image. - run_check truncate -s 256M $TEST_DEV + run_check truncate -s 512M $TEST_DEV run_check $* -F $TEST_DEV # create a file to check btrfs-convert can convert regular file # correct run_check_mount_test_dev + populate_fs; run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/test bs=$nodesize \ count=1 1>/dev/null 2>&1 - run_check_stdout md5sum $TEST_MNT/test > $CHECKSUMTMP + run_check_stdout find $TEST_MNT -type f ! -name 'image' -exec md5sum {} \+ > $CHECKSUMTMP run_check_umount_test_dev run_check $TOP/btrfs-convert ${features:+-O "$features"} -N "$nodesize" $TEST_DEV @@ -56,7 +132,7 @@ convert_test() { run_check_mount_test_dev run_check_stdout md5sum -c $CHECKSUMTMP | - grep -q 'OK' || _fail "file validation failed." + grep -q 'FAILED' && _fail "file validation failed." run_check_umount_test_dev }