[LTP] [PATCH V2 03/11] Add TST_TRACE

Cyril Hrubis chrubis@suse.cz
Thu Aug 25 13:15:17 CEST 2016


Hi!
> +'TST_TRACE' can make the analysis of such situations easier. It's a macro which
> +inserts a call to 'tst_res(TINFO, ...)' in case its argument is not zero.
                                                         ^
						"evaluates to non-zero"

						would be more clear in
						this case

> +In this call to 'tst_res(TINFO, ...)' the file and line will be expanded using
> +the actual location of 'TST_TRACE'.
> +
> +[source,c]
> +-------------------------------------------------------------------------------
> +#include "tst_test.h"
> +
> +if (TST_TRACE(do_action())) {
> +	...
> +}
> +-------------------------------------------------------------------------------

Maybe we should also include example test output here. Otherise the
description looks good to me.

>  2.3.1 Basic shell test structure
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 3e2ff5b..eb3f751 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -59,6 +59,10 @@ pid_t safe_fork(const char *filename, unsigned int lineno);
>  #define SAFE_FORK() \
>  	safe_fork(__FILE__, __LINE__)
>  
> +#define TST_TRACE(expr)							\
> +	({int ret = expr;						\
> +		ret != 0 ? tst_res(TINFO, #expr " failed"), ret : ret; })
> +

I would format this to something as:

#define TST_TRACE(expr)	                                            \
	({int ret = expr;                                           \
	  ret != 0 ? tst_res(TINFO, #expr " failed"), ret : ret; }) \

But that is very minor.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list