From patchwork Fri Jun 3 02:34:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9151505 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 AD2E260221 for ; Fri, 3 Jun 2016 02:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D4C42780C for ; Fri, 3 Jun 2016 02:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D11D2832D; Fri, 3 Jun 2016 02:34:45 +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 39D072780C for ; Fri, 3 Jun 2016 02:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750926AbcFCCek (ORCPT ); Thu, 2 Jun 2016 22:34:40 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:51467 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750916AbcFCCej (ORCPT ); Thu, 2 Jun 2016 22:34:39 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="592105" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 03 Jun 2016 10:34:34 +0800 Received: from adam-work.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id E79454056403; Fri, 3 Jun 2016 10:34:28 +0800 (CST) From: Qu Wenruo To: dsterba@suse.com, linux-btrfs@vger.kernel.org Subject: [PATCH v2 1/2] btrfs-progs: convert-tests: Add support for custom test scripts Date: Fri, 3 Jun 2016 10:34:25 +0800 Message-Id: <20160603023426.25216-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 X-yoursite-MailScanner-ID: E79454056403.AC18F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com 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 support for custom convert test scripts, just like fsck tests. Instead of generic convert tests, we need more specifically created images for new convert tests. This patch provide the needed infrastructure for later convert test cases. Signed-off-by: Qu Wenruo --- v2: Split test case with infrastructure --- tests/common | 8 ++++++++ tests/convert-tests.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/tests/common b/tests/common index 91682ef..fed9ede 100644 --- a/tests/common +++ b/tests/common @@ -94,6 +94,14 @@ check_prereq() fi } +check_global_prereq() +{ + which $1 &> /dev/null + if [ $? -ne 0 ]; then + _fail "Failed system wide prerequisities: $1"; + fi +} + check_image() { local image diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh index 06d8419..a02311d 100755 --- a/tests/convert-tests.sh +++ b/tests/convert-tests.sh @@ -15,6 +15,11 @@ DATASET_SIZE=50 source $TOP/tests/common +# Allow child test to use $TOP and $RESULTS +export TOP +export RESULTS +export LANG + rm -f $RESULTS setup_root_helper @@ -22,6 +27,25 @@ prepare_test_dev 512M CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX) +run_one_test() { + local testname + + testname="$1" + echo " [TEST/conv] $testname" + cd $testname + echo "=== Entering $testname" >> $RESULTS + if [ -x test.sh ]; then + # Difference convert test case needs different tools to restore + # and check image, so only support custom test scripts + ./test.sh + if [ $? -ne 0 ]; then + _fail "test failed for case $(basename $testname)" + fi + else + _fail "custom test script not found" + fi +} + generate_dataset() { dataset_type="$1" @@ -163,4 +187,11 @@ for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do convert_test "$feature" "ext4 64k nodesize" 65536 mke2fs -t ext4 -b 4096 done +# Test special images +for i in $(find $TOP/tests/convert-tests -maxdepth 1 -mindepth 1 -type d \ + ${TEST:+-name "$TEST"} | sort) +do + run_one_test "$i" +done + rm $CHECKSUMTMP