From patchwork Wed Oct 26 16:39:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79458 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp159846qge; Wed, 26 Oct 2016 09:40:26 -0700 (PDT) X-Received: by 10.107.9.22 with SMTP id j22mr3280289ioi.150.1477500026298; Wed, 26 Oct 2016 09:40:26 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a189si3307299iog.65.2016.10.26.09.40.25; Wed, 26 Oct 2016 09:40:26 -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 1E2666180C; Wed, 26 Oct 2016 16:40:25 +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=-1.9 required=5.0 tests=BAYES_00, 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 A38436182B; Wed, 26 Oct 2016 16:39:37 +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 1674060CE2; Wed, 26 Oct 2016 16:39:33 +0000 (UTC) Received: from mail-oi0-f52.google.com (mail-oi0-f52.google.com [209.85.218.52]) by lists.linaro.org (Postfix) with ESMTPS id BD72060CB6 for ; Wed, 26 Oct 2016 16:39:31 +0000 (UTC) Received: by mail-oi0-f52.google.com with SMTP id a195so9724032oib.1 for ; Wed, 26 Oct 2016 09:39:31 -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=kFucObpxViDEChy6uUD07K7I+DE3qsjrD/kQNbm55JA=; b=dcIxnpyX5hRuW9BRwzyTcTWpZ7eOxyd6bLSNltVUMYmX+mgIZLFgyItBVrfLwa11Q0 FGGkO2HRmgLCoDnE/7CxNDbxnI8+3cE/2izATP8OmEjkwe2rgJ34UAECOOYnIGPDrvGi Qy+Ow8BXzd7lI3xxCD1xUUQB7VwN2mpBLc1J6/xLK9p/y5Rl/JQHd3KNv+Cnwgryti+1 gaYsqFiycOLcxSloOS+HuY4hsUfA4hkW6yeVNvZkyIqBJtSX9aVZVXEWf5fKrdD9qTw5 5xxKv0j2LzYcpJY0gkr9AVIAuJzWnx0erI7vo4MFR83pStU0tjEvfSozHkXFi878uVSj acRg== X-Gm-Message-State: ABUngvdvtUHo/Hbh6YhVK28OSR2QoFjALAaaMd1DAqRd8NACD43gGZhpRhhmnsPyo3ufAmlCqZc= X-Received: by 10.202.193.134 with SMTP id r128mr2193620oif.96.1477499971335; Wed, 26 Oct 2016 09:39:31 -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 f68sm844369otb.36.2016.10.26.09.39.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 09:39:31 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 26 Oct 2016 11:39:26 -0500 Message-Id: <1477499966-30632-4-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477499966-30632-1-git-send-email-bill.fischofer@linaro.org> References: <1477499966-30632-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 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 | 32 ++++++++++++++++++++++++- test/common_plat/validation/api/random/random.h | 1 + 2 files changed, 32 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..53c29d1 100644 --- a/test/common_plat/validation/api/random/random.c +++ b/test/common_plat/validation/api/random/random.c @@ -13,12 +13,42 @@ 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_RANDOM_BASIC); 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); + + rc = odp_random_data(buf, buf_size, capa.max_random_kind); + CU_ASSERT(rc > 0); + + switch (capa.max_random_kind) { + case ODP_RANDOM_BASIC: + rc = odp_random_data(buf, 4, ODP_RANDOM_CRYPTO); + CU_ASSERT(rc < 0); + /* Fall through */ + + case ODP_RANDOM_CRYPTO: + rc = odp_random_data(buf, 4, ODP_RANDOM_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[];