[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tests/cpu-policy: add sorted MSR test
commit b8e53a81ba538849b98b0d417436f8be653fa1ff Author: Roger Pau Monne <roger.pau@xxxxxxxxxx> AuthorDate: Tue Apr 13 14:51:44 2021 +0200 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Thu Apr 29 19:27:21 2021 +0100 tests/cpu-policy: add sorted MSR test Further changes will rely on MSR entries being sorted, so add a test to assert it. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- 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 cb578ca6e5..75973298df 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -89,6 +89,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; @@ -273,6 +283,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); } -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |