From patchwork Tue Nov 25 14:05:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41465 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 EC5A5246DF for ; Tue, 25 Nov 2014 14:06:00 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id y19sf453123wgg.7 for ; Tue, 25 Nov 2014 06:06:00 -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=oFCrXXKmNRMPN2zISS+cTxwKrQu9OZ30/KaTJ7XfEYw=; b=Tkit+slhN+GG+yA60tDLM93bOIUOt/n8gtkLO+xa6HXrGt7zPdzUDYwBHZfL9G+s58 jRTjA8YLEObMlH3c3Y3Wvy9JjLBTJrr3zzfzo9SRz1ebL0XBTRzqGqX13GZ0QyeNmUIP DpEsmkiZenJxSq2zYVX+aLnKpv+O76sl+Tfhb7Pqf0pDSFe3dPHgo7NDRyXAe3Y/6Am2 pXAlqFnxK8EmiviAUrL2rujVZx5eaf+vJ/Qf9nyH3N+D7VmVXnv0M5Hfsnx7NDw3etO6 BrfVwhCWuENQOKzCzgLYU7atAOXbI+KpKRXBaIFcdga4aRyVvYYHM1bxMTFa2b3EYNDu t6bw== X-Gm-Message-State: ALoCoQnzX8ARkz233BuzuNfgC5MeygTjUbRTgE6yxqa60EBGpphGJRB90OKzRUTwG44WTJpN9T6d X-Received: by 10.112.143.136 with SMTP id se8mr444225lbb.18.1416924360149; Tue, 25 Nov 2014 06:06:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.67 with SMTP id 3ls436667las.61.gmail; Tue, 25 Nov 2014 06:05:59 -0800 (PST) X-Received: by 10.152.5.100 with SMTP id r4mr27264463lar.26.1416924359431; Tue, 25 Nov 2014 06:05:59 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id l2si1445442lbp.76.2014.11.25.06.05.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Nov 2014 06:05:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id p9so586990lbv.28 for ; Tue, 25 Nov 2014 06:05:59 -0800 (PST) X-Received: by 10.152.9.7 with SMTP id v7mr27196217laa.40.1416924359341; Tue, 25 Nov 2014 06:05:59 -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 ew9csp438990lbc; Tue, 25 Nov 2014 06:05:58 -0800 (PST) X-Received: by 10.220.74.9 with SMTP id s9mr5791269vcj.74.1416924358020; Tue, 25 Nov 2014 06:05:58 -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 tf4si415368vcb.1.2014.11.25.06.05.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Nov 2014 06:05:58 -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 1XtGkc-0005WK-MU; Tue, 25 Nov 2014 14:05:54 +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 1XtGkT-0005W1-2W for lng-odp@lists.linaro.org; Tue, 25 Nov 2014 14:05:45 +0000 Received: by mail-lb0-f181.google.com with SMTP id 10so575953lbg.26 for ; Tue, 25 Nov 2014 06:05:39 -0800 (PST) X-Received: by 10.152.27.202 with SMTP id v10mr26955788lag.13.1416924339027; Tue, 25 Nov 2014 06:05:39 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id x1sm369331laa.20.2014.11.25.06.05.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Nov 2014 06:05:38 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 25 Nov 2014 17:05:28 +0300 Message-Id: <1416924328-17663-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1416924328-17663-1-git-send-email-maxim.uvarov@linaro.org> References: <1416924328-17663-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/2] 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.169 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 Signed-off-by: Maxim Uvarov --- test/validation/odp_pktio.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index e26d820..fe22050 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,49 @@ 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; + + ret = odp_pktio_get_mac_addr(pktio, mac_addr, + &mac_len); + CU_ASSERT(0 == ret); + 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_set_mac_addr(pktio, mac_addr, ETH_ALEN); + CU_ASSERT(0 == ret); + + /* Verify */ + ret = odp_pktio_get_mac_addr(pktio, mac_addr, + &mac_len); + CU_ASSERT(0 == ret); + 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_set_mac_addr(pktio, def_mac_addr, ETH_ALEN); + CU_ASSERT(0 == ret); + + return; +} + static void test_pktio_mtu(void) { int i; @@ -152,6 +196,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();