From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC0E945843; Fri, 23 Aug 2024 11:30:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8EEE6402E6; Fri, 23 Aug 2024 11:30:02 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mails.dpdk.org (Postfix) with ESMTP id C10CF402CA for ; Fri, 23 Aug 2024 11:30:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724405401; x=1755941401; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=MtS8Y88pKGY+hd8je3nFO88cNRxkQvf59FDS8SZYH1Q=; b=JKAMzSQ9PsL7AfnLFdlZ/Gz29Hbtq/gT1ccdL/AtkIjIRbU0fB87QVSA S0Gw6HmFFwLWf7zpFoMRMsNbCZ9AoBy/KCCMr/7saOEDlW0GCliuxKzhZ NRiQDuGGaovj00fNE99zASBjdaqv6f/iCqCgHWI6yduTWfv88klcX2Pwi nnY9TrftyTjAhslpqwz8wNtxIrMRtTyXfzwRW4wUpD582rAKpMBowC48x pSfOWqmdPN6ugeA/iH16qsIUDluxVFfgfDVyAZio1hvInq8C6HqSGn0l3 7Zl6WLlUUM81oSfr8ICUCmBwFLNrhypblgDEMVog2HrrRyL+atMGiBtNI w==; X-CSE-ConnectionGUID: pBIS7WJ8T3CEpg8/NSO3dg== X-CSE-MsgGUID: keiuV3TJQZq/AUfiEMszgQ== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="22727266" X-IronPort-AV: E=Sophos;i="6.10,169,1719903600"; d="scan'208";a="22727266" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 02:29:59 -0700 X-CSE-ConnectionGUID: +jrbMLJ1TCOtT9FomWog6g== X-CSE-MsgGUID: Wh/Lrck4T2aI/cTSHPUe1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,169,1719903600"; d="scan'208";a="61417092" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa006.fm.intel.com with ESMTP; 23 Aug 2024 02:29:59 -0700 From: Anatoly Burakov To: dev@dpdk.org Subject: [PATCH v1 1/3] fbarray: rename tests to be more meaningful Date: Fri, 23 Aug 2024 10:29:54 +0100 Message-ID: <47e02f706d284a2e2a49db51ce75081e62aee393.1724405387.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Some tests reference internal implementation details of fbarray, as well as equivocate between mask and index. Most other test names are not very descriptive. Rename them, and adjust comments to explain things in terms of what the tests actually do, instead of referring to internal implementation details. Also, add more tests that fill up exactly one mask, with and without neighbouring set bits. Signed-off-by: Anatoly Burakov --- app/test/test_fbarray.c | 99 ++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c index 09f6907fb1..6ca509b898 100644 --- a/app/test/test_fbarray.c +++ b/app/test/test_fbarray.c @@ -104,7 +104,7 @@ static int first_msk_test_setup(void) return init_aligned(); } -static int cross_msk_test_setup(void) +static int contig_test_setup(void) { /* put all within second and third mask */ param.start = 70; @@ -112,7 +112,7 @@ static int cross_msk_test_setup(void) return init_aligned(); } -static int multi_msk_test_setup(void) +static int large_contig_test_setup(void) { /* put all within first and last mask */ param.start = 3; @@ -128,15 +128,39 @@ static int last_msk_test_setup(void) return init_aligned(); } +static int full_index_test_setup(void) +{ + /* fill entire index */ + param.start = 0; + param.end = FBARRAY_TEST_LEN - 1; + return init_aligned(); +} + static int full_msk_test_setup(void) { - /* fill entire mask */ + /* fill one mask */ param.start = 0; - param.end = FBARRAY_TEST_LEN - 1; + param.end = 63; return init_aligned(); } -static int lookahead_test_setup(void) +static int full_msk_contig_fwd_test_setup(void) +{ + /* fill one mask plus one item */ + param.start = 64; + param.end = 128; + return init_aligned(); +} + +static int full_msk_contig_rev_test_setup(void) +{ + /* fill one mask plus one item */ + param.start = 63; + param.end = 127; + return init_aligned(); +} + +static int cross_msk_test_setup(void) { /* set index 64 as used */ param.start = 64; @@ -144,7 +168,7 @@ static int lookahead_test_setup(void) return init_aligned(); } -static int lookbehind_test_setup(void) +static int cross_msk_rev_test_setup(void) { /* set index 63 as used */ param.start = 63; @@ -160,6 +184,13 @@ static int unaligned_test_setup(void) return init_unaligned(); } +static int full_unaligned_test_setup(void) +{ + unaligned.start = 0; + unaligned.end = FBARRAY_UNALIGNED_TEST_LEN - 1; + return init_unaligned(); +} + static int test_invalid(void) { struct rte_fbarray dummy; @@ -786,7 +817,7 @@ static int test_empty(void) return TEST_SUCCESS; } -static int test_lookahead(void) +static int test_cross_msk(void) { int ret; @@ -801,7 +832,7 @@ static int test_lookahead(void) return TEST_SUCCESS; } -static int test_lookbehind(void) +static int test_cross_rev_msk(void) { int ret, free_len = 2; @@ -816,19 +847,19 @@ static int test_lookbehind(void) return TEST_SUCCESS; } -static int test_lookahead_mask(void) +static int test_broken_run(void) { /* - * There is a certain type of lookahead behavior we want to test here, - * namely masking of bits that were scanned with lookahead but that we - * know do not match our criteria. This is achieved in following steps: + * There is a certain type of search behavior we want to test here, + * namely starting cross-mask runs and failing to find them. This is + * achieved when these conditions happen: * * 0. Look for a big enough chunk of free space (say, 62 elements) - * 1. Trigger lookahead by breaking a run somewhere inside mask 0 - * (indices 0-63) - * 2. Fail lookahead by breaking the run somewhere inside mask 1 - * (indices 64-127) - * 3. Ensure that we can still find free space in mask 1 afterwards + * 1. Break a run somewhere inside mask 0 (indices 0-63) but leave + * some free elements at the end of mask 0 to start a run + * 2. Break the run somewhere inside mask 1 (indices 64-127) + * 3. Ensure that we can still find a free space run right after the + * second broken run */ /* break run on first mask */ @@ -842,19 +873,19 @@ static int test_lookahead_mask(void) return TEST_SUCCESS; } -static int test_lookbehind_mask(void) +static int test_rev_broken_run(void) { /* - * There is a certain type of lookbehind behavior we want to test here, - * namely masking of bits that were scanned with lookbehind but that we - * know do not match our criteria. This is achieved in two steps: + * There is a certain type of search behavior we want to test here, + * namely starting cross-mask runs and failing to find them. This is + * achieved when these conditions happen: * * 0. Look for a big enough chunk of free space (say, 62 elements) - * 1. Trigger lookbehind by breaking a run somewhere inside mask 2 - * (indices 128-191) - * 2. Fail lookbehind by breaking the run somewhere inside mask 1 - * (indices 64-127) - * 3. Ensure that we can still find free space in mask 1 afterwards + * 1. Break a run somewhere inside mask 2 (indices 128-191) but leave + * some free elements at the beginning of mask 2 to start a run + * 2. Break the run somewhere inside mask 1 (indices 64-127) + * 3. Ensure that we can still find free space N elements down from + * our last broken run (inside mask 0 in this case) */ /* break run on mask 2 */ @@ -876,18 +907,22 @@ static struct unit_test_suite fbarray_test_suite = { TEST_CASE(test_invalid), TEST_CASE(test_basic), TEST_CASE_ST(first_msk_test_setup, reset_aligned, test_find), - TEST_CASE_ST(cross_msk_test_setup, reset_aligned, test_find), - TEST_CASE_ST(multi_msk_test_setup, reset_aligned, test_find), + TEST_CASE_ST(contig_test_setup, reset_aligned, test_find), + TEST_CASE_ST(large_contig_test_setup, reset_aligned, test_find), TEST_CASE_ST(last_msk_test_setup, reset_aligned, test_find), TEST_CASE_ST(full_msk_test_setup, reset_aligned, test_find), + TEST_CASE_ST(full_msk_contig_fwd_test_setup, reset_aligned, test_find), + TEST_CASE_ST(full_msk_contig_rev_test_setup, reset_aligned, test_find), + TEST_CASE_ST(full_index_test_setup, reset_aligned, test_find), /* empty test does not need setup */ TEST_CASE_ST(NULL, reset_aligned, test_empty), - TEST_CASE_ST(lookahead_test_setup, reset_aligned, test_lookahead), - TEST_CASE_ST(lookbehind_test_setup, reset_aligned, test_lookbehind), + TEST_CASE_ST(cross_msk_test_setup, reset_aligned, test_cross_msk), + TEST_CASE_ST(cross_msk_rev_test_setup, reset_aligned, test_cross_rev_msk), /* setup for these tests is more complex so do it in test func */ - TEST_CASE_ST(NULL, reset_aligned, test_lookahead_mask), - TEST_CASE_ST(NULL, reset_aligned, test_lookbehind_mask), + TEST_CASE_ST(NULL, reset_aligned, test_broken_run), + TEST_CASE_ST(NULL, reset_aligned, test_rev_broken_run), TEST_CASE_ST(unaligned_test_setup, reset_unaligned, test_find_unaligned), + TEST_CASE_ST(full_unaligned_test_setup, reset_unaligned, test_find_unaligned), TEST_CASES_END() } }; -- 2.43.5