Received: from eggs.gnu.org ([140.186.70.92]:50629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkHaU-0003Kj-QY for qemu-devel@nongnu.org; Mon, 09 Jan 2012 10:56:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkHaO-000116-S7 for qemu-devel@nongnu.org; Mon, 09 Jan 2012 10:56:42 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:44803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkHaO-000111-MP for qemu-devel@nongnu.org; Mon, 09 Jan 2012 10:56:36 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Jan 2012 10:56:34 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q09FuVTR282792 for ; Mon, 9 Jan 2012 10:56:31 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q09FuTMa008900 for ; Mon, 9 Jan 2012 13:56:29 -0200 From: Anthony Liguori Date: Mon, 9 Jan 2012 09:56:06 -0600 Message-Id: <1326124572-8312-5-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1326124572-8312-1-git-send-email-aliguori@us.ibm.com> References: <1326124572-8312-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 05/11] check-qint: convert to gtest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Luiz Capitulino Signed-off-by: Anthony Liguori --- check-qint.c | 68 ++++++++++++++++++---------------------------------------- configure | 4 +- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/check-qint.c b/check-qint.c index 3af51f2..5a27119 100644 --- a/check-qint.c +++ b/check-qint.c @@ -9,7 +9,7 @@ * 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 #include "qint.h" #include "qemu-common.h" @@ -20,94 +20,68 @@ * (with some violations to access 'private' data) */ -START_TEST(qint_from_int_test) +static void qint_from_int_test(void) { QInt *qi; const int value = -42; qi = qint_from_int(value); - fail_unless(qi != NULL); - fail_unless(qi->value == value); - fail_unless(qi->base.refcnt == 1); - fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT); + g_assert(qi != NULL); + g_assert(qi->value == value); + g_assert(qi->base.refcnt == 1); + g_assert(qobject_type(QOBJECT(qi)) == QTYPE_QINT); // destroy doesn't exit yet g_free(qi); } -END_TEST -START_TEST(qint_destroy_test) +static void qint_destroy_test(void) { QInt *qi = qint_from_int(0); QDECREF(qi); } -END_TEST -START_TEST(qint_from_int64_test) +static void qint_from_int64_test(void) { QInt *qi; const int64_t value = 0x1234567890abcdefLL; qi = qint_from_int(value); - fail_unless((int64_t) qi->value == value); + g_assert((int64_t) qi->value == value); QDECREF(qi); } -END_TEST -START_TEST(qint_get_int_test) +static void qint_get_int_test(void) { QInt *qi; const int value = 123456; qi = qint_from_int(value); - fail_unless(qint_get_int(qi) == value); + g_assert(qint_get_int(qi) == value); QDECREF(qi); } -END_TEST -START_TEST(qobject_to_qint_test) +static void qobject_to_qint_test(void) { QInt *qi; qi = qint_from_int(0); - fail_unless(qobject_to_qint(QOBJECT(qi)) == qi); + g_assert(qobject_to_qint(QOBJECT(qi)) == qi); QDECREF(qi); } -END_TEST -static Suite *qint_suite(void) +int main(int argc, char **argv) { - Suite *s; - TCase *qint_public_tcase; + g_test_init(&argc, &argv, NULL); - s = suite_create("QInt test-suite"); + g_test_add_func("/public/from_int", qint_from_int_test); + g_test_add_func("/public/destroy", qint_destroy_test); + g_test_add_func("/public/from_int64", qint_from_int64_test); + g_test_add_func("/public/get_int", qint_get_int_test); + g_test_add_func("/public/to_qint", qobject_to_qint_test); - qint_public_tcase = tcase_create("Public Interface"); - suite_add_tcase(s, qint_public_tcase); - tcase_add_test(qint_public_tcase, qint_from_int_test); - tcase_add_test(qint_public_tcase, qint_destroy_test); - tcase_add_test(qint_public_tcase, qint_from_int64_test); - tcase_add_test(qint_public_tcase, qint_get_int_test); - tcase_add_test(qint_public_tcase, qobject_to_qint_test); - - return s; -} - -int main(void) -{ - int nf; - Suite *s; - SRunner *sr; - - s = qint_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; + return g_test_run(); } diff --git a/configure b/configure index a7a6758..cea9cb6 100755 --- a/configure +++ b/configure @@ -2800,10 +2800,10 @@ if test "$softmmu" = yes ; then tools="qemu-ga\$(EXESUF) $tools" fi if [ "$check_utests" = "yes" ]; then - checks="check-qint check-qstring check-qlist" + checks="check-qstring check-qlist" checks="check-qjson $checks" fi - test_progs="$checks check-qdict check-qfloat test-coroutine test-qmp-output-visitor test-qmp-input-visitor" + test_progs="$checks check-qdict check-qfloat check-qint test-coroutine test-qmp-output-visitor test-qmp-input-visitor" fi fi -- 1.7.4.1