public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] skipfile: allow regular expressions
@ 2018-01-16  8:01 Daniel Sangorrin
  2018-01-22 15:19 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Sangorrin @ 2018-01-16  8:01 UTC (permalink / raw)
  To: ltp

This patch allows using regular expressions to match
test cases that should be skipped when using the -S option.
For example, creating a SKIPFILE with "cron.*" on it will
skip all test names that start with "cron".

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
---
 runltp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/runltp b/runltp
index 302c4a7..1295651 100755
--- a/runltp
+++ b/runltp
@@ -692,10 +692,11 @@ main()
     fi
 
     # Blacklist or skip tests if a SKIPFILE was specified with -S
+    # The SKIPFILE can contain regular expressions (e.g.: cron.*)
     if [ -n "${SKIPFILE}" ]; then
         for test_name in $(awk '{print $1}' "${SKIPFILE}"); do
             case "${test_name}" in \#*) continue;; esac
-            sed -i "/\<${test_name}\>/c\\${test_name} exit 32;" alltests
+            sed -i "s/^\(${test_name}\)\s.*/\1 exit 32;/" alltests
         done
     fi
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH v2] skipfile: allow regular expressions
  2018-01-16  8:01 [LTP] [PATCH v2] skipfile: allow regular expressions Daniel Sangorrin
@ 2018-01-22 15:19 ` Cyril Hrubis
  2018-01-30  7:15   ` Daniel Sangorrin
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2018-01-22 15:19 UTC (permalink / raw)
  To: ltp

Hi!
> --- a/runltp
> +++ b/runltp
> @@ -692,10 +692,11 @@ main()
>      fi
>  
>      # Blacklist or skip tests if a SKIPFILE was specified with -S
> +    # The SKIPFILE can contain regular expressions (e.g.: cron.*)
>      if [ -n "${SKIPFILE}" ]; then
>          for test_name in $(awk '{print $1}' "${SKIPFILE}"); do
>              case "${test_name}" in \#*) continue;; esac
> -            sed -i "/\<${test_name}\>/c\\${test_name} exit 32;" alltests
> +            sed -i "s/^\(${test_name}\)\s.*/\1 exit 32;/" alltests
>          done
>      fi

Looks good, but please update runltplite.sh as well.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH v2] skipfile: allow regular expressions
  2018-01-22 15:19 ` Cyril Hrubis
@ 2018-01-30  7:15   ` Daniel Sangorrin
  2018-02-07 15:32     ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Sangorrin @ 2018-01-30  7:15 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> -----Original Message-----
> From: Cyril Hrubis [mailto:chrubis@suse.cz]
> Sent: Tuesday, January 23, 2018 12:19 AM
> To: Daniel Sangorrin
> Cc: ltp@lists.linux.it
> Subject: Re: [LTP] [PATCH v2] skipfile: allow regular expressions
> 
> Hi!
> > --- a/runltp
> > +++ b/runltp
> > @@ -692,10 +692,11 @@ main()
> >      fi
> >
> >      # Blacklist or skip tests if a SKIPFILE was specified with -S
> > +    # The SKIPFILE can contain regular expressions (e.g.: cron.*)
> >      if [ -n "${SKIPFILE}" ]; then
> >          for test_name in $(awk '{print $1}' "${SKIPFILE}"); do
> >              case "${test_name}" in \#*) continue;; esac
> > -            sed -i "/\<${test_name}\>/c\\${test_name} exit 32;" alltests
> > +            sed -i "s/^\(${test_name}\)\s.*/\1 exit 32;/" alltests
> >          done
> >      fi
> 
> Looks good, but please update runltplite.sh as well.

Sorry for the delay. I found that my patch had a flaw while testing it on runltplite.sh.
For example, "rwtest.*" doesn't work for rwtest:  
rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f sync ..

The reason is that "rwtest.*"  matches too much. If I use "rwtest[a-zA-Z0-9]" as a regex on the skipfile
then it works as expected

Example:
$ STRING="rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f"
$ sed "s/^\(rwtest.*\)\s.*/\1 exit 32;/" <<< $STRING
    rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f exit 32  (BAD!!)
$ sed "s/^\(rwtest[a-zA-Z0-9]*\)\s.*/\1 exit 32;/" <<< $STRING
rwtest01 exit 32 (GOOD!!)

I think that the skipfile entries should only care about the testname, so "rwtest.*" should actually
work. I have tried modifying the sed instruction but I wasn't able to isolate the first occurrence.
Should I extract the test_name (first words, except blank lines) from alltests and match them
with the skipfile entries one by one in a loop?

Thanks,
Daniel




> --
> Cyril Hrubis
> chrubis@suse.cz




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH v2] skipfile: allow regular expressions
  2018-01-30  7:15   ` Daniel Sangorrin
@ 2018-02-07 15:32     ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2018-02-07 15:32 UTC (permalink / raw)
  To: ltp

Hi!
> Sorry for the delay. I found that my patch had a flaw while testing it on runltplite.sh.
> For example, "rwtest.*" doesn't work for rwtest:  
> rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f sync ..
> 
> The reason is that "rwtest.*"  matches too much. If I use "rwtest[a-zA-Z0-9]" as a regex on the skipfile
> then it works as expected
> 
> Example:
> $ STRING="rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f"
> $ sed "s/^\(rwtest.*\)\s.*/\1 exit 32;/" <<< $STRING
>     rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s -f exit 32  (BAD!!)
> $ sed "s/^\(rwtest[a-zA-Z0-9]*\)\s.*/\1 exit 32;/" <<< $STRING
> rwtest01 exit 32 (GOOD!!)

Ah looks like your first attempt ends up eating the source greadily
so \1 ends up being everything to the last whitespace.

I guess that s/^\(rwtest[\S]*\).*/\1 exit 32;/ should work, since it
will stop at first whitespace.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-07 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16  8:01 [LTP] [PATCH v2] skipfile: allow regular expressions Daniel Sangorrin
2018-01-22 15:19 ` Cyril Hrubis
2018-01-30  7:15   ` Daniel Sangorrin
2018-02-07 15:32     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox