From patchwork Mon Dec 1 14:08:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C9D9820672 for ; Mon, 1 Dec 2014 14:09:39 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id hs14sf3175633lab.1 for ; Mon, 01 Dec 2014 06:09:38 -0800 (PST) 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:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=2Nf3FsnTGdM5SB+l2N5+1xnOB3UOLyiGRE46XUdP/94=; b=TuraUrIioKTW8Xl5AcmKkg3j5Nyju2OHLZY23dOLAnIAwXSYbXJ7prYQflfkipO143 ct18H+ICDNiY56Lyjtxy3ojs6bvI4wTdsE8nraDzIdWUVRqksZVJxbElJVJ06DORBgTz qbzTnPl305u6LBjxtLtyjcD+Hd4TukgyeCUP0Znh70sGlqUFbE3pHtqTmpBHES3k6STG J05y0ZQKrGL7ZecU6tojKgWDro/jR6LjC/K5UH8p2tNhkWgg+PFrl1aJfg95e1pTLxH1 hR//o0OaIcJOqG0cHiAfM/Xm5nzE3yv/C3Hnz5iWnHRm/HAOUnmxY1kwnUGlN+mbOE+T gucg== X-Gm-Message-State: ALoCoQlA3Nh8s2S3DJH4BVshZaKvglQsm7syYXKM8hFswWXeCk86AN3VNLv08H0anVM5QtrXdqdk X-Received: by 10.112.53.39 with SMTP id y7mr787955lbo.8.1417442978786; Mon, 01 Dec 2014 06:09:38 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.67 with SMTP id 3ls1043980las.61.gmail; Mon, 01 Dec 2014 06:09:38 -0800 (PST) X-Received: by 10.152.28.193 with SMTP id d1mr56735001lah.17.1417442978407; Mon, 01 Dec 2014 06:09:38 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id ri4si17802159lbb.25.2014.12.01.06.09.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 06:09:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id u10so8720654lbd.3 for ; Mon, 01 Dec 2014 06:09:38 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr33651042lal.29.1417442978264; Mon, 01 Dec 2014 06:09:38 -0800 (PST) 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.184.201 with SMTP id ew9csp293245lbc; Mon, 1 Dec 2014 06:09:36 -0800 (PST) X-Received: by 10.229.174.70 with SMTP id s6mr84630323qcz.7.1417442974949; Mon, 01 Dec 2014 06:09:34 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id c12si20545835qae.103.2014.12.01.06.09.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Dec 2014 06:09:34 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvRfQ-0000wM-QQ; Mon, 01 Dec 2014 14:09:32 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvRf5-0000rq-6T for lng-odp@lists.linaro.org; Mon, 01 Dec 2014 14:09:11 +0000 Received: by mail-lb0-f181.google.com with SMTP id 10so8432704lbg.40 for ; Mon, 01 Dec 2014 06:09:05 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr56239156lbc.23.1417442945587; Mon, 01 Dec 2014 06:09:05 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id or5sm4739750lbb.42.2014.12.01.06.09.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 06:09:04 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 1 Dec 2014 17:08:43 +0300 Message-Id: <1417442928-20680-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417442928-20680-1-git-send-email-maxim.uvarov@linaro.org> References: <1417442928-20680-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 05/10] cunit: add mac test X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=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 Mac address unit test. Signed-off-by: Maxim Uvarov --- test/validation/odp_pktio.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 56fece9..1d31bf4 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -6,6 +6,7 @@ #include #include "CUnit/Basic.h" +#include #define SHM_PKT_POOL_SIZE (512 * 2048 * 2) #define SHM_PKT_POOL_BUF_SIZE (1024 * 32) @@ -15,6 +16,52 @@ static odp_pktio_t pktio; +static void test_pktio_mac(void) +{ + unsigned char mac_addr[ETH_ALEN]; + unsigned char def_mac_addr[ETH_ALEN]; + ssize_t mac_len; + int ret; + int i; + + mac_len = odp_pktio_mac_addr(pktio, mac_addr, ETH_ALEN); + CU_ASSERT(ETH_ALEN == mac_len); + + printf(" %X:%X:%X:%X:%X:%X ", + mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5]); + + /* save original mac addr */ + memcpy(def_mac_addr, mac_addr, ETH_ALEN); + + /* Modify addr */ + for (i = 0; i < ETH_ALEN; i++) + mac_addr[i] = i * 2; + + ret = odp_pktio_mac_addr_set(pktio, mac_addr, ETH_ALEN); + CU_ASSERT(0 == ret); + + /* Verify */ + mac_len = odp_pktio_mac_addr(pktio, mac_addr, ETH_ALEN); + CU_ASSERT(ETH_ALEN == mac_len); + + for (i = 0; i < ETH_ALEN; i++) + CU_ASSERT(mac_addr[i] == (i * 2)); + + /* Restore original mac */ + ret = odp_pktio_mac_addr_set(pktio, def_mac_addr, ETH_ALEN); + CU_ASSERT(0 == ret); + + /* Fail tests */ + ret = odp_pktio_mac_addr_set(pktio, def_mac_addr, 2); + CU_ASSERT(ret < 0); + + mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2); + CU_ASSERT(mac_len < 0); + + return; +} + static void test_pktio_mtu(void) { int i; @@ -152,6 +199,12 @@ int main(void) return CU_get_error(); } + ptest = CU_ADD_TEST(ptr_suite, test_pktio_mac); + if (NULL == ptest) { + CU_cleanup_registry(); + return CU_get_error(); + } + /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests();