From patchwork Mon Nov 17 18:33:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 40976 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AC73621F5F for ; Mon, 17 Nov 2014 18:33:54 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf1330223eek.5 for ; Mon, 17 Nov 2014 10:33:53 -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:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=HMGbkz79n+uxo9Eda7/ezNf6XISbFA1rtufYqcIgOmE=; b=WMpOq2yqrZZS5/QRU8fwhN1g2MGKur5RH9zSD19HGHtPlpYjvgt575r7XDooQI+8ta zyndYwGs8EcxelOqb+pIfpdNh8GFbe+DlETjQSgPSIS1ex5CXxPZHaoaUT86N5Z0ZXMd MiRElhrtXxV3fZ5r3sF8RMX8mDA6lJ3h06rnGhngZSGnmsPamM0kQr9ood/anV1RJY0e fwT2VPVmO8vRfVrifYW9OOl7ZeAhpqyFTAFp+DTGPqXOQbReSz05hH4nGRnIBgyMSXAm hgp/hjvKwnmTDgftBmHF3eS7GWJAbVEj8d3y0IUaehtxgWgonKMJGriJMxzEXC1eIACG 5aYw== X-Gm-Message-State: ALoCoQmgWlsl/YYBNG7VCXWh8NbE7IIXp68bOa8p1R7CJUENQfCy2h7qwja5wBbmQs732TTHvoh8 X-Received: by 10.112.166.102 with SMTP id zf6mr782935lbb.12.1416249233848; Mon, 17 Nov 2014 10:33:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.197 with SMTP id q5ls1284730lal.39.gmail; Mon, 17 Nov 2014 10:33:53 -0800 (PST) X-Received: by 10.112.243.107 with SMTP id wx11mr9165755lbc.15.1416249233597; Mon, 17 Nov 2014 10:33:53 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id j4si52855827lbn.98.2014.11.17.10.33.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 10:33:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gf13so6746222lab.41 for ; Mon, 17 Nov 2014 10:33:53 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr12423379lbr.74.1416249233491; Mon, 17 Nov 2014 10:33:53 -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 ew9csp1205520lbc; Mon, 17 Nov 2014 10:33:52 -0800 (PST) X-Received: by 10.224.96.136 with SMTP id h8mr28480815qan.13.1416249231402; Mon, 17 Nov 2014 10:33:51 -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 l19si3130527qaa.1.2014.11.17.10.33.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 17 Nov 2014 10:33:51 -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 1XqR7V-0003r2-DT; Mon, 17 Nov 2014 18:33:49 +0000 Received: from mail-qg0-f44.google.com ([209.85.192.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XqR7O-0003qr-0g for lng-odp@lists.linaro.org; Mon, 17 Nov 2014 18:33:42 +0000 Received: by mail-qg0-f44.google.com with SMTP id z60so1094632qgd.3 for ; Mon, 17 Nov 2014 10:33:35 -0800 (PST) X-Received: by 10.229.115.7 with SMTP id g7mr36491187qcq.2.1416249214999; Mon, 17 Nov 2014 10:33:34 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id q19sm26894998qam.7.2014.11.17.10.33.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Nov 2014 10:33:34 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 17 Nov 2014 13:33:19 -0500 Message-Id: <1416249199-36106-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: Architecture patch Subject: [lng-odp] [PATCH v4 ARCH] Add testing.dox 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: mike.holmes@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.215.54 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: Mike Holmes Reviewed-by: Maxim Uvarov --- Received some nit fixes now incorporated. testing.dox | 316 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 testing.dox diff --git a/testing.dox b/testing.dox new file mode 100644 index 0000000..8b210be --- /dev/null +++ b/testing.dox @@ -0,0 +1,316 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved + * + * SPDX-License-Identifier BSD-3-Clause + */ + +/** + +@page testing Testing, Verification & Validation + +@tableofcontents + +@sectiooverview Overview +The goals for ODP API testing are: + - Ensure that all platform implementations operate identically from the perspective of the application. Optional APIs or optional features of an API must operate identically between platforms but this can be to return any indication specified by the API and call ODP_UNIMPLEMENTED. + - Ensure that a given API performs to the specification defined in the published ODP Architecture & API document in source code control. The API should provide specific information on how the API will respond to its arguments. + - Catch differences in the API definition between the version of the test suite and the implementation + - GCOV or similar tool be used to ensure complete coverage of the API, note that the implementation may have less coverage than 100% but the API must be covered 100%. +Both branch and line coverage will be reported. + - New APIs are considered delivered when there is a test suite to compliment the API definition. + - Framework should be very light and configurable. + - Provide a mechanism to publish compliance to a released API version + +There are three elements to the overall test strategy. + +- @ref compliance +The simplest is the ODP Compliance test suite, this is updated with every commit that adds or modifies an ODP API. +It is intended to be very lightweight and is implemented using CUnit for the APIs, with simple scripting for the documentation. + +- @ref functional +Functional tests that attempt to perform some more in depth processing which has its output verified, for example encrypt and then decrypt a packet, checking that the result matches the input (similar to LTP). +These may require external equipment. + +- @ref benchmarking +Provides no pass fail indication but instead returns a metric on the performance of some portion of the implementation of the API + +@section logical_groups Test suite API groups + +The following logical areas for the API need to be addressed for the v1.0 release cycle. +The API logical groups will be used in the test directory structure and in defining the unit test suites +to gather the tests in to groups of related functionality. + +API logical group | Headers + :--------------- | :--- +Buffer | odp_buffer.h odp_buffer_pool.h +Packet | odp_packet_flags.h odp_packet.h +Classification | odp_classification.h +Crypt | odp_crypto.h +IPC | not defined +Pktio | odp_packet_io.h +Queue | odp_queue.h +Schedule | odp_schedule.h odp_coremask.h +Shared Memory | odp_shared_memory.h +Synchronizers / Barriers | odp_rwlock.h odp_sync.h odp_atomic.h odp_barrier.h odp_spinlock.h odp_ticketlock.h +Thread | odp_thread.h +Timer | odp_timer.h +System | odp_time.h odp_perf.h +Logging / Abort | odp_version.h odp_debug.h odp_system_info.h +Initialization | odp_init.h + +@section directory Directory structure + +Test contains all the tests that must be passed for a given revision of the API to be declared compliant. +The tests cover: + - the unit tests + - documentation tests + - functional & benchmark tests + +@verbatim +test +| +|-- functional +| |-- +| |-- / +| +|-- documentation +| |-- +| +|-- cunit + |-- + |-- / + +@endverbatim + +@section compliance ODP-Compliance test suite +Because this suite is extended with every API extension it needs to be very light weight. +This suite would be run by any new platform attempting to be API compliant, it will try to pass in the obvious combinations of arguments that arise from reading the API definition. +For example a unit test is of the following form. + +@code +/* a is in the range 0 to 10 +returns a *2 or -1 if a is out of range */ +int foo (unsigned int a) +@endcode + +Tests for foo arguments would be + - a=-check that return = -1 + - a=check that return = 0 + - a=check that return = 10 + - a=1check that return = 20 + - a=11 check that return = -1 + +The frame work to support generating these test cases is CUnit which provides batch and interactive operation. +Unit test cases do not use any external equipment. + +@section cunit CUnit +CUnit http://cunit.sourceforge.net/doc/index.html is a system for writing, administering, and running unit tests in C. +It is built as a static library which is linked with the user's testing code. +CUnit uses a simple framework for building test structures, and provides a rich set of assertions for testing common data types. +In addition, several different interfaces are provided for running tests and reporting results. +These include automated interfaces for code-controlled testing and reporting, as well as interactive interfaces allowing the user to run tests and view results dynamically. + +@subsection structure Structure +CUnit is a combination of a platform-independent framework with various user interfaces. +The core framework provides basic support for managing a test registry, suites, and test cases. +The user interfaces facilitate interaction with the framework to run tests and view results. +CUnit is organized like a conventional unit testing framework: + +@verbatim + Test Registry + | + ------------------------------ + | | + Suite '1' . . . . Suite 'N' + | | + --------------- --------------- + | | | | + Test '11' ... Test '1M' Test 'N1' ... Test 'NM' +@endverbatim + +Individual test cases are packaged into suites, which are registered with the active test registry. +Suites can have setup and tear down functions which are automatically called before and after running the suite's tests. +All suites/tests in the registry may be run using a single function call, or selected suites or tests can be run. + +@subsection general_usage General Usage + - A typical sequence of steps for using the CUnit framework is: + - Write functions for tests (and suite init/cleanup if necessary). + - Initialize the test registry - CU_initialize_registry() + - Add suites to the test registry - CU_add_suite() + - Add tests to the suites - CU_add_test() + - Run tests using an appropriate interface, e.g. CU_console_run_tests + - Cleanup the test registry - CU_cleanup_registry + +@code +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier BSD-3-Clause + */ + +#include "odp.h" +#include "CUnit/Basic.h" + +#define DEFAULT_MSG_POOL_SIZE (4*1024*1024) +#define DEFAULT_MSG_SIZE (8) + +static void test_odp_init_global(void) +{ + + int status; + status = odp_init_global(); + CU_ASSERT (status == 0) ; +} + +static int init(void) +{ + printf("ODP version:%s\n",odp_version_api_str()); + return 0; +} + + +int main(void) +{ + CU_pSuite pSuite; + CU_pTest pTest; + + /* initialize the CUnit test registry */ + if (CUE_SUCCESS != CU_initialize_registry()) + return CU_get_error(); + /* add a suite to the registry */ + pSuite = CU_add_suite("odp_init", init, NULL); + if (!pSuite) { + CU_cleanup_registry(); + return CU_get_error(); + } + /* add the tests to the suite */ + pTest == CU_ADD_TEST(pSuite, test_odp_init_global)); + if (!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(); + CU_cleanup_registry(); + return CU_get_error(); +} +@endcode + +@subsection results Normal results + +@code + CUnit - A unit testing framework for C - Version 2.1-2 + http://cunit.sourceforge.net/ + +ODP version:0.0.1 + +Suite: odp_init + Test: test_odp_init_global ... +Buffer pool init global + pool_entry_s siz 192 + pool_entry_t siz 192 + odp_buffer_hdr_t size 120 + +Queue init ... done +Queue init global + struct queue_entry_s size 192 + queue_entry_t siz 192 + +Schedule init ... done +Timer init ...done +passed + +Run Summary Type Total Ran Passed Failed Inactive + suites 1 1 n/a 0 0 + tests 1 1 1 0 0 + asserts 1 1 1 0 n/a +@endcode + + +@subsection compliance_xml Compliance results (XML) +The CUnit results may also be gathered in XML format, this format may be use to submit an implementations CUnit test case completion for inclusion on the ODP website as compliant to a given release. + +~~~{.xml} +. +. +. +. + . + . + . + . + odp initialization . + . + . + test_odp_init_global . + . + . + . + . + + . + . + Suites . + 1 . + 1 . + - NA - . + 0 . + 0 . + . + . + Test Cases . + 1 . + 1 . + 1 . + 0 . + 0 . + . + . + Assertions . + 1 . + 1 . + 1 . + 0 . + n/a . + . + . + File Generated By CUnit v2.1-2 - Thu Oct 23 15:02:46 2014 + . + +~~~ + +@section functional Functional tests + +These tests are generally more elaborate with a goal of proving a complex functionality. +@verbatim +test +. +|-- functional + |-- + |-- / +@endverbatim + - There is no framework for these tests and they generally take command line arguments to modify their behaviour. + - These tests do provide a pass fail indication. + - These tests may require network interfaces and external equipment. + +@section benchmarking Benchmarks + +Benchmarks are currently also stored with the functional tests, this may be re assessed depending on the test volume. +@verbatim +test +. +|-- functional + |-- + |-- / +@endverbatim + - These tests are generally more elaborate with a goal of quantifying the capacity of a complex functionality. + - There is no framework for these benchmarks and they generally take command line arguments to modify their behaviour. + - They do not provide a pass fail indication. + +@section test_versioning Test versioning relationship to ODP and versioning + +For ODP to declare for example the v1.0 tag in its git repository it must have passed the corresponding test suit. +When ODP API v3.0 is released it will be validated against the test suite version tagged ODP v3.0 +It is possible that a version of the ODP API is released and that the test suite used has a flaw, in this case the test suite will be re released as v3.0-1 +*/