From patchwork Wed Nov 4 16:31:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 7552121 Return-Path: X-Original-To: patchwork-fstests@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 9985CBEEA4 for ; Wed, 4 Nov 2015 16:39:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D155E206CC for ; Wed, 4 Nov 2015 16:39:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BBEE206B7 for ; Wed, 4 Nov 2015 16:39:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030394AbbKDQbx (ORCPT ); Wed, 4 Nov 2015 11:31:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:35731 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965622AbbKDQbv (ORCPT ); Wed, 4 Nov 2015 11:31:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 278EEABFA; Wed, 4 Nov 2015 16:31:32 +0000 (UTC) Received: by quack.suse.cz (Postfix, from userid 1000) id D4A318282F; Wed, 4 Nov 2015 17:31:48 +0100 (CET) From: Jan Kara To: fstests@vger.kernel.org Cc: linux-ext4@vger.kernel.org, Jan Kara Subject: [PATCH 3/4] common: Add function for selecting from different output files Date: Wed, 4 Nov 2015 17:31:37 +0100 Message-Id: <1446654698-23577-4-git-send-email-jack@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446654698-23577-1-git-send-email-jack@suse.com> References: <1446654698-23577-1-git-send-email-jack@suse.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 function for selection of different output files. The idea is that in config file ($seq.cfg) there are several lines like: feat1,feat2: suffix The function is passed a feature string (or uses MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected. Signed-off-by: Jan Kara --- common/rc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/common/rc b/common/rc index adf1edf64d8d..543780c92c59 100644 --- a/common/rc +++ b/common/rc @@ -3142,6 +3142,47 @@ get_block_size() echo `stat -f -c %S $1` } +_select_output() +{ + if [ $# -eq 0 ]; then + FEATURES=${MOUNT_OPTIONS##"-o "} + else + FEATURES=$1 + fi + + export FEATURES + seqfull=$SRC_DIR/$seqnum + perl -e ' + my %feathash; + my $feature, $result, $suffix, $opts; + + foreach $feature (split(/,/, $ENV{"FEATURES"})) { + $feathash{$feature} = 1; + } + $result = "default"; + while (<>) { + my $found = 1; + + chomp; + ($opts, $suffix) = split(/ *: */); + foreach my $opt (split(/,/, $opts)) { + if (!exists($feathash{$opt})) { + $found = 0; + last; + } + } + if ($found == 1) { + $result = $suffix; + last; + } + } + print $result + ' <$seqfull.cfg | { + read SUFFIX + ln -fs $seq.out.$SUFFIX $seqfull.out + } +} + init_rc ################################################################################