From patchwork Mon Dec 1 16:15:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41791 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B144E20672 for ; Mon, 1 Dec 2014 16:16:28 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf6923284lbj.3 for ; Mon, 01 Dec 2014 08:16:27 -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=q4Y0DTJVZss/t5KMDdkAwJ4W6MrSyAHktUGR97kTHm8=; b=b1UujZ35BEmB25+N3khouPlSSHLpTg9evTGuBvDrfkvh/E8Eq0oKnsAeHUT/Uoypsn e+lVJBaNbe94ymDMctYE20KNT785ddWygfOazfIIQKCW2OYETF2cpjAUCAOeetDSCmXX ht+lSkT5wuj9DPhoyqbXIvv3lb9b4wGHB91S89Yee33TiuE49WcLFIbsJFtGIC5BJlWc ZjnPN5DHCIJHDZfyE5p0MmFk7abHkylVd46p4/e3I8na7vRKhFL7Q30CcvcyIZXHUsmZ hm4QLC6oG1BHdZEpO0JFvqqrXDuBdk4ck5aHI1ZtVyaVmyaedymPt2vbSDN743cnR8w9 EM5w== X-Gm-Message-State: ALoCoQmHPEZWMr2SWkAyksr7btoHhelkjtAk9oXUWL1pNs3CpbmSSAFJcqUywpp0XPMl3yBcy0NJ X-Received: by 10.112.142.36 with SMTP id rt4mr16022393lbb.3.1417450587662; Mon, 01 Dec 2014 08:16:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.232 with SMTP id m8ls1092134laa.45.gmail; Mon, 01 Dec 2014 08:16:27 -0800 (PST) X-Received: by 10.112.144.228 with SMTP id sp4mr56446108lbb.58.1417450587139; Mon, 01 Dec 2014 08:16:27 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id t4si552143lag.49.2014.12.01.08.16.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:16:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so8956161lab.4 for ; Mon, 01 Dec 2014 08:16:27 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr56269332lbr.74.1417450587064; Mon, 01 Dec 2014 08:16:27 -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 ew9csp319941lbc; Mon, 1 Dec 2014 08:16:26 -0800 (PST) X-Received: by 10.170.218.8 with SMTP id k8mr67436279ykf.38.1417450585369; Mon, 01 Dec 2014 08:16: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 q19si11278276qad.3.2014.12.01.08.16.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:16: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 1XvTeB-0007D2-L7; Mon, 01 Dec 2014 16:16:23 +0000 Received: from mail-lb0-f171.google.com ([209.85.217.171]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvTdo-0007AS-2w for lng-odp@lists.linaro.org; Mon, 01 Dec 2014 16:16:00 +0000 Received: by mail-lb0-f171.google.com with SMTP id n15so8841275lbi.2 for ; Mon, 01 Dec 2014 08:15:54 -0800 (PST) X-Received: by 10.112.173.39 with SMTP id bh7mr58837413lbc.53.1417450554579; Mon, 01 Dec 2014 08:15:54 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id ar4sm4819466lbc.48.2014.12.01.08.15.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:15:53 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 1 Dec 2014 19:15:31 +0300 Message-Id: <1417450537-7640-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417450537-7640-1-git-send-email-maxim.uvarov@linaro.org> References: <1417450537-7640-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 05/11] 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.45 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 edbf0c9..9f3cb40 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();