[CRIU] [PATCH 1/4] test: replace use of pcre grep with awk

Andrew Vagin avagin at parallels.com
Tue Aug 26 02:04:15 PDT 2014


On Mon, Aug 25, 2014 at 08:53:57PM -0700, Filipe Brandenburger wrote:
> Unfortunately, grep -P is not ubiquitous, so use awk with two regexps to
> simulate the negative forward lookup in the grep -P expression.
> 
> Using awk doesn't really make it too unreadable, as using boolean operators
> such as && and || might actually make it more intuitive than the extended
> regexp.
> 
> Tested:
> - sudo make -C test zdtm_ns
> - sudo make -C test zdtm_nons
>

Acked-by: Andrew Vagin <avagin at parallels.com> for all four patches.

Thank you, Filipe.

> Signed-off-by: Filipe Brandenburger <filbranden at google.com>
> ---
>  test/Makefile | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/test/Makefile b/test/Makefile
> index 9dcc52336a8d..9cb219d635be 100644
> --- a/test/Makefile
> +++ b/test/Makefile
> @@ -1,5 +1,4 @@
>  TST = $(shell ./zdtm.sh -l)
> -EXP = '^ns/(?!.*(tty|pty))'
>  
>  ZDTM_ARGS ?= -C
>  
> @@ -25,8 +24,8 @@ fault-injection: .FORCE
>  	$(MAKE) -C fault-injection
>  .PHONY: fault-injection
>  
> -zdtm_ns: $(shell echo "$(TST)" | tr ' ' '\n' | grep -P $(EXP))
> -zdtm_nons: $(shell echo "$(TST)" | tr ' ' '\n' | grep -vP $(EXP))
> +zdtm_ns:   $(shell echo "$(TST)" | tr ' ' '\n' | awk '/^ns\// && !/tty|pty/ {print}')
> +zdtm_nons: $(shell echo "$(TST)" | tr ' ' '\n' | awk '!/^ns\// || /tty|pty/ {print}')
>  
>  zdtm_ct: zdtm_ct.c
>  
> -- 
> 1.9.3
> 


More information about the CRIU mailing list