From patchwork Tue Oct 25 12:49:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79170 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp3094085qge; Tue, 25 Oct 2016 05:50:02 -0700 (PDT) X-Received: by 10.36.65.39 with SMTP id x39mr1463588ita.103.1477399802406; Tue, 25 Oct 2016 05:50:02 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x15si1257698ite.121.2016.10.25.05.50.02; Tue, 25 Oct 2016 05:50:02 -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 DC72760E53; Tue, 25 Oct 2016 12:50:01 +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 7A40760A56; Tue, 25 Oct 2016 12:49:18 +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 5A6E3609FB; Tue, 25 Oct 2016 12:49:12 +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 C481A60A1F for ; Tue, 25 Oct 2016 12:49:09 +0000 (UTC) Received: by mail-oi0-f52.google.com with SMTP id i127so42037090oia.2 for ; Tue, 25 Oct 2016 05:49:09 -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=yfWUPpZyRxEcQmo7qrWH3mUeZaaqyVlcKOfDEgCL9h0=; b=IQ6CjjLBXlx0sZr9dJG+ikbftw2DGmEm813X9bEj2E4hWS/v5geGFsGxVBxkxEQNa2 KWj0Xl+XskH+WcpqCxi9VVXEPiVTsn+ldZNtmKSlSkJNpsSC38Lh5i/TLnUtR2P4qpS4 Cl1FLuWcidmNwSCknh//lTZKqEnF6oZqeLUf8KER5Z5iHNcDaNyvDwhqj54tjyklPS8+ hZOotiXMc3vD33k57DEkEKGBzCOdfAT+2mH7RmlNaQzI6kRKXMMXluBIaGNZoIwhjhtd EGauP6HNOOCtNZWueiydgxktykOh3Qnwl5Xa64XVnAZV4/7v66PCZsgpx00EptsFylVW ZC7Q== X-Gm-Message-State: ABUngve8cgUidFLQj1+SShPPHKm6dGl+IDCm1mZXKuTCKh8xP2enl8tgoUXw6SE7f5jjyBFEnt0= X-Received: by 10.157.22.203 with SMTP id s11mr5026172ots.229.1477399749321; Tue, 25 Oct 2016 05:49:09 -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 g17sm6296544otd.38.2016.10.25.05.49.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 05:49:08 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 25 Oct 2016 07:49:04 -0500 Message-Id: <1477399744-16516-4-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477399744-16516-1-git-send-email-bill.fischofer@linaro.org> References: <1477399744-16516-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 4/4] validation: random: add entropy 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 entropy capabilities are present and behave as advertised. Signed-off-by: Bill Fischofer --- test/common_plat/validation/api/random/random.c | 22 ++++++++++++++++++++++ test/common_plat/validation/api/random/random.h | 1 + 2 files changed, 23 insertions(+) -- 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..637e042 100644 --- a/test/common_plat/validation/api/random/random.c +++ b/test/common_plat/validation/api/random/random.c @@ -17,8 +17,30 @@ void random_test_get_size(void) CU_ASSERT(ret == sizeof(buf)); } +void random_test_entropy(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.entropy_available) { + if (capa.entropy_size < buf_size) + buf_size = capa.entropy_size; + rc = odp_random_data(buf, buf_size, true); + CU_ASSERT((uint32_t)rc == buf_size); + } else { + rc = odp_random_data(buf, 4, true); + CU_ASSERT(rc < 0); + } +} + odp_testinfo_t random_suite[] = { ODP_TEST_INFO(random_test_get_size), + ODP_TEST_INFO(random_test_entropy), 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..7dbeba7 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_entropy(void); /* test arrays: */ extern odp_testinfo_t random_suite[];