From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mz9SL-0005nT-6V for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mz9SF-0005jw-54 for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:23 -0400 Received: from [199.232.76.173] (port=58961 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mz9SE-0005jm-RG for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:18 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:55252) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mz9SE-0000OI-C5 for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:18 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9HDPMnK032280 for ; Sat, 17 Oct 2009 07:25:22 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9HDaDGB081908 for ; Sat, 17 Oct 2009 07:36:13 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n9HDaCbx021490 for ; Sat, 17 Oct 2009 07:36:13 -0600 From: Anthony Liguori Date: Sat, 17 Oct 2009 08:36:03 -0500 Message-Id: <1255786571-3528-4-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> References: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 03/11] Add a test case for qfloat List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori Signed-off-by: Anthony Liguori --- Makefile | 2 + check-qfloat.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 + * + * Copyright IBM, Corp. 2009 + * + * Authors: + * Anthony Liguori + * + * 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 + +#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