From patchwork Wed Nov 26 17:32:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41558 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8FE14203C2 for ; Wed, 26 Nov 2014 17:32:58 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id y19sf2080570wgg.3 for ; Wed, 26 Nov 2014 09:32:57 -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=P2JlkCZEjVRJ07uVY3TH6DeVyScScfBriTIwMi35tqY=; b=Ft70lvcO48vAXEFXFLRyScy31ZlIrNzIxGW05E7GtXzv3mBjKeGFCSgwYJ5HnsyoeN WSKtekeHVeqDMiTrFliseJqVQpY17xHXWbaT9KOSvfd49JqXNlxtB1rjUw4qEvx6g+bp pUq6jukqo9fc6hfmEGqCBEBOM4kfd+nMgbHCSFXFoV+pSPKr/3zbtEeSvmVv/8m1yKRn RDhB+MiAeR3Ge7BIPTjT0RTEf+YGRUphpyuwRy8WfrzkMvbwWhFl1816LKjZefKoZ+Pc w7iWlCX2Jm/fhuOXArEeOmm1FIuZQuOSWgGEr5QXjqNX3M5ScQcHFXtwXh9/x4+GTs/L RrcA== X-Gm-Message-State: ALoCoQmryyMkQBq+rEKcrRwWZMcVqOT7szKpZtdCNeUqg9N8A+kLactWwQgXLf04H5kSVe0rWaBZ X-Received: by 10.112.204.71 with SMTP id kw7mr895304lbc.13.1417023177844; Wed, 26 Nov 2014 09:32:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.202 with SMTP id ks10ls751644lac.72.gmail; Wed, 26 Nov 2014 09:32:57 -0800 (PST) X-Received: by 10.112.162.101 with SMTP id xz5mr34618765lbb.49.1417023177704; Wed, 26 Nov 2014 09:32:57 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id p5si5029493lbo.69.2014.11.26.09.32.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 09:32:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so2925694lam.35 for ; Wed, 26 Nov 2014 09:32:57 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr35048193lbc.34.1417023177566; Wed, 26 Nov 2014 09:32:57 -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 ew9csp664171lbc; Wed, 26 Nov 2014 09:32:56 -0800 (PST) X-Received: by 10.224.79.212 with SMTP id q20mr33772505qak.4.1417023176186; Wed, 26 Nov 2014 09:32:56 -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 i34si5732062qgf.90.2014.11.26.09.32.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Nov 2014 09:32:56 -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 1XtgSU-0003Nf-4d; Wed, 26 Nov 2014 17:32:54 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XtgS7-0003M0-Sz for lng-odp@lists.linaro.org; Wed, 26 Nov 2014 17:32:32 +0000 Received: by mail-la0-f47.google.com with SMTP id hz20so2902361lab.34 for ; Wed, 26 Nov 2014 09:32:26 -0800 (PST) X-Received: by 10.152.21.227 with SMTP id y3mr3147775lae.50.1417023146338; Wed, 26 Nov 2014 09:32:26 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id l1sm311644lae.11.2014.11.26.09.32.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 09:32:25 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Nov 2014 20:32:01 +0300 Message-Id: <1417023121-19867-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417023121-19867-1-git-send-email-maxim.uvarov@linaro.org> References: <1417023121-19867-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 5/5] 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.215.48 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 | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 56fece9..c3eb65b 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,45 @@ 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); + 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); + 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); + + return; +} + static void test_pktio_mtu(void) { int i; @@ -152,6 +192,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();