From patchwork Thu Nov 19 10:22:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 56979 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3088312lbb; Thu, 19 Nov 2015 02:22:55 -0800 (PST) X-Received: by 10.140.102.226 with SMTP id w89mr6364696qge.44.1447928575866; Thu, 19 Nov 2015 02:22:55 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e109si6170042qga.15.2015.11.19.02.22.55; Thu, 19 Nov 2015 02:22:55 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 1B61E61FCC; Thu, 19 Nov 2015 10:22:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 035A061C83; Thu, 19 Nov 2015 10:22:49 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 93FAC61D12; Thu, 19 Nov 2015 10:22:47 +0000 (UTC) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by lists.linaro.org (Postfix) with ESMTPS id 79FAE61B1A for ; Thu, 19 Nov 2015 10:22:46 +0000 (UTC) Received: by wmdw130 with SMTP id w130so233892707wmd.0 for ; Thu, 19 Nov 2015 02:22:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=W9rpmDZiJOI2ySuWDfzCy0nZXTEl+aNogZx848J40zw=; b=0/kLSTfNFY3lBehQ3zA6B3bo3N6wNB9z4I82gx2HJoyVUx0sP9aji3SAnCejRUKioD vYnqOEeZB+wzAV8TxiecSZ7TN+7g5+gNSquggh5axHCBlUwZmSMXH8EtW7ngv8evEKMu HdX292iDa2pEkPsdFsiuWPCp8jPRxpWowTGqoWAI4TRwv7YqIatCmLt1POLmm24V+3yQ wup7d5JxM+x8PCTYloUhCoHIATy7SXBUQ756uXjHoDBzmln6g2AE6up8rAv6KW53z6Mt nsBQ6toec5SPHeLE96SNRChxQIuPwkRWzZtm3RRZzBVWwMOdvM325P1POdFjR0mfUX95 fkkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=W9rpmDZiJOI2ySuWDfzCy0nZXTEl+aNogZx848J40zw=; b=O0H2wTKiFCOXaaH3EbAlouC4SWqGov0OHtQ+5MbKDpjbwRQikEF1L8EUyDWf/H+arO wOpn+cqtP3VLLcz8Ru/SlBvIzkV8dpSyH9LdHw1hVhqjjcdYu8pg+XdUymWcYt6tm60O lHCI3mRMDS5uvOfK4n3t6+cjN1bzuhqPZmJtO13wrLVnjZs0CLNzchoS3V/9jgwD2G2c VFTCJgfjdCSloywK2VEMJvtKkPuXVohvrmT1mOvpr7URMUSMgufS+C0L5GeOh6mlyClm BBe/JFAAtXQIStd0ltDVDAHgByUE4sotx7nf0ezLjWbTabonegr3fcFARkA5E5uJfxQn NDCg== X-Gm-Message-State: ALoCoQlJVeT/1cSfwZQhDWQsNF6ez63YkAVx/kqROkm0jx3h6irv23W6Q1g1GFgXB+6Ir7sWjF7u X-Received: by 10.194.120.194 with SMTP id le2mr7274528wjb.74.1447928565671; Thu, 19 Nov 2015 02:22:45 -0800 (PST) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id vr10sm7173595wjc.38.2015.11.19.02.22.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Nov 2015 02:22:45 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 19 Nov 2015 10:22:29 +0000 Message-Id: <1447928549-6030-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 MIME-Version: 1.0 X-Topics: patch Subject: [lng-odp] [PATCH] validation: remove strict dependency on CUnit 2.1-3 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" This makes it a bit easier to get a new system set up for running the unit tests. There has always been a dependency on using a version of CUnit >= 2.1-3, using an older version would result in an error: error: initialization discards ‘const’ qualifier from pointer target type [-Werror] caused by CUnit's CU_TestInfo structure taking a char * for the test name rather than a const char *, and we always pass string literals as names. Version 2.1-3 of CUnit changed this but that's still not packaged with most distributions so we end up needing to build it from source most of the time. We now don't use the CU_TestInfo structure directly in any of our tests so a couple of small changes in the common code make the issue go away. Tested with CUnit versions 2.1-2.dfsg-1 (packaged with Ubuntu 14.04) and 2.1-3 (which most people will still be using). Signed-off-by: Stuart Haslam Reviewed-by: Ivan Khoronzhuk --- There is a FAQ on the website explaining the compiler error, which could (eventually) be removed after this change. DEPENDENCIES | 2 +- test/validation/common/odp_cunit_common.c | 22 +++++++++++----------- test/validation/common/odp_cunit_common.h | 11 ++++++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 341fe69..fec65d2 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -162,7 +162,7 @@ Prerequisites for building the OpenDataPlane (ODP) API 4.1 Native Cunit install - # Debian/Ubuntu check it is 2.1-3 + # Debian/Ubuntu $ apt-get install libcunit1-dev 4.2 Built from src diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index a98042d..bc786ec 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -108,8 +108,8 @@ static odp_testinfo_t *cunit_get_test_info(odp_suiteinfo_t *sinfo, { odp_testinfo_t *tinfo; - for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) - if (strcmp(tinfo->testinfo.pName, test_name) == 0) + for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) + if (strcmp(tinfo->pName, test_name) == 0) return tinfo; return NULL; @@ -144,7 +144,7 @@ static int _cunit_suite_init(void) } /* run any configured conditional checks and mark inactive tests */ - for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) { + for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) { CU_pTest ptest; CU_ErrorCode err; @@ -152,7 +152,7 @@ static int _cunit_suite_init(void) continue; /* test is inactive, mark it as such */ - ptest = CU_get_test_by_name(tinfo->testinfo.pName, cur_suite); + ptest = CU_get_test_by_name(tinfo->pName, cur_suite); if (ptest) err = CU_set_test_active(ptest, CU_FALSE); else @@ -160,7 +160,7 @@ static int _cunit_suite_init(void) if (err != CUE_SUCCESS) { fprintf(stderr, "%s: failed to set test %s inactive\n", - __func__, tinfo->testinfo.pName); + __func__, tinfo->pName); return -1; } } @@ -187,9 +187,9 @@ static int cunit_register_suites(odp_suiteinfo_t testsuites[]) if (!suite) return CU_get_error(); - for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) { - test = CU_add_test(suite, tinfo->testinfo.pName, - tinfo->testinfo.pTestFunc); + for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) { + test = CU_add_test(suite, tinfo->pName, + tinfo->pTestFunc); if (!test) return CU_get_error(); } @@ -205,7 +205,7 @@ static int cunit_update_test(CU_pSuite suite, CU_pTest test = NULL; CU_ErrorCode err; odp_testinfo_t *tinfo; - const char *test_name = updated_tinfo->testinfo.pName; + const char *test_name = updated_tinfo->pName; tinfo = cunit_get_test_info(sinfo, test_name); if (tinfo) @@ -217,7 +217,7 @@ static int cunit_update_test(CU_pSuite suite, return -1; } - err = CU_set_test_func(test, updated_tinfo->testinfo.pTestFunc); + err = CU_set_test_func(test, updated_tinfo->pTestFunc); if (err != CUE_SUCCESS) { fprintf(stderr, "%s: failed to update test func for %s\n", __func__, test_name); @@ -261,7 +261,7 @@ static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo) return -1; } - for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) { + for (tinfo = updated_sinfo->pTests; tinfo->pName; tinfo++) { int ret; ret = cunit_update_test(suite, sinfo, tinfo); diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index c689054..8dbbb9f 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -22,7 +22,8 @@ typedef int (*cunit_test_check_active)(void); typedef struct { - CU_TestInfo testinfo; + const char *pName; + CU_TestFunc pTestFunc; cunit_test_check_active check_active; } odp_testinfo_t; @@ -38,21 +39,21 @@ static inline void odp_cunit_test_missing(void) { } /* An active test case, with the test name matching the test function name */ #define ODP_TEST_INFO(test_func) \ - {{#test_func, test_func}, NULL} + {#test_func, test_func, NULL} /* A test case that is unconditionally inactive. Its name will be registered * with CUnit but it won't be executed and will be reported as inactive in * the result summary. */ #define ODP_TEST_INFO_INACTIVE(test_func) \ - {{#test_func, odp_cunit_test_missing}, odp_cunit_test_inactive} + {#test_func, odp_cunit_test_missing, odp_cunit_test_inactive} /* A test case that may be marked as inactive at runtime based on the * return value of the cond_func function. A return value of 0 means * inactive, anything else is active. */ #define ODP_TEST_INFO_CONDITIONAL(test_func, cond_func) \ - {{#test_func, test_func}, cond_func} + {#test_func, test_func, cond_func} -#define ODP_TEST_INFO_NULL {CU_TEST_INFO_NULL, NULL} +#define ODP_TEST_INFO_NULL {NULL, NULL, NULL} #define ODP_SUITE_INFO_NULL {NULL, NULL, NULL, NULL} typedef struct {