diff mbox series

[kvm-unit-tests,2/5] s390x: css: Skip if we're not run by qemu

Message ID 20220114100245.8643-3-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Allocation and hosting environment detection fixes | expand

Commit Message

Janosch Frank Jan. 14, 2022, 10:02 a.m. UTC
There's no guarantee that we even find a device at the address we're
testing for if we're not running under QEMU.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/css.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Claudio Imbrenda Jan. 14, 2022, 10:41 a.m. UTC | #1
On Fri, 14 Jan 2022 10:02:42 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> There's no guarantee that we even find a device at the address we're
> testing for if we're not running under QEMU.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  s390x/css.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/css.c b/s390x/css.c
> index 881206ba..c24119b4 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -15,6 +15,7 @@
>  #include <interrupt.h>
>  #include <asm/arch_def.h>
>  #include <alloc_page.h>
> +#include <vm.h>
>  
>  #include <malloc_io.h>
>  #include <css.h>
> @@ -350,6 +351,12 @@ int main(int argc, char *argv[])
>  {
>  	int i;
>  
> +	/* There's no guarantee where our devices are without qemu */
> +	if (!vm_is_kvm() && !vm_is_tcg()) {
> +		report_skip("Not running under QEMU");
> +		goto done;
> +	}
> +
>  	report_prefix_push("Channel Subsystem");
>  	enable_io_isc(0x80 >> IO_SCH_ISC);
>  	for (i = 0; tests[i].name; i++) {
> @@ -357,7 +364,8 @@ int main(int argc, char *argv[])
>  		tests[i].func();
>  		report_prefix_pop();
>  	}
> -	report_prefix_pop();
>  
> +done:
> +	report_prefix_pop();
>  	return report_summary();
>  }
Thomas Huth Jan. 17, 2022, 7:01 a.m. UTC | #2
On 14/01/2022 11.02, Janosch Frank wrote:
> There's no guarantee that we even find a device at the address we're
> testing for if we're not running under QEMU.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>   s390x/css.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/css.c b/s390x/css.c
> index 881206ba..c24119b4 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -15,6 +15,7 @@
>   #include <interrupt.h>
>   #include <asm/arch_def.h>
>   #include <alloc_page.h>
> +#include <vm.h>
>   
>   #include <malloc_io.h>
>   #include <css.h>
> @@ -350,6 +351,12 @@ int main(int argc, char *argv[])
>   {
>   	int i;
>   
> +	/* There's no guarantee where our devices are without qemu */
> +	if (!vm_is_kvm() && !vm_is_tcg()) {
> +		report_skip("Not running under QEMU");
> +		goto done;
> +	}

You've added the check before the report_prefix_push() ...

>   	report_prefix_push("Channel Subsystem");
>   	enable_io_isc(0x80 >> IO_SCH_ISC);
>   	for (i = 0; tests[i].name; i++) {
> @@ -357,7 +364,8 @@ int main(int argc, char *argv[])
>   		tests[i].func();
>   		report_prefix_pop();
>   	}
> -	report_prefix_pop();
>   
> +done:
> +	report_prefix_pop();

... but in case of the goto you now do the pop without the push. I think you 
have to drop the second hunk.

  Thomas


>   	return report_summary();
>   }
diff mbox series

Patch

diff --git a/s390x/css.c b/s390x/css.c
index 881206ba..c24119b4 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -15,6 +15,7 @@ 
 #include <interrupt.h>
 #include <asm/arch_def.h>
 #include <alloc_page.h>
+#include <vm.h>
 
 #include <malloc_io.h>
 #include <css.h>
@@ -350,6 +351,12 @@  int main(int argc, char *argv[])
 {
 	int i;
 
+	/* There's no guarantee where our devices are without qemu */
+	if (!vm_is_kvm() && !vm_is_tcg()) {
+		report_skip("Not running under QEMU");
+		goto done;
+	}
+
 	report_prefix_push("Channel Subsystem");
 	enable_io_isc(0x80 >> IO_SCH_ISC);
 	for (i = 0; tests[i].name; i++) {
@@ -357,7 +364,8 @@  int main(int argc, char *argv[])
 		tests[i].func();
 		report_prefix_pop();
 	}
-	report_prefix_pop();
 
+done:
+	report_prefix_pop();
 	return report_summary();
 }