From patchwork Thu Nov 27 17:51:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41636 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1811B244C2 for ; Thu, 27 Nov 2014 17:52:28 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id u10sf3306695lbd.10 for ; Thu, 27 Nov 2014 09:52:26 -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=5trRJIcJeIaTlloGbb6WhqAPYavm2qtxjDp76k34dQU=; b=GfG9RFuRgp8H3In42FQ5nrCZuiHQ10IQpdaRQY6C5ZvmcWMxbSHLS/rHTd+9U7lKlJ PrCh3uo31CzZVbgSYBInS2trTWot3IgnmDRa+bO3vtR24MXiuo4wkyx6CB3BcTqT1CrL 2xHXKVd7H+EX5nexaa62LI3RFdQ3Ich+FXp8aMLwL5+52pxUgsp7AlNzuMeXlPlHHbRp Jj0WhD1iPYd4pVXn3Gmo01i4RPPe2bi88WN4oRcFzphGXdP2ELLECoqM9QWHCAY0ioSG VNZNI6eMFFG2wu7Dne3bmaqnTXC35tIZ+Oxb+oOMPthmYJv7kQ2cPZmE75zaLEX1LdRF QDxQ== X-Gm-Message-State: ALoCoQmAm6Q4FdXkr3gOQ5ClxNEHAlX+U/TAvXEIy9Q4d95KJWEuo8JNMJnGyIXrqc1rfqZ1l4T4 X-Received: by 10.180.108.101 with SMTP id hj5mr8835153wib.3.1417110746767; Thu, 27 Nov 2014 09:52:26 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.134 with SMTP id ay6ls31557lab.107.gmail; Thu, 27 Nov 2014 09:52:26 -0800 (PST) X-Received: by 10.112.156.138 with SMTP id we10mr39462132lbb.88.1417110746473; Thu, 27 Nov 2014 09:52:26 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id x8si7879109lbb.86.2014.11.27.09.52.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 09:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so4560332lbd.34 for ; Thu, 27 Nov 2014 09:52:26 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr39499060laz.27.1417110746395; Thu, 27 Nov 2014 09:52:26 -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 ew9csp832677lbc; Thu, 27 Nov 2014 09:52:25 -0800 (PST) X-Received: by 10.229.90.72 with SMTP id h8mr55428038qcm.2.1417110745055; Thu, 27 Nov 2014 09:52:25 -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 x109si9182601qge.89.2014.11.27.09.52.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Nov 2014 09:52:25 -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 1Xu3Et-0005m3-4G; Thu, 27 Nov 2014 17:52:23 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xu3EV-0005hL-Ur for lng-odp@lists.linaro.org; Thu, 27 Nov 2014 17:52:00 +0000 Received: by mail-la0-f49.google.com with SMTP id hs14so4447654lab.22 for ; Thu, 27 Nov 2014 09:51:54 -0800 (PST) X-Received: by 10.112.17.1 with SMTP id k1mr39384830lbd.39.1417110714185; Thu, 27 Nov 2014 09:51:54 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-99.2com.net. [46.188.125.99]) by mx.google.com with ESMTPSA id ed8sm2020693lbb.41.2014.11.27.09.51.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 09:51:53 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 27 Nov 2014 20:51:22 +0300 Message-Id: <1417110685-2931-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417110685-2931-1-git-send-email-maxim.uvarov@linaro.org> References: <1417110685-2931-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 5/8] 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.175 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..87b55a0 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]; + size_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(-1 == ret); + + mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2); + CU_ASSERT(0 == mac_len); + + 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();