[dpdk-dev,2/2] test: update common auto test

Message ID 20180314094100.12373-2-pbhagavatula@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pavan Nikhilesh March 14, 2018, 9:41 a.m. UTC
  Update common auto test to include test for aligning values to multiples
of given integer.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 test/test/test_common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Thomas Monjalon March 15, 2018, 11:53 p.m. UTC | #1
14/03/2018 10:41, Pavan Nikhilesh:
> Update common auto test to include test for aligning values to multiples
> of given integer.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>  test/test/test_common.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

The unit test can be in the same patch as the code.
A single patch is fine here.
  
Pavan Nikhilesh March 16, 2018, 8:56 a.m. UTC | #2
On Fri, Mar 16, 2018 at 12:53:27AM +0100, Thomas Monjalon wrote:
> 14/03/2018 10:41, Pavan Nikhilesh:
> > Update common auto test to include test for aligning values to multiples
> > of given integer.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > ---
> >  test/test/test_common.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
>
> The unit test can be in the same patch as the code.
> A single patch is fine here.

Sure, will merge them in v2.
>
>
>
  

Patch

diff --git a/test/test/test_common.c b/test/test/test_common.c
index d0342430f..e43cba49b 100644
--- a/test/test/test_common.c
+++ b/test/test/test_common.c
@@ -128,6 +128,18 @@  test_align(void)
 				FAIL("rte_is_aligned");
 		}
 	}
+
+	for (p = 1; p <= MAX_NUM / 2; p++) {
+		for (i = 1; i <= MAX_NUM / 2; i++) {
+			val = RTE_ALIGN_MUL_CEIL(i, p);
+			if (val % p != 0 || val < i)
+				FAIL_ALIGN("RTE_ALIGN_MUL_CEIL", i, p);
+			val = RTE_ALIGN_MUL_FLOOR(i, p);
+			if (val % p != 0 || val > i)
+				FAIL_ALIGN("RTE_ALIGN_MUL_FLOOR", i, p);
+		}
+	}
+
 	return 0;
 }