diff mbox

tests: minor cleanups in usb-hcd-uhci-test

Message ID 1475765448-18949-1-git-send-email-lvivier@redhat.com
State New
Headers show

Commit Message

Laurent Vivier Oct. 6, 2016, 2:50 p.m. UTC
Two minor cleanups:
- exit gracefully in case on unsupported target,
- put machine command line in a constant to avoid
  to duplicate it.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tests/usb-hcd-uhci-test.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

David Gibson Oct. 6, 2016, 11:49 p.m. UTC | #1
On Thu, Oct 06, 2016 at 04:50:48PM +0200, Laurent Vivier wrote:
> Two minor cleanups:
> - exit gracefully in case on unsupported target,
> - put machine command line in a constant to avoid
>   to duplicate it.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

I'm not sure if I should take this through my tree or not.

> ---
>  tests/usb-hcd-uhci-test.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
> index 4b951ce..e956b9c 100644
> --- a/tests/usb-hcd-uhci-test.c
> +++ b/tests/usb-hcd-uhci-test.c
> @@ -77,6 +77,9 @@ static void test_usb_storage_hotplug(void)
>  int main(int argc, char **argv)
>  {
>      const char *arch = qtest_get_arch();
> +    const char *cmd = "-device piix3-usb-uhci,id=uhci,addr=1d.0"
> +                      " -drive id=drive0,if=none,file=/dev/null,format=raw"
> +                      " -device usb-tablet,bus=uhci.0,port=1";
>      int ret;
>  
>      g_test_init(&argc, &argv, NULL);
> @@ -87,13 +90,13 @@ int main(int argc, char **argv)
>      qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
>  
>      if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> -        qs = qtest_pc_boot("-device piix3-usb-uhci,id=uhci,addr=1d.0"
> -                           " -drive id=drive0,if=none,file=/dev/null,format=raw"
> -                           " -device usb-tablet,bus=uhci.0,port=1");
> +        qs = qtest_pc_boot(cmd);
>      } else if (strcmp(arch, "ppc64") == 0) {
> -        qs = qtest_spapr_boot("-device piix3-usb-uhci,id=uhci,addr=1d.0"
> -                           " -drive id=drive0,if=none,file=/dev/null,format=raw"
> -                           " -device usb-tablet,bus=uhci.0,port=1");
> +        qs = qtest_spapr_boot(cmd);
> +    } else {
> +        g_printerr("usb-hcd-uhci-test tests are only "
> +                   "available on x86 or ppc64\n");
> +        exit(EXIT_FAILURE);
>      }
>      ret = g_test_run();
>      qtest_shutdown(qs);
Gerd Hoffmann Oct. 7, 2016, 8:40 a.m. UTC | #2
On Fr, 2016-10-07 at 10:49 +1100, David Gibson wrote:
> On Thu, Oct 06, 2016 at 04:50:48PM +0200, Laurent Vivier wrote:
> > Two minor cleanups:
> > - exit gracefully in case on unsupported target,
> > - put machine command line in a constant to avoid
> >   to duplicate it.
> > 
> > Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> I'm not sure if I should take this through my tree or not.

Feel free to do so, makes sense to merge this together with the ppc usb
test patches.  Avoids conflicts.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

But I can take it through the usb tree too, I have some pending stuff
and will probably prepare a pull request early next week.

cheers,
  Gerd
David Gibson Oct. 8, 2016, 8:27 a.m. UTC | #3
On Fri, Oct 07, 2016 at 10:40:45AM +0200, Gerd Hoffmann wrote:
> On Fr, 2016-10-07 at 10:49 +1100, David Gibson wrote:
> > On Thu, Oct 06, 2016 at 04:50:48PM +0200, Laurent Vivier wrote:
> > > Two minor cleanups:
> > > - exit gracefully in case on unsupported target,
> > > - put machine command line in a constant to avoid
> > >   to duplicate it.
> > > 
> > > Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > 
> > I'm not sure if I should take this through my tree or not.
> 
> Feel free to do so, makes sense to merge this together with the ppc usb
> test patches.  Avoids conflicts.
> 
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

Ok, will do.

> 
> But I can take it through the usb tree too, I have some pending stuff
> and will probably prepare a pull request early next week.
> 
> cheers,
>   Gerd
>
diff mbox

Patch

diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
index 4b951ce..e956b9c 100644
--- a/tests/usb-hcd-uhci-test.c
+++ b/tests/usb-hcd-uhci-test.c
@@ -77,6 +77,9 @@  static void test_usb_storage_hotplug(void)
 int main(int argc, char **argv)
 {
     const char *arch = qtest_get_arch();
+    const char *cmd = "-device piix3-usb-uhci,id=uhci,addr=1d.0"
+                      " -drive id=drive0,if=none,file=/dev/null,format=raw"
+                      " -device usb-tablet,bus=uhci.0,port=1";
     int ret;
 
     g_test_init(&argc, &argv, NULL);
@@ -87,13 +90,13 @@  int main(int argc, char **argv)
     qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qs = qtest_pc_boot("-device piix3-usb-uhci,id=uhci,addr=1d.0"
-                           " -drive id=drive0,if=none,file=/dev/null,format=raw"
-                           " -device usb-tablet,bus=uhci.0,port=1");
+        qs = qtest_pc_boot(cmd);
     } else if (strcmp(arch, "ppc64") == 0) {
-        qs = qtest_spapr_boot("-device piix3-usb-uhci,id=uhci,addr=1d.0"
-                           " -drive id=drive0,if=none,file=/dev/null,format=raw"
-                           " -device usb-tablet,bus=uhci.0,port=1");
+        qs = qtest_spapr_boot(cmd);
+    } else {
+        g_printerr("usb-hcd-uhci-test tests are only "
+                   "available on x86 or ppc64\n");
+        exit(EXIT_FAILURE);
     }
     ret = g_test_run();
     qtest_shutdown(qs);