From patchwork Fri Jan 13 11:47:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91304 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp127627qgi; Fri, 13 Jan 2017 02:47:55 -0800 (PST) X-Received: by 10.36.116.71 with SMTP id o68mr1945965itc.60.1484304475535; Fri, 13 Jan 2017 02:47:55 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p186si1193530itc.56.2017.01.13.02.47.54; Fri, 13 Jan 2017 02:47:55 -0800 (PST) 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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 83A1660B29; Fri, 13 Jan 2017 10:47:54 +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, URIBL_BLOCKED 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 19F6D6083B; Fri, 13 Jan 2017 10:47:51 +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 26F84608C3; Fri, 13 Jan 2017 10:47:49 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id ECBBD607D2 for ; Fri, 13 Jan 2017 10:47:47 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id k86so33980758lfi.0 for ; Fri, 13 Jan 2017 02:47:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZFwep7XcKmHJQ99c/mKX2CovW/OQGC4SZFJ9C7NBtEg=; b=Y5kMqQPnMPrE9NDYfgPTFeKwC/m32tBvNIHTIr7460PBUlXBWSIkFY+l2R7I7O57s6 ZNXq3vBmdSUqPIGkkAzUAKAjmba1oZ5I8ns44kJ1kmJgwxNP9BVaCTDamEyQrutRVl40 vz/2/7m+PnY1+X212UIMjPzSJ+nzN5LaoMJphzXoHdsO0CMEIja0W8PAmBNE2aJ0Pyk+ nKQdlthCcEP4UbQm+j0+F4BHPH5tXQ+u4iI1O+ZsuX+t2rauKHQW2HMRrqJs0fdvqHuC rTUdfTqcMdUikJXB/2GAgCCioYXh1ZQomFdpyG+xFF9Ji/BdPCqYBu4LzarqngyVkcqU yxhg== X-Gm-Message-State: AIkVDXLYQDeAxxI9Oha21P3l3ne9AKxHcf5DPQXJa6yrDDBvKTOa1xRaFDvjTIJTV7EotpWtwEA= X-Received: by 10.25.195.76 with SMTP id t73mr5952027lff.40.1484304466731; Fri, 13 Jan 2017 02:47:46 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id k7sm3628589lfe.26.2017.01.13.02.47.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 02:47:45 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 13 Jan 2017 12:47:12 +0100 Message-Id: <1484308032-19366-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [lng-odp] [API-NEXT PATCH] test: random: adding thread based test for random 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" checking the thread safety of odp_random. Signed-off-by: Christophe Milard --- test/common_plat/validation/api/random/random.c | 46 +++++++++++++++++++++++++ test/common_plat/validation/api/random/random.h | 1 + 2 files changed, 47 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 a0e2ef7..17234db 100644 --- a/test/common_plat/validation/api/random/random.c +++ b/test/common_plat/validation/api/random/random.c @@ -8,6 +8,8 @@ #include #include "random.h" +#define STRESS_TEST_SZ 100000 + void random_test_get_size(void) { int32_t ret; @@ -61,10 +63,54 @@ void random_test_repeat(void) CU_ASSERT(memcmp(buf1, buf2, sizeof(buf1)) == 0); } +/* + * thread part for the random_test_stress + */ +static int run_test_stress(void *arg ODP_UNUSED) +{ + int32_t i; + int32_t rc; + uint8_t buf[4096]; + + odp_random_kind_t max_kind = odp_random_max_kind(); + + /* generate plenty of random data of different length and different + * quality (using the 2 first bytes of the previous iteration buffer as + * length and quality) + */ + for (i = 0; i < STRESS_TEST_SZ; i++) { + rc = odp_random_data(buf, buf[0] + 2, buf[1] % (max_kind + 1)); + CU_ASSERT(rc > 0); + } + + fflush(stdout); + return CU_get_number_of_failures(); +} + +/* + * stress tests + */ +void random_test_stress(void) +{ + pthrd_arg thrdarg; + odp_cpumask_t unused; + + thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); + if (thrdarg.numthrds > MAX_WORKERS) + thrdarg.numthrds = MAX_WORKERS; + + /* create threads */ + odp_cunit_thread_create(run_test_stress, &thrdarg); + + /* wait for all thread endings: */ + CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); +} + odp_testinfo_t random_suite[] = { ODP_TEST_INFO(random_test_get_size), ODP_TEST_INFO(random_test_kind), ODP_TEST_INFO(random_test_repeat), + ODP_TEST_INFO(random_test_stress), 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 c4bca78..f9538aa 100644 --- a/test/common_plat/validation/api/random/random.h +++ b/test/common_plat/validation/api/random/random.h @@ -13,6 +13,7 @@ void random_test_get_size(void); void random_test_kind(void); void random_test_repeat(void); +void random_test_stress(void); /* test arrays: */ extern odp_testinfo_t random_suite[];