Further changes will rely on MSR entries being sorted, so add a test
to assert it.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
- New in this version.
---
tools/tests/cpu-policy/test-cpu-policy.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index 0fa209f1ea7..ed450a09970 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -86,6 +86,16 @@ static bool leaves_are_sorted(const xen_cpuid_leaf_t *leaves, unsigned int nr)
return true;
}
+static bool msrs_are_sorted(const xen_msr_entry_t *entries, unsigned int nr)
+{
+ for ( unsigned int i = 1; i < nr; ++i )
+ /* MSR index went backwards => not sorted. */
+ if ( entries[i - 1].idx > entries[i].idx )
+ return false;
+
+ return true;
+}
+
static void test_cpuid_current(void)
{
struct cpuid_policy p;
@@ -270,6 +280,13 @@ static void test_msr_serialise_success(void)
goto test_done;
}
+ if ( !msrs_are_sorted(msrs, nr) )
+ {
+ fail(" Test %s, MSR entries not sorted\n",
+ t->name);
+ goto test_done;
+ }
+
test_done:
free(msrs);
}
--
2.30.1