Re: [PATCH 1/2] qemumonitorjsontest: Test CPU state handling code

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

 



On 09/18/2013 12:16 PM, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  tests/qemumonitorjsontest.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
> index b287747..0a3f717 100644
> --- a/tests/qemumonitorjsontest.c
> +++ b/tests/qemumonitorjsontest.c
> @@ -942,6 +942,61 @@ cleanup:
>      return ret;
>  }
>  
> +static int
> +testQemuMonitorJSONCPU(const void *data)
> +{
> +    const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
> +    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);

Coverity complains:

(1) Event returned_null: 	Function "qemuMonitorTestNew(bool, virDomainXMLOptionPtr, virDomainObjPtr, virQEMUDriverPtr)" returns null (checked 14 out of 16 times). [details]
(11) Event var_assigned: 	Assigning: "test" = null return value from "qemuMonitorTestNew(bool, virDomainXMLOptionPtr, virDomainObjPtr, virQEMUDriverPtr)".

> +    int ret = -1;
> +    bool running = false;
> +    virDomainPausedReason reason = 0;
> +
> +    if (qemuMonitorTestAddItem(test, "stop", "{\"return\": {}}") < 0 ||


(12) Event dereference: 	Dereferencing a pointer that might be null "test" when calling "qemuMonitorTestAddItem(qemuMonitorTestPtr, char const *, char const *)". [details]


John

> +        qemuMonitorTestAddItem(test, "query-status",
> +                               "{\"return\": {"
> +                               "   \"status\": \"paused\","
> +                               "   \"singlestep\": false,"
> +                               "   \"running\": false}}") < 0 ||
> +        qemuMonitorTestAddItem(test, "cont", "{\"return\": {}}") < 0 ||
> +        qemuMonitorTestAddItem(test, "query-status",
> +                               "{\"return\": {"
> +                               "    \"status\": \"running\","
> +                               "    \"singlestep\": false,"
> +                               "    \"running\": true}}") < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorJSONStopCPUs(qemuMonitorTestGetMonitor(test)) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
> +                             &running, &reason) < 0)
> +        goto cleanup;
> +
> +    if (running) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       "Running was not false");
> +        goto cleanup;
> +    }
> +
> +    if (qemuMonitorJSONStartCPUs(qemuMonitorTestGetMonitor(test), NULL) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
> +                             &running, &reason) < 0)
> +        goto cleanup;
> +
> +    if (!running) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       "Running was not true");
> +        goto cleanup;
> +    }
> +
> +    ret = 0;
> +
> +cleanup:
> +    qemuMonitorTestFree(test);
> +    return ret;
> +}
>  
>  static int
>  mymain(void)
> @@ -977,6 +1032,7 @@ mymain(void)
>      DO_TEST(GetObjectProperty);
>      DO_TEST(SetObjectProperty);
>      DO_TEST(GetDeviceAliases);
> +    DO_TEST(CPU);
>  
>      virObjectUnref(xmlopt);
>  
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]