Re: [kvm-unit-tests PATCH v2 3/8] s390x: css: simplify skipping tests on no device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/25/21 10:39 AM, Pierre Morel wrote:
> We will lhave to test if a device is present for every tests

s/lhave/have/

> in the future.
> Let's provide a macro to check if the device is present and
> to skip the tests if it is not.
> 
> Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>

Reviewed-by: Janosch Frank <frankja@xxxxxxxxxxxxx>

> ---
>  s390x/css.c | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/s390x/css.c b/s390x/css.c
> index c340c53..16723f6 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -27,6 +27,13 @@ static int test_device_sid;
>  static struct senseid *senseid;
>  struct ccw1 *ccw;
>  
> +#define NODEV_SKIP(dev) do {						\

s/device/schid/ ?
I have no strong opinions either way so choose what you like best.

Also, since you use report(0, "") so often, maybe you want to introduce
report_fail() into the library in the future? The x86 vmx tests also use
report(0, "") a lot so you're not completely alone.

Could you please move the "do {" one line down so we start with a zero
indent?

> +				if (!(dev)) {				\
> +					report_skip("No device");	\
> +					return;				\
> +				}					\
> +			} while (0)
> +
>  static void test_enumerate(void)
>  {
>  	test_device_sid = css_enumerate();
> @@ -41,10 +48,7 @@ static void test_enable(void)
>  {
>  	int cc;
>  
> -	if (!test_device_sid) {
> -		report_skip("No device");
> -		return;
> -	}
> +	NODEV_SKIP(test_device_sid);
>  
>  	cc = css_enable(test_device_sid, IO_SCH_ISC);
>  
> @@ -62,10 +66,7 @@ static void test_sense(void)
>  	int ret;
>  	int len;
>  
> -	if (!test_device_sid) {
> -		report_skip("No device");
> -		return;
> -	}
> +	NODEV_SKIP(test_device_sid);
>  
>  	ret = css_enable(test_device_sid, IO_SCH_ISC);
>  	if (ret) {
> @@ -218,10 +219,7 @@ static void test_schm_fmt0(void)
>  	struct measurement_block_format0 *mb0;
>  	int shared_mb_size = 2 * sizeof(struct measurement_block_format0);
>  
> -	if (!test_device_sid) {
> -		report_skip("No device");
> -		return;
> -	}
> +	NODEV_SKIP(test_device_sid);
>  
>  	/* Allocate zeroed Measurement block */
>  	mb0 = alloc_io_mem(shared_mb_size, 0);
> @@ -289,10 +287,7 @@ static void test_schm_fmt1(void)
>  {
>  	struct measurement_block_format1 *mb1;
>  
> -	if (!test_device_sid) {
> -		report_skip("No device");
> -		return;
> -	}
> +	NODEV_SKIP(test_device_sid);
>  
>  	if (!css_test_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) {
>  		report_skip("Extended measurement block not available");
> 




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux