From patchwork Tue Oct 25 22:03:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79289 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp99635qge; Tue, 25 Oct 2016 15:04:50 -0700 (PDT) X-Received: by 10.55.130.7 with SMTP id e7mr23969948qkd.121.1477433090768; Tue, 25 Oct 2016 15:04:50 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n124si14675030qke.65.2016.10.25.15.04.50; Tue, 25 Oct 2016 15:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 40BC6607CD; Tue, 25 Oct 2016 22:04:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4FBAD60CAA; Tue, 25 Oct 2016 22:03:27 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0AFA5607D9; Tue, 25 Oct 2016 22:03:19 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by lists.linaro.org (Postfix) with ESMTPS id 2636560732 for ; Tue, 25 Oct 2016 22:03:17 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id m72so120948336oik.3 for ; Tue, 25 Oct 2016 15:03:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9RBe+bCCARmdGAQ+xPP2zdQpfuBeQNYVF0QWkh0ZVxU=; b=B8Bt/Zaf5Y56kRjeLbelrL7NfcuraPRfKlJSrBMVDh9oZ+4cj6AaZZ1slVi8Jtz761 qv0cGkASRLAdvSBgGgP1wEJKMta6502f+FzB7O9ON1GTMK9a7+Tl5bDXwY/Q3cB+x/VV CGfjtwMm0BW22wtmr0pYgwQHuu8G6xi5cTaFkYDcP3Kk7cCWobSraB3W0fCQZiDhBuL8 zgrIJnuM8gpn3Tksdb0kLlpwIb83hQ/HdPQZldjwD/0eVhTQkAZQan3ZgaTKPTulQlMO P0lTPcnb3znht/JGsvXFWP3D8IsalaQ0GqOxNUrA1r0NyGUYFLx13ScVWbkRgPd/suPp eyyQ== X-Gm-Message-State: ABUngvdQiKFu8s6SpeLoJ399PgHQ2rgoocOHuWW7/pQ7qt/lrIwDQYMpgAvsogFQHaTJsINXRDo= X-Received: by 10.157.54.99 with SMTP id w90mr6655591otb.128.1477432996235; Tue, 25 Oct 2016 15:03:16 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id s23sm7363519ots.1.2016.10.25.15.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 15:03:15 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 25 Oct 2016 17:03:12 -0500 Message-Id: <1477432992-21770-4-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477432992-21770-1-git-send-email-bill.fischofer@linaro.org> References: <1477432992-21770-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 4/4] validation: random: add kindness tests X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add additional test to verify that random kindness capabilities are present and behave as advertised. Signed-off-by: Bill Fischofer --- test/common_plat/validation/api/random/random.c | 35 ++++++++++++++++++++++++- test/common_plat/validation/api/random/random.h | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/test/common_plat/validation/api/random/random.c b/test/common_plat/validation/api/random/random.c index 7572366..5aec121 100644 --- a/test/common_plat/validation/api/random/random.c +++ b/test/common_plat/validation/api/random/random.c @@ -13,12 +13,45 @@ void random_test_get_size(void) int32_t ret; uint8_t buf[32]; - ret = odp_random_data(buf, sizeof(buf), false); + ret = odp_random_data(buf, sizeof(buf), ODP_RAND_NORMAL); CU_ASSERT(ret == sizeof(buf)); } +void random_test_kind(void) +{ + odp_crypto_capability_t capa; + int32_t rc; + uint8_t buf[4096]; + uint32_t buf_size = sizeof(buf); + + rc = odp_crypto_capability(&capa); + CU_ASSERT_FATAL(rc == 0); + + if (capa.max_kind_size != 0 && capa.max_kind_size < buf_size) + buf_size = capa.max_kind_size; + + rc = odp_random_data(buf, buf_size, capa.max_kind); + CU_ASSERT((uint32_t)rc == buf_size); + + switch (capa.max_kind) { + case ODP_RAND_NORMAL: + rc = odp_random_data(buf, 4, ODP_RAND_CRYPTO); + CU_ASSERT(rc < 0); + /* Fall through */ + + case ODP_RAND_CRYPTO: + rc = odp_random_data(buf, 4, ODP_RAND_TRUE); + CU_ASSERT(rc < 0); + break; + + default: + break; + } +} + odp_testinfo_t random_suite[] = { ODP_TEST_INFO(random_test_get_size), + ODP_TEST_INFO(random_test_kind), ODP_TEST_INFO_NULL, }; diff --git a/test/common_plat/validation/api/random/random.h b/test/common_plat/validation/api/random/random.h index 26202cc..21be255 100644 --- a/test/common_plat/validation/api/random/random.h +++ b/test/common_plat/validation/api/random/random.h @@ -11,6 +11,7 @@ /* test functions: */ void random_test_get_size(void); +void random_test_kind(void); /* test arrays: */ extern odp_testinfo_t random_suite[];