[RFC,v5,4/6] eal: add unit tests for atomic bitset operations

Message ID 20240505073313.118515-4-mattias.ronnblom@ericsson.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [RFC,v4,1/4] eal: add bitset type |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues

Commit Message

Mattias Rönnblom May 5, 2024, 7:33 a.m. UTC
  Extend bitset tests to cover the basic operation of the
rte_bitset_atomic_*() family of functions.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 app/test/test_bitset.c | 48 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
  

Patch

diff --git a/app/test/test_bitset.c b/app/test/test_bitset.c
index b3496df1c0..32224a1eee 100644
--- a/app/test/test_bitset.c
+++ b/app/test/test_bitset.c
@@ -222,6 +222,52 @@  test_flip(void)
 			     rte_bitset_flip);
 }
 
+static bool
+bitset_atomic_test(const uint64_t *bitset, size_t bit_num)
+{
+	return rte_bitset_atomic_test(bitset, bit_num,
+				      rte_memory_order_relaxed);
+}
+
+static void
+bitset_atomic_set(uint64_t *bitset, size_t bit_num)
+{
+	rte_bitset_atomic_set(bitset, bit_num, rte_memory_order_relaxed);
+}
+
+static void
+bitset_atomic_clear(uint64_t *bitset, size_t bit_num)
+{
+	rte_bitset_atomic_clear(bitset, bit_num, rte_memory_order_relaxed);
+}
+
+static void
+bitset_atomic_flip(uint64_t *bitset, size_t bit_num)
+{
+	rte_bitset_atomic_flip(bitset, bit_num, rte_memory_order_relaxed);
+}
+
+static void
+bitset_atomic_assign(uint64_t *bitset, size_t bit_num, bool bit_value)
+{
+	rte_bitset_atomic_assign(bitset, bit_num, bit_value,
+				 rte_memory_order_relaxed);
+}
+
+static int
+test_atomic_set_clear(void)
+{
+	return test_set_clear_fun(bitset_atomic_test, bitset_atomic_set,
+				  bitset_atomic_clear);
+}
+
+static int
+test_atomic_flip(void)
+{
+	return test_flip_fun(bitset_atomic_test, bitset_atomic_assign,
+			     bitset_atomic_flip);
+}
+
 static ssize_t
 find(const bool *ary, size_t num_bools, size_t start, size_t len, bool set)
 {
@@ -868,6 +914,8 @@  static struct unit_test_suite bitset_tests  = {
 	.unit_test_cases = {
 		TEST_CASE_ST(NULL, NULL, test_set_clear),
 		TEST_CASE_ST(NULL, NULL, test_flip),
+		TEST_CASE_ST(NULL, NULL, test_atomic_set_clear),
+		TEST_CASE_ST(NULL, NULL, test_atomic_flip),
 		TEST_CASE_ST(NULL, NULL, test_find),
 		TEST_CASE_ST(NULL, NULL, test_foreach),
 		TEST_CASE_ST(NULL, NULL, test_count),