From patchwork Sat Jan 21 08:10:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9530115 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 99E5D600CA for ; Sat, 21 Jan 2017 08:10:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8600C2842E for ; Sat, 21 Jan 2017 08:10:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 780E628698; Sat, 21 Jan 2017 08:10:58 +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, UNPARSEABLE_RELAY 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 C92792842E for ; Sat, 21 Jan 2017 08:10:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750982AbdAUIK5 (ORCPT ); Sat, 21 Jan 2017 03:10:57 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:20802 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbdAUIK5 (ORCPT ); Sat, 21 Jan 2017 03:10:57 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0L8Ass8018519 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 08:10:54 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v0L8AsAs002929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 08:10:54 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v0L8ArGK027369; Sat, 21 Jan 2017 08:10:54 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 21 Jan 2017 00:10:53 -0800 Subject: [PATCH 5/9] common/fuzzy: move fuzzing helper functions here From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Sat, 21 Jan 2017 00:10:50 -0800 Message-ID: <148498625060.17109.11461581002141350060.stgit@birch.djwong.org> In-Reply-To: <148498621936.17109.4249711513404036449.stgit@birch.djwong.org> References: <148498621936.17109.4249711513404036449.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move some fuzzing helper functions into a new common/fuzzy file. We'll add a lot more fuzzing helpers in subsequent patches. Signed-off-by: Darrick J. Wong --- common/fuzzy | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/populate | 35 ------------------------ tests/ext4/006 | 1 + tests/xfs/083 | 1 + 4 files changed, 82 insertions(+), 35 deletions(-) create mode 100644 common/fuzzy -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/common/fuzzy b/common/fuzzy new file mode 100644 index 0000000..d4f8274 --- /dev/null +++ b/common/fuzzy @@ -0,0 +1,80 @@ +##/bin/bash + +# Routines for fuzzing and scrubbing a filesystem. +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Oracle. All Rights Reserved. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +#----------------------------------------------------------------------- + +# Modify various files after a fuzzing operation +_scratch_fuzz_modify() { + nr="$1" + + test -z "${nr}" && nr=50000 + echo "+++ touch ${nr} files" + blk_sz=$(stat -f -c '%s' ${SCRATCH_MNT}) + $XFS_IO_PROG -f -c "pwrite -S 0x63 0 ${blk_sz}" "/tmp/afile" > /dev/null + date="$(date)" + find "${SCRATCH_MNT}/" -type f 2> /dev/null | head -n "${nr}" | while read f; do + setfattr -n "user.date" -v "${date}" "$f" + cat "/tmp/afile" >> "$f" + mv "$f" "$f.longer" + done + sync + rm -rf "/tmp/afile" + + echo "+++ create files" + mkdir -p "${SCRATCH_MNT}/test.moo" + $XFS_IO_PROG -f -c 'pwrite -S 0x80 0 65536' "${SCRATCH_MNT}/test.moo/urk" + sync + + echo "+++ remove files" + rm -rf "${SCRATCH_MNT}/test.moo" +} + +# Try to access files after fuzzing +_scratch_fuzz_test() { + echo "+++ ls -laR" >> $seqres.full + ls -laR "${SCRATCH_MNT}/test.1/" >/dev/null 2>&1 + + echo "+++ cat files" >> $seqres.full + (find "${SCRATCH_MNT}/test.1/" -type f -size -1048576k -print0 | xargs -0 cat) >/dev/null 2>&1 +} + +# Do we have an online scrub program? +_require_scrub() { + case "${FSTYP}" in + "xfs"|"ext4") + test -x $XFS_SCRUB_PROG || _notrun "xfs_scrub not found" + ;; + *) + _notrun "No online scrub program for ${FSTYP}." + ;; + esac +} + +# Scrub the scratch filesystem metadata (online) +_scratch_scrub() { + case "${FSTYP}" in + "xfs"|"ext4"|"ext3"|"ext2") + $XFS_SCRUB_PROG -d -T -v "$@" $SCRATCH_MNT + ;; + *) + _fail "No online scrub program for ${FSTYP}." + ;; + esac +} diff --git a/common/populate b/common/populate index 1afab46..cf6a80b 100644 --- a/common/populate +++ b/common/populate @@ -606,41 +606,6 @@ _scratch_populate() { esac } -# Modify various files after a fuzzing operation -_scratch_fuzz_modify() { - nr="$1" - - test -z "${nr}" && nr=50000 - echo "+++ touch ${nr} files" - blk_sz=$(stat -f -c '%s' ${SCRATCH_MNT}) - $XFS_IO_PROG -f -c "pwrite -S 0x63 0 ${blk_sz}" "/tmp/afile" > /dev/null - date="$(date)" - find "${SCRATCH_MNT}/" -type f 2> /dev/null | head -n "${nr}" | while read f; do - setfattr -n "user.date" -v "${date}" "$f" - cat "/tmp/afile" >> "$f" - mv "$f" "$f.longer" - done - sync - rm -rf "/tmp/afile" - - echo "+++ create files" - mkdir -p "${SCRATCH_MNT}/test.moo" - $XFS_IO_PROG -f -c 'pwrite -S 0x80 0 65536' "${SCRATCH_MNT}/test.moo/urk" - sync - - echo "+++ remove files" - rm -rf "${SCRATCH_MNT}/test.moo" -} - -# Try to access files after fuzzing -_scratch_fuzz_test() { - echo "+++ ls -laR" >> $seqres.full - ls -laR "${SCRATCH_MNT}/test.1/" >/dev/null 2>&1 - - echo "+++ cat files" >> $seqres.full - (find "${SCRATCH_MNT}/test.1/" -type f -size -1048576k -print0 | xargs -0 cat) >/dev/null 2>&1 -} - # Fill a file system by repeatedly creating files in the given folder # starting with the given file size. Files are reduced in size when # they can no longer fit until no more files can be created. diff --git a/tests/ext4/006 b/tests/ext4/006 index 9662f50..bb9b7e5 100755 --- a/tests/ext4/006 +++ b/tests/ext4/006 @@ -43,6 +43,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/populate +. ./common/fuzzy if [ ! -x "$(which e2fuzz)" ]; then _notrun "Couldn't find e2fuzz" diff --git a/tests/xfs/083 b/tests/xfs/083 index 39bd75f..e2b5f82 100755 --- a/tests/xfs/083 +++ b/tests/xfs/083 @@ -43,6 +43,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/populate +. ./common/fuzzy # real QA test starts here _supported_fs xfs