From: Subrata Modak <subrata@linux.vnet.ibm.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: Sachin P Sant <sachinp@linux.vnet.ibm.com>,
LTP Mailing List <ltp-list@lists.sourceforge.net>,
Mike Frysinger <vapier@gentoo.org>,
Michael Reed <mreed10@us.ibm.com>, Nate Straz <nate@refried.org>,
Paul Larson <paul.larson@ubuntu.com>,
Manoj Iyer <manoj.iyer@ubuntu.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>
Subject: Re: [LTP] [PATCH 04/05] Add Script which will be at the heart of this infrastructure
Date: Wed, 12 Aug 2009 16:51:00 +0530 [thread overview]
Message-ID: <1250076060.5373.22.camel@subratamodak.linux.ibm.com> (raw)
In-Reply-To: <364299f40908120142k47ec9742ub9eb4cf2021dbb94@mail.gmail.com>
On Wed, 2009-08-12 at 01:42 -0700, Garrett Cooper wrote:
> On Tue, Aug 11, 2009 at 10:30 AM, Subrata
> Modak<subrata@linux.vnet.ibm.com> wrote:
> > At the heart of this infrastructure is this Script, which will actually:
> > 1) Change the temporary command file generated by runltp,
> > 2) Create a new temporary command file which will have the following entries
> > against each one entry in the command file:
> > i) Same TAG COMMAND_LINE entry,
> > ii) Entry to call the script to insert faults,
> > iii) Entry to run as many loops as specified by the user,
> > iv) Entry to call the script to restore kernel to default state,
> >
> > It is capable of creating new entries in the temporary command file with the
> > following tags and command lines:
> > TAG_NAME=tag1, COMMANDLINE="test1",
> > TAG_NAME=tag1_loop1, COMMANDLINE="insert_fault_in_kernel; test1",
> > TAG_NAME=tag1_loop2, COMMANDLINE="test1",
> > ...
> > TAG_NAME=tag1_loopn, COMMANDLINE="test1; restore_default_kernel",
> >
> > Signed-off-by: Subrata Modak <subrata@linux.vnet.ibm.com>
> > ---
> >
> > diff -uprN ltp-full-20090731.orig/tools/create_kernel_faults_in_loops_and_probability.pl ltp-full-20090731/tools/create_kernel_faults_in_loops_and_probability.pl
> > --- ltp-full-20090731.orig/tools/create_kernel_faults_in_loops_and_probability.pl 1970-01-01 05:30:00.000000000 +0530
> > +++ ltp-full-20090731/tools/create_kernel_faults_in_loops_and_probability.pl 2009-08-11 20:23:54.000000000 +0530
> > @@ -0,0 +1,97 @@
> > +#!/usr/bin/perl
> > +################################################################################
> > +## ##
> > +## Copyright (c) International Business Machines Corp., 2009 ##
> > +## ##
> > +## 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 ##
> > +## ##
> > +################################################################################
> > +# ##
> > +# File : create_kernel_faults_in_loops_and_probability.pl ##
> > +# ##
> > +# Usage: create_kernel_faults_in_loops_and_probability.pl\ ##
> > +# <LTP_COMMAND_FILE> <NO_OF_LOOPS_EACH_TEST_WILL_RUN>\ ##
> > +# <PROBABILITY_OF_FAULT_INJECTION> ##
> > +# ##
> > +# Description: This is a simple perl script which will take ltp command file ##
> > +# as input and then create a final command file while will have ##
> > +# the following entries for each test tag: ##
> > +# 1) <tag_name_loop1> <test_binary_name> ##
> > +# 2) <tag_name_loop2> <insert_kernel_faults.sh test_binary_name>##
> > +# 3) tag entried from loop3 to loop(n-1) ##
> > +# 4) <tag_name_loopn> <restore_kernel_faults_default.sh test_binary_name>##
> > +# ##
> > +# Author: Subrata Modak <subrata@linux.vnet.ibm.com> ##
> > +# ##
> > +# History: Aug 11 2009 - Created - Subrata Modak. ##
> > +################################################################################
> > +
> > +my $command_file = shift (@ARGV) || syntax();
> > +my $loops = shift (@ARGV) || syntax();
> > +my $failure_probability = shift (@ARGV) || syntax();
> > +
> > +sub syntax() {
> > + print "syntax: create_fault_in_loops_and_probability.pl\
> > + <LTP_COMMAND_FILE> <NO_OF_LOOPS_EACH_TEST_WILL_RUN>\
> > + <PROBABILITY_OF_FAULT_INJECTION>\n";
> > + exit (1);
> > +}
> > +#$ENV{TEST_START_TIME})
> > +
> > +
> > +open (FILE, $command_file) || die "Cannot open file: $command_file\n";
> > +while ($line = <FILE>) {
> > + if ($line =~ /^#/) {
> > + print "$line";
> > + next;
> > + }
> > + if ($line =~ /^\n$/) {
> > + next;
> > + }
> > + chomp $line;
> > + print "$line\n"; #Print one instance for stable execution
> > + @tag_and_actual_command = split(/\ /, $line);
> > +
> > + #The remaining loops should be running under fault injection
> > + for ($counter=1; $counter<=$loops; $counter++) {
> > + my $token_counter = 0;
> > + foreach my $token (@tag_and_actual_command) {
> > + if ($token_counter == 0 ) {
> > + #Time to append the actual command tag with the loop no.
> > + print $token . "_loop_" . $counter . " ";
> > + $token_counter++;
> > + next;
> > + }
> > + if ($token_counter == 1 && $counter == 1) {
> > + #Time to include the fault injection script in the first loop
> > + print "\$LTPROOT/tools/insert_kernel_faults.sh " . $failure_probability . "; " . $token;
> > + $token_counter++;
> > + next;
> > + }
> > + print " " . $token . " ";
> > + }
> > + if ($counter == $loops) {
> > + #Time to withdraw the faults once the last loop has been executed
> > + #Until all faults has been successfully restored to default values...
> > + #Keep restoring them
> > + print "; " . "\$LTPROOT/tools/restore_kernel_faults_default.sh; RC=\$?; while [ \$RC -ne 0 ]; do \$LTPROOT/tools/restore_kernel_faults_default.sh; RC=\$?; done\n"
> > + } else {
> > + print "\n"
> > + }
> > + }
> > +
> > +}
> > +close (FILE);
> > +
>
> Hi Subrata,
> 1. Why is this written in perl? bourne shell should be the maximum
> requirement for any and all infrastructure scripts.
I initially wrote this in perl as i feel more comfortable in doing
regular expression in perl than in any other language. If you want you
can later replace it with a shell script, i will not have any objection.
> 2. Why not write this in a runtest-ish file format, e.g.
>
> [tag] [command]
>
> ? That way you can feed the command through pan at least...
Thatś exactly it is doing. Before the original temporary command file is
passed to ltp-pan, this script is just modifying that command file and
passing to ltp-pan. So, ltp-pan has no idea of what it is running. It is
just parsing the tags and commands associated with them. I am exploiting
that behavior only without touching anything in ltp-pan.
Regards--
Subrata
> Thanks
> -Garrett
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2009-08-12 11:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 17:29 [LTP] [PATCH 00/05] Integration of "Fault Injection Framework" into LTP Subrata Modak
2009-08-11 17:30 ` [LTP] [PATCH 01/05] Provide all necessary information through ltp/README Subrata Modak
2009-08-11 17:30 ` [LTP] [PATCH 02/05] Add Script which would actually do the job of injecting faults Subrata Modak
2009-08-12 8:45 ` Garrett Cooper
2009-08-12 11:20 ` Subrata Modak
2009-08-11 17:30 ` [LTP] [PATCH 03/05] Add Script so the kernel is restored back to its original pristine form Subrata Modak
2009-08-11 17:30 ` [LTP] [PATCH 04/05] Add Script which will be at the heart of this infrastructure Subrata Modak
2009-08-12 8:42 ` Garrett Cooper
2009-08-12 11:21 ` Subrata Modak [this message]
2009-08-13 7:11 ` Mike Frysinger
2009-08-11 17:31 ` [LTP] [PATCH 05/05] Add the necessary Interface and Option through "runltp" Subrata Modak
2009-08-11 18:02 ` Paul Larson
[not found] ` <4A81B1A0.5050708@ubuntu.com>
2009-08-12 11:21 ` Subrata Modak
2009-08-13 7:13 ` Mike Frysinger
2009-08-11 17:31 ` [LTP] [RESULTS] Results of test run for "Fault Injection Framework" Subrata Modak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250076060.5373.22.camel@subratamodak.linux.ibm.com \
--to=subrata@linux.vnet.ibm.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=manoj.iyer@ubuntu.com \
--cc=mreed10@us.ibm.com \
--cc=nate@refried.org \
--cc=paul.larson@ubuntu.com \
--cc=sachinp@linux.vnet.ibm.com \
--cc=vapier@gentoo.org \
--cc=yanegomi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox