[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/11] Add a test case for qfloat
From: |
Edgar E. Iglesias |
Subject: |
Re: [Qemu-devel] [PATCH 03/11] Add a test case for qfloat |
Date: |
Sat, 17 Oct 2009 16:00:00 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Sat, Oct 17, 2009 at 08:36:03AM -0500, Anthony Liguori wrote:
> Signed-off-by: Anthony Liguori <address@hidden>
> ---
> Makefile | 2 +
> check-qfloat.c | 81
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hello Anthony,
Shouldn't we put these tests under tests/something/ ?
Cheers
> configure | 2 +-
> 3 files changed, 84 insertions(+), 1 deletions(-)
> create mode 100644 check-qfloat.c
>
> diff --git a/Makefile b/Makefile
> index 9294638..aedb6c7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -216,6 +216,8 @@ check-qint: check-qint.o qint.o qemu-malloc.o
> check-qstring: check-qstring.o qstring.o qemu-malloc.o
> check-qdict: check-qdict.o qdict.o qint.o qstring.o qemu-malloc.o
> check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o
> +check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o
> +
>
> clean:
> # avoid old build problems by removing potentially incorrect old files
> diff --git a/check-qfloat.c b/check-qfloat.c
> new file mode 100644
> index 0000000..3758700
> --- /dev/null
> +++ b/check-qfloat.c
> @@ -0,0 +1,81 @@
> +/*
> + * QFloat unit-tests.
> + *
> + * Copyright (C) 2009 Red Hat Inc.
> + *
> + * Authors:
> + * Luiz Capitulino <address@hidden>
> + *
> + * Copyright IBM, Corp. 2009
> + *
> + * Authors:
> + * Anthony Liguori <address@hidden>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.1 or
> later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +#include <check.h>
> +
> +#include "qfloat.h"
> +#include "qemu-common.h"
> +
> +/*
> + * Public Interface test-cases
> + *
> + * (with some violations to access 'private' data)
> + */
> +
> +START_TEST(qfloat_from_double_test)
> +{
> + QFloat *qf;
> + const double value = -42.23423;
> +
> + qf = qfloat_from_double(value);
> + fail_unless(qf != NULL);
> + fail_unless(qf->value == value);
> + fail_unless(qf->base.refcnt == 1);
> + fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
> +
> + // destroy doesn't exit yet
> + qemu_free(qf);
> +}
> +END_TEST
> +
> +START_TEST(qfloat_destroy_test)
> +{
> + QFloat *qf = qfloat_from_double(0.0);
> + QDECREF(qf);
> +}
> +END_TEST
> +
> +static Suite *qfloat_suite(void)
> +{
> + Suite *s;
> + TCase *qfloat_public_tcase;
> +
> + s = suite_create("QFloat test-suite");
> +
> + qfloat_public_tcase = tcase_create("Public Interface");
> + suite_add_tcase(s, qfloat_public_tcase);
> + tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
> + tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
> +
> + return s;
> +}
> +
> +int main(void)
> +{
> + int nf;
> + Suite *s;
> + SRunner *sr;
> +
> + s = qfloat_suite();
> + sr = srunner_create(s);
> +
> + srunner_run_all(sr, CK_NORMAL);
> + nf = srunner_ntests_failed(sr);
> + srunner_free(sr);
> +
> + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
> +}
> diff --git a/configure b/configure
> index ca6d45c..3e6f980 100755
> --- a/configure
> +++ b/configure
> @@ -2024,7 +2024,7 @@ if test `expr "$target_list" : ".*softmmu.*"` != 0 ;
> then
> if [ "$linux" = "yes" ] ; then
> tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
> if [ "$check_utests" = "yes" ]; then
> - tools="check-qint check-qstring check-qdict check-qlist $tools"
> + tools="check-qint check-qstring check-qdict check-qlist check-qfloat
> $tools"
> fi
> elif test "$mingw32" = "yes" ; then
> tools="qemu-io\$(EXESUF) $tools"
> --
> 1.6.2.5
>
>
>
- Re: [Qemu-devel] [PATCH 01/11] Add append method to qstring and empty constructor, (continued)
- [Qemu-devel] [PATCH 02/11] Add support for qfloat, Anthony Liguori, 2009/10/17
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Luiz Capitulino, 2009/10/18
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Anthony Liguori, 2009/10/19
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Amit Shah, 2009/10/22
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Anthony Liguori, 2009/10/22
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Amit Shah, 2009/10/22
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Jamie Lokier, 2009/10/23
- Re: [Qemu-devel] [PATCH 02/11] Add support for qfloat, Daniel P. Berrange, 2009/10/23
[Qemu-devel] [PATCH 03/11] Add a test case for qfloat, Anthony Liguori, 2009/10/17
- Re: [Qemu-devel] [PATCH 03/11] Add a test case for qfloat,
Edgar E. Iglesias <=
[Qemu-devel] [PATCH 04/11] Add json->qobject parser, Anthony Liguori, 2009/10/17
[Qemu-devel] [PATCH 07/11] qjson: Use QBool for true/false keywords, Anthony Liguori, 2009/10/17
[Qemu-devel] [PATCH 08/11] qjson: add %i for parsing bools, Anthony Liguori, 2009/10/17
[Qemu-devel] [PATCH 06/11] qobject: add QBool type, Anthony Liguori, 2009/10/17
[Qemu-devel] [PATCH 05/11] Add unit test for json parser, Anthony Liguori, 2009/10/17