From patchwork Fri Nov 13 21:36:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 7614841 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E95F79F2E2 for ; Fri, 13 Nov 2015 21:45:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0841F205DD for ; Fri, 13 Nov 2015 21:45:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95801205F5 for ; Fri, 13 Nov 2015 21:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750872AbbKMVhb (ORCPT ); Fri, 13 Nov 2015 16:37:31 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:22737 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751494AbbKMVh3 (ORCPT ); Fri, 13 Nov 2015 16:37:29 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tADLatTl018005 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Nov 2015 21:36:55 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tADLasK5009200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 13 Nov 2015 21:36:55 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id tADLapvD007176; Fri, 13 Nov 2015 21:36:51 GMT Received: from localhost (/71.198.20.188) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 Nov 2015 13:36:51 -0800 Subject: [PATCH 01/12] test-scripts: test migration scripts From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: fstests@vger.kernel.org, xfs@oss.sgi.com, hch@infradead.org, tao.peng@primarydata.com, linux-ext4@vger.kernel.org, Anna.Schumaker@netapp.com, linux-btrfs@vger.kernel.org Date: Fri, 13 Nov 2015 13:36:50 -0800 Message-ID: <20151113213650.31124.16817.stgit@birch.djwong.org> In-Reply-To: <20151113213643.31124.80975.stgit@birch.djwong.org> References: <20151113213643.31124.80975.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-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add two scripts: "nextid" finds the next available test ID number in a group, and "mvtest" relocates a test, fixes the golden output, and moves the group entry for that test. Signed-off-by: Darrick J. Wong --- mvtest | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ nextid | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100755 mvtest create mode 100755 nextid -- 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/mvtest b/mvtest new file mode 100755 index 0000000..b5406d1 --- /dev/null +++ b/mvtest @@ -0,0 +1,58 @@ +#!/bin/sh + +# Renumber a test + +if [ -z "$1" ] || [ "$1" = "--help" ]; then + echo "Usage: $0 path_to_test new_path_to_test" + exit 1 +fi + +src="$1" +dest="$2" + +die() { + echo "$@" + exit 1 +} + +nsort() { + sort -g < "$1" > "$2" +} + +append() { + out="$1" + shift + echo "$@" >> "${out}" +} + +test "${src}" != "${dest}" || die "Test \"${src}\" is the same as dest." +test -e "tests/${src}" || die "Test \"${src}\" does not exist." +test ! -e "tests/${dest}" || die "Test \"${src}\" already exists." + +sid="$(basename "${src}")" +did="$(basename "${dest}")" + +sgroup="$(basename "$(dirname "tests/${src}")")" +dgroup="$(basename "$(dirname "tests/${dest}")")" + +sgroupfile="tests/${sgroup}/group" +dgroupfile="tests/${sgroup}/group" + +$DBG git mv "tests/${src}" "tests/${dest}" +$DBG git mv "tests/${src}.out" "tests/${dest}.out" +$DBG sed -e "s/^# FS QA Test No. ${sid}$/# FS QA Test No. ${did}/g" -i "tests/${dest}" +$DBG sed -e "s/^QA output created by ${sid}$/QA output created by ${did}/g" -i "tests/${dest}.out" +$DBG sed -e "s/test-${sid}/test-${did}/g" -i "tests/${dest}.out" + +grpline="$(grep "^${sid} " "${sgroupfile}")" +newgrpline="$(echo "${grpline}" | sed -e "s/^${sid} /${did} /g")" + +$DBG sed -e "/^${sid}.*$/d" -i "${sgroupfile}" +$DBG cp "${dgroupfile}" "${dgroupfile}.new" +$DBG append "${dgroupfile}.new" "${newgrpline}" +$DBG nsort "${dgroupfile}.new" "${dgroupfile}" +$DBG rm "${dgroupfile}.new" + +echo "Moved \"${src}\" to \"${dest}\"." + +exit 0 diff --git a/nextid b/nextid new file mode 100755 index 0000000..285b549 --- /dev/null +++ b/nextid @@ -0,0 +1,35 @@ +#!/bin/sh + +# Given a group name, find the next available test number. + +if [ -z "$1" ] || [ "$1" = "--help" ]; then + echo "Usage: $0 groupname[/start_looking_at_this_number]" + exit 1 +fi + +die() { + echo "$@" + exit 1 +} + +if [ "$(basename "$1")" != "$1" ]; then + group="$(dirname "$1")" + id="$(basename "$1")" +else + group="$1" + id=1 +fi +test -e "tests/${group}/group" || die "Unknown group \"${group}\"." + +while test "${id}" -lt 1000; do + name="$(printf "%.03d" "${id}")" + if [ ! -e "tests/${group}/${name}" ]; then + echo "${group}/${name}" + exit 0 + fi + id=$((id + 1)) +done + +echo "No free IDs less than ${id} in group \"${group}\"." + +exit 1