[ovs-dev] [PATCH 1/2] tests: Use $(MKDIR_P) to avoid races.

Gregory Rose gvrose8192 at gmail.com
Wed Dec 6 17:42:06 UTC 2017


On 12/5/2017 4:27 PM, Ben Pfaff wrote:
> "test -d x || mkdir x" has a race when invoked in parallel: it is possible
> for two processes to both see that 'x' does not exist and both try to
> create it, and if that happens then one of them will fail.  This avoids
> the problem.
>
> Signed-off-by: Ben Pfaff <blp at ovn.org>
> ---
>   tests/automake.mk | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 7eed1064e82b..c5cc95251207 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -193,7 +193,7 @@ valgrind_wrappers = \
>   	tests/valgrind/test-type-props
>   
>   $(valgrind_wrappers): tests/valgrind-wrapper.in
> -	@test -d tests/valgrind || mkdir tests/valgrind
> +	@$(MKDIR_P) tests/valgrind
>   	$(AM_V_GEN) sed -e 's,[@]wrap_program[@],$@,' \
>   		$(top_srcdir)/tests/valgrind-wrapper.in > $@.tmp && \
>   	chmod +x $@.tmp && \

Reviewed-by: Greg Rose <gvrose8192 at gmail.com>



More information about the dev mailing list