diff mbox

[v4,2/6] tests: don't check if qtest_spapr_boot() returns NULL

Message ID 1476435535-9408-3-git-send-email-lvivier@redhat.com
State New
Headers show

Commit Message

Laurent Vivier Oct. 14, 2016, 8:58 a.m. UTC
qtest_spapr_boot()/qtest_pc_boot()/qtest_boot() call qtest_vboot()
and qtest_vboot() calls g_malloc(),
and g_malloc() never fails:
if memory allocation fails, the application is terminated.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tests/libqos/libqos.c | 1 +
 tests/rtas-test.c     | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

Comments

Greg Kurz Oct. 14, 2016, 4:46 p.m. UTC | #1
On Fri, 14 Oct 2016 10:58:51 +0200
Laurent Vivier <lvivier@redhat.com> wrote:

> qtest_spapr_boot()/qtest_pc_boot()/qtest_boot() call qtest_vboot()
> and qtest_vboot() calls g_malloc(),
> and g_malloc() never fails:
> if memory allocation fails, the application is terminated.
> 

And even if qtest_vboot() would be using g_try_malloc(), it would crash
anyway:

    qs->qts = qtest_start(cmdline);
    qs->ops = ops;

> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  tests/libqos/libqos.c | 1 +
>  tests/rtas-test.c     | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
> index 7abb482..65d6296 100644
> --- a/tests/libqos/libqos.c
> +++ b/tests/libqos/libqos.c
> @@ -10,6 +10,7 @@
>  /**
>   * Launch QEMU with the given command line,
>   * and then set up interrupts and our guest malloc interface.
> + * Never return NULL as the application is terminated if g_malloc() fails.

True, but my point was that qtest_vboot() should never return NULL in any
case: how could the caller (i.e. a test program) could possibly recover
from such a failure ?

>   */
>  QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>  {
> diff --git a/tests/rtas-test.c b/tests/rtas-test.c
> index ba0867a..276c87e 100644
> --- a/tests/rtas-test.c
> +++ b/tests/rtas-test.c
> @@ -14,7 +14,6 @@ static void test_rtas_get_time_of_day(void)
>      time_t t1, t2;
>  
>      qs = qtest_spapr_boot("-machine pseries");
> -    g_assert(qs != NULL);
>  
>      t1 = time(NULL);
>      ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);
diff mbox

Patch

diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 7abb482..65d6296 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -10,6 +10,7 @@ 
 /**
  * Launch QEMU with the given command line,
  * and then set up interrupts and our guest malloc interface.
+ * Never return NULL as the application is terminated if g_malloc() fails.
  */
 QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
 {
diff --git a/tests/rtas-test.c b/tests/rtas-test.c
index ba0867a..276c87e 100644
--- a/tests/rtas-test.c
+++ b/tests/rtas-test.c
@@ -14,7 +14,6 @@  static void test_rtas_get_time_of_day(void)
     time_t t1, t2;
 
     qs = qtest_spapr_boot("-machine pseries");
-    g_assert(qs != NULL);
 
     t1 = time(NULL);
     ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);