From patchwork Tue Sep 29 23:56:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 54286 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id D782C2300D for ; Tue, 29 Sep 2015 23:59:32 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf13676792wic.1 for ; Tue, 29 Sep 2015 16:59:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list; bh=rCUskBJYz7M6z+NN3CpqrKhy04QV3NocoE+VEAB5YJk=; b=MPRnzauJpSfqK7nSWDVrtMlTEJ0yXn57M6fxP9CBEa8R7aoCpSkbUhoMd/hniLs/kq KGpmhnYacML61IQmRZkQllqtBLV3/X6QkqWme6RNGWMpNmb/yNuVkPdqPcBtgzfWz/VZ 1RbRyUrnE4GeF2XA6AFBTqbhvL4KPz5iOUwZucbkrI3Y36TWKcG4qHv7YRLf7lfDQ9RD aoc9gTiCfEBZvtx/spxI/IBI6zb7Hw7+qYLd+nQZ9w0ydxOJCdIOoO66pXo6Z1VfgvwT vBhwXCifUC7r+IRt7xk0tE6v8ZQsYg2OaGJapbbuNHmsvTKiY/H5UrpOp+A5ewr9DkIg 44Hw== X-Gm-Message-State: ALoCoQkB+irEXmjiHtXMgcbS0LA42cV66JvTXtjYWkCFetxQmfjES0yyPznVcC4oGoxnpNFaJ/Nn X-Received: by 10.180.210.212 with SMTP id mw20mr4295683wic.3.1443571172156; Tue, 29 Sep 2015 16:59:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.136 with SMTP id s8ls7567las.58.gmail; Tue, 29 Sep 2015 16:59:31 -0700 (PDT) X-Received: by 10.152.45.97 with SMTP id l1mr189985lam.15.1443571171723; Tue, 29 Sep 2015 16:59:31 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id bm7si12111535lbc.82.2015.09.29.16.59.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 16:59:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laclj5 with SMTP id lj5so27214418lac.3 for ; Tue, 29 Sep 2015 16:59:31 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr183751lbs.41.1443571171589; Tue, 29 Sep 2015 16:59:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2430644lbq; Tue, 29 Sep 2015 16:59:31 -0700 (PDT) X-Received: by 10.194.57.180 with SMTP id j20mr741403wjq.147.1443571168765; Tue, 29 Sep 2015 16:59:28 -0700 (PDT) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id ft7si32622959wib.26.2015.09.29.16.59.28 (version=TLSv1 cipher=AES128-SHA bits=128/128); Tue, 29 Sep 2015 16:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t8TNusip031250; Tue, 29 Sep 2015 19:56:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t8TNur8J032252 for ; Tue, 29 Sep 2015 19:56:53 -0400 Received: from colepc.redhat.com (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8TNuo7R015888; Tue, 29 Sep 2015 19:56:53 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 29 Sep 2015 19:56:45 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] tests: sheepdog: Drop use of virtTestResult X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: crobinso@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Instead use the same pattern that most other test files use. --- tests/storagebackendsheepdogtest.c | 63 ++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c index 7744119..2b0f4db 100644 --- a/tests/storagebackendsheepdogtest.c +++ b/tests/storagebackendsheepdogtest.c @@ -44,15 +44,28 @@ typedef struct { uint64_t expected_allocation; } collie_test; +struct testNodeInfoParserData { + collie_test data; + const char *poolxml; +}; + +struct testVDIListParserData { + collie_test data; + const char *poolxml; + const char *volxml; +}; + static int -test_node_info_parser(collie_test test, char *poolxml) +test_node_info_parser(const void *opaque) { + const struct testNodeInfoParserData *data = opaque; + collie_test test = data->data; int ret = -1; char *output = NULL; virStoragePoolDefPtr pool = NULL; - if (!(pool = virStoragePoolDefParseFile(poolxml))) + if (!(pool = virStoragePoolDefParseFile(data->poolxml))) goto cleanup; if (VIR_STRDUP(output, test.output) < 0) @@ -78,17 +91,19 @@ test_node_info_parser(collie_test test, char *poolxml) } static int -test_vdi_list_parser(collie_test test, char *poolxml, char *volxml) +test_vdi_list_parser(const void *opaque) { + const struct testVDIListParserData *data = opaque; + collie_test test = data->data; int ret = -1; char *output = NULL; virStoragePoolDefPtr pool = NULL; virStorageVolDefPtr vol = NULL; - if (!(pool = virStoragePoolDefParseFile(poolxml))) + if (!(pool = virStoragePoolDefParseFile(data->poolxml))) goto cleanup; - if (!(vol = virStorageVolDefParseFile(pool, volxml, 0))) + if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0))) goto cleanup; if (VIR_STRDUP(output, test.output) < 0) @@ -118,7 +133,7 @@ test_vdi_list_parser(collie_test test, char *poolxml, char *volxml) static int mymain(void) { - int ret = -1; + int ret = 0; char *poolxml = NULL; char *volxml = NULL; @@ -170,26 +185,42 @@ mymain(void) abs_srcdir) < 0) goto cleanup; +#define DO_TEST_NODE(collie) \ + do { \ + struct testNodeInfoParserData data = { \ + .data = collie, \ + .poolxml = poolxml, \ + }; \ + if (virtTestRun("node_info_parser", test_node_info_parser, \ + &data) < 0) \ + ret = -1; \ + } while (0) + while (test->output != NULL) { - ret = test_node_info_parser(*test, poolxml); - virtTestResult("node_info_parser", ret, NULL); + DO_TEST_NODE(*test); ++test; - if (ret < 0) - return EXIT_FAILURE; } + +#define DO_TEST_VDI(collie) \ + do { \ + struct testVDIListParserData data = { \ + .data = collie, \ + .poolxml = poolxml, \ + .volxml = volxml, \ + }; \ + if (virtTestRun("vdi_list_parser", test_vdi_list_parser, \ + &data) < 0) \ + ret = -1; \ + } while (0) + test = vdi_list_tests; while (test->output != NULL) { - ret = test_vdi_list_parser(*test, poolxml, volxml); - virtTestResult("vdi_list_parser", ret, NULL); + DO_TEST_VDI(*test); ++test; - if (ret < 0) - return EXIT_FAILURE; } - ret = 0; - cleanup: VIR_FREE(poolxml); VIR_FREE(volxml);