summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2024-08-22 16:36:06 (GMT)
committerThomas Haller <thaller@redhat.com>2024-08-22 16:37:37 (GMT)
commit81c40cbb904fb4844411cc660eaa0fd1d5d9f5f3 (patch)
treeb437c3fbdfd7ea1154fdf4e46aa32e82b4b8e01e
parent9f5fac78f5d3b7605eb3ef359974748201b07446 (diff)
downloadlibnl-81c40cbb904fb4844411cc660eaa0fd1d5d9f5f3.zip
libnl-81c40cbb904fb4844411cc660eaa0fd1d5d9f5f3.tar.gz
libnl-81c40cbb904fb4844411cc660eaa0fd1d5d9f5f3.tar.bz2
tests: optimize _nltst_assert_route_list_permutate() to short cut search through permutations
-rw-r--r--tests/nl-test-util.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/nl-test-util.c b/tests/nl-test-util.c
index 9fd6c8b..dc8dc5a 100644
--- a/tests/nl-test-util.c
+++ b/tests/nl-test-util.c
@@ -1085,12 +1085,16 @@ _nltst_assert_route_list_permutate(const NltstAssertRouteListPermData *data,
{
size_t i;
- if (idx + 1 == num) {
- return _nltst_assert_route_list_equal(
- objs, data->expected_route_selects, num);
- }
+ if (idx + 1 == num)
+ return true;
for (i = idx; i < num; i++) {
+ if (!_nltst_select_route_match(
+ objs[i], &data->expected_route_selects[idx],
+ false)) {
+ /* This entry does not match. We can shortcut this permutation. */
+ continue;
+ }
_nl_swap(&objs[idx], &objs[i]);
if (_nltst_assert_route_list_permutate(data, objs, idx + 1,
num)) {
@@ -1137,6 +1141,14 @@ void _nltst_assert_route_list(struct nl_object *const *objs, ssize_t len,
objs2, 0, l_objs))
goto out_fail;
+ if (!_nltst_assert_route_list_equal(objs2, expected_route_selects,
+ len)) {
+ _nltst_assert_route_list_print(objs, l_objs, expected_routes,
+ l_expected);
+ ck_abort_msg(
+ "there is a in _nltst_assert_route_list_permutate(), the permutation should now match");
+ }
+
goto out_free;
out_fail: