xen/mm: Host-side unit/integration test framework for page_alloc.c
cover xen/mm: Host-side unit/integration test framework for page_alloc.c
Hi all,
This patch series adds a host-side unit and integration test framework for the Xen page allocator in xen/common/page_alloc.c.
Using this framework, it also adds a host-side integration test suite for memory claims, including NUMA-aware claim sets.
This test suite complements the functional system tests submitted as part of the NUMA-aware claims v6 series yesterday.
The purpose is to verify the behaviour of the page allocator when multi-node claim sets are present in situations that are easier to create and validate in isolation, with full control over a synthetic Xen heap state and visibility into the claim state of domains as claims are made and redeemed through heap allocation.
This series depends on the NUMA claims v6 series, which introduced NUMA-aware claim sets which I submitted yesterday:
[PATCH v6 0/7] xen/mm: Introduce NUMA-aware claim sets for domains
https://lists.xen.org/archives/html/xen-devel/2026-04/msg00587.html
https://patchwork.kernel.org/project/xen-devel/list/?series=1081139
Its design is described in this design document submitted yesterday:
[PATCH v2] docs: Draft Design Document for NUMA-aware claim sets
https://lists.xen.org/archives/html/xen-devel/2026-04/msg00569.html
https://patchwork.kernel.org/project/xen-devel/list/?series=1081047
Patch summary:
1. tools/tests/alloc: Add test framework for xen/common/page_alloc.c
2. tools/tests/alloc: Add integration tests for claims and claim sets
3. tools/tests/alloc: Add tests for offlining with claims present
4. xen/mm: Fix recalling claims when offlining pages if needed
Thanks,
Bernhard Kaindl
---
PS: The bug fixed in the last commit of this series affects global outstanding claims as implemented in current Xen master as well.
However, this only arises when Xen offlines pages. Page offlining code in current Xen still has known limitations, particularly when offlining pages from larger buddies, and should be avoided in the interest of heap integrity.
That said, this test framework makes it possible to run targeted test cases on a synthetic Xen heap and observe logged changes to the heap during page offlining.
That should make further offlining fixes easier to validate, both by checking the test results and by inspecting the resulting heap state.
If you are interested in that, the next series will add a test suite for offlining pages using this test framework. That should make it possible to observe the effects of the bugs and the corresponding fixes on any machine able to compile Xen source code.
Bernhard Kaindl (4):
tools/tests/alloc: Unit and Integration Test Framework for
page_alloc.c
tools/tests/alloc: Add integration test suite for memory claims tools/tests/alloc: Add tests for offlining with claims present xen/mm: Recall claims when offlining pages if needed
tools/tests/Makefile | 1 + tools/tests/alloc/.gitignore | 6 + tools/tests/alloc/Makefile | 141 ++++++ tools/tests/alloc/README.rst | 31 ++ tools/tests/alloc/check-asserts.h | 347 +++++++++++++++ tools/tests/alloc/harness.h | 69 +++ tools/tests/alloc/hypervisor-macros.h | 101 +++++ tools/tests/alloc/libtest-page_alloc.h | 356 +++++++++++++++ tools/tests/alloc/mock-page_list.h | 307 +++++++++++++ tools/tests/alloc/page_alloc-wrapper.h | 465 ++++++++++++++++++++ tools/tests/alloc/page_alloc_shim.h | 433 ++++++++++++++++++ tools/tests/alloc/test-claims_basic.c | 230 ++++++++++ tools/tests/alloc/test-claims_numa_redeem.c | 201 +++++++++ tools/tests/alloc/test-offlining-claims.c | 102 +++++ xen/common/page_alloc.c | 42 ++ 15 files changed, 2832 insertions(+) create mode 100644 tools/tests/alloc/.gitignore create mode 100644 tools/tests/alloc/Makefile create mode 100644 tools/tests/alloc/README.rst create mode 100644 tools/tests/alloc/check-asserts.h create mode 100644 tools/tests/alloc/harness.h create mode 100644 tools/tests/alloc/hypervisor-macros.h create mode 100644 tools/tests/alloc/libtest-page_alloc.h create mode 100644 tools/tests/alloc/mock-page_list.h create mode 100644 tools/tests/alloc/page_alloc-wrapper.h create mode 100644 tools/tests/alloc/page_alloc_shim.h create mode 100644 tools/tests/alloc/test-claims_basic.c create mode 100644 tools/tests/alloc/test-claims_numa_redeem.c create mode 100644 tools/tests/alloc/test-offlining-claims.c
Signature · 1 line
2.39.5
PATCH 1/4 tools/tests/alloc: Unit and Integration Test Framework for page_alloc.c
Add a test framefork for unit and integration test suites testing the Xen page allocator module xen/common/page_alloc.c in isolation.
It enables test suites to verify the behaviour of the page allocator in situations that are easier to create and validate in isolation, with full control over a synthetic Xen heap state and visibility into the allocator and domain state.
--- tools/tests/Makefile | 1 + tools/tests/alloc/.gitignore | 6 + tools/tests/alloc/Makefile | 141 ++++++++ tools/tests/alloc/README.rst | 31 ++ tools/tests/alloc/check-asserts.h | 347 ++++++++++++++++++ tools/tests/alloc/harness.h | 69 ++++ tools/tests/alloc/hypervisor-macros.h | 101 ++++++ tools/tests/alloc/libtest-page_alloc.h | 356 +++++++++++++++++++ tools/tests/alloc/mock-page_list.h | 307 ++++++++++++++++ tools/tests/alloc/page_alloc-wrapper.h | 465 +++++++++++++++++++++++++ tools/tests/alloc/page_alloc_shim.h | 433 +++++++++++++++++++++++ 11 files changed, 2257 insertions(+) create mode 100644 tools/tests/alloc/.gitignore create mode 100644 tools/tests/alloc/Makefile create mode 100644 tools/tests/alloc/README.rst create mode 100644 tools/tests/alloc/check-asserts.h create mode 100644 tools/tests/alloc/harness.h create mode 100644 tools/tests/alloc/hypervisor-macros.h create mode 100644 tools/tests/alloc/libtest-page_alloc.h create mode 100644 tools/tests/alloc/mock-page_list.h create mode 100644 tools/tests/alloc/page_alloc-wrapper.h create mode 100644 tools/tests/alloc/page_alloc_shim.h
tools/tests/Makefile +1 -0
@@ -2,6 +2,7 @@ XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/Rules.mk SUBDIRS-y := +SUBDIRS-y += alloc SUBDIRS-y += domid SUBDIRS-y += mem-claim SUBDIRS-y += paging-mempool
tools/tests/alloc/.gitignore new file +6 -0
@@ -0,0 +1,6 @@ +/test-claims_basic +/test-claims_numa_install +/test-claims_numa_redeem +/test-online_page +/test-offlining-claims +/test-reserve_offline_page
tools/tests/alloc/Makefile new file +141 -0
141 lines not on this page · raw message
tools/tests/alloc/README.rst new file +31 -0
@@ -0,0 +1,31 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +Unit and Integration test suite for the page allocator +====================================================== + +The tests in ``tools/tests/alloc`` contain unit tests for the +Xen page allocator in ``xen/common/page_alloc.c`` and are +built as standalone executables. + +They are not intended to be run in a Xen environment, but rather to test +the allocator logic in isolation and can be run on any compatible host +system at build time and do not use any installed libraries or require +any special setup or dependencies beyond the standard C library. + +The tests use a shim as a substitute for Xen hypervisor code that would +conflict with running the page allocator as a host executable, and they +use helper functions to initialize and assert the status of the data +structures of the allocator such as the page lists and zones. + +The tests can be run with the ``run`` target of the ``Makefile``, which +will execute all the test executables and report their results unless +you override the TARGETS variable to run a specific test: + +.. code:: shell + + make -C tools/tests/alloc clean all run \ + TARGETS=test-reserve_offline_page-uma + +To add a new test, simply create a new C file with a name starting with +``test-``, implement the test logic, and it will be automatically included +in the build and run targets by default.
tools/tests/alloc/check-asserts.h new file +347 -0
347 lines not on this page · raw message
tools/tests/alloc/harness.h new file +69 -0
69 lines not on this page · raw message
tools/tests/alloc/hypervisor-macros.h new file +101 -0
101 lines not on this page · raw message
tools/tests/alloc/libtest-page_alloc.h new file +356 -0
356 lines not on this page · raw message
tools/tests/alloc/mock-page_list.h new file +307 -0
308 lines not on this page · raw message
tools/tests/alloc/page_alloc-wrapper.h new file +465 -0
465 lines not on this page · raw message
tools/tests/alloc/page_alloc_shim.h new file +433 -0
433 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH 2/4 tools/tests/alloc: Add integration test suite for memory claims
In reply to Bernhard KaindlAdd a host-side integration test suite for memory claims, including NUMA-aware claim sets.
This complements the functional system tests submitted as part of the NUMA-aware claims series.
It verifies the behaviour of the page allocator when multi-node claim sets are present in situations that are easier to create and validate in isolation, with full control over a synthetic Xen heap state and visibility into the claim state of domains as claims are made and redeemed through heap allocation.
The included tests cover a range of claim-related scenarios to ensure that the Xen page allocator behaves as expected.
--- tools/tests/alloc/test-claims_basic.c | 230 ++++++++++++++++++++ tools/tests/alloc/test-claims_numa_redeem.c | 201 +++++++++++++++++ 2 files changed, 431 insertions(+) create mode 100644 tools/tests/alloc/test-claims_basic.c create mode 100644 tools/tests/alloc/test-claims_numa_redeem.c
tools/tests/alloc/test-claims_basic.c new file +230 -0
@@ -0,0 +1,230 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Unit tests for memory claims in xen/common/page_alloc.c. +* +* Copyright (C) 2026 Cloud Software Group +*/ + +/* Enable sysctl support in page_alloc.c for testing get_outstanding_claims() */ +#define CONFIG_NUMA 1 +#define CONFIG_SYSCTL 1 +#include "libtest-page_alloc.h" + +/* +* Wrapper for domain_install_claim_set() with the function signature as +* domain_set_outstanding_pages() to test both domain_install_claim_set() +* and domain_set_outstanding_pages() by using a function pointer for +* setting claims to check feature parity and consistent behavior. +*/ + +int test_set_global_claims (struct domain *d,unsigned long pages) +{ +memory_claim_t claim_set[] = { + {.target =XEN_DOMCTL_CLAIM_MEMORY_GLOBAL , .pages = pages}, + }; +return domain_install_claim_set (d,ARRAY_SIZE (claim_set), claim_set); +} +typedef int (*set_global_claims )(struct domain *d,unsigned long pages); + +/* +* Function pointer to test both domain_install_claim_set() and +* domain_set_outstanding_pages() interchangeably in the test +* scenarios for feature parity and consistent behaviour. +*/ +set_global_claims install_global_claims = test_set_global_claims; + +/* +* Test that memory claims are consumed correctly during allocations. +*/ +static void test_alloc_domheap_consumes_claims (int start_mfn) +{ +unsigned long avail_pages_zone; +int zone, ret; +struct page_info *pages = test_pages + start_mfn, *allocated; + +/* +* PREPARE +*/ + +/* Create a buddy of order 2 (4 pages) and add it to the heap. */ + zone =test_page_list_add_buddy (pages, order2); + +/* Verify the initial state of the heap */ +ASSERT_LIST_EQUAL (&heap (node, zone, order2), pages); +ASSERT (page_list_empty (&heap (node, zone, order1))); +ASSERT (page_list_empty (&heap (node, zone, order0))); +CHECK_BUDDY (pages,"Order-2 buddy prepared on the heap" ); + +/* +* ACT 1 +*/ + +/* Claim 3 out of the 4 pages for the dummy domain */ + ret =test_set_global_claims (dom1,3 ); +ASSERT (ret ==0 ); + +/* Allocate an order-1 page for the dummy domain */ + allocated =alloc_domheap_pages (dom1, order1,0 ); +CHECK (allocated == &pages[2 ],"Expect allocation start at 3rd page" ); + +/* +* ASSERT 1 +* +* The allocation is expected to split the order-2 buddy and allocate +* an order-1 chunk from it, leaving the remaining order-1 chunk as a free +* available pages, and the claim should have been consumed accordingly. +*/ + +/* Verify the state of the heap after allocation */ +ASSERT (page_list_empty (&heap (node, zone, order2))); +ASSERT (page_list_empty (&heap (node, zone, order0))); +/* The remaining order-1 chunk should be the first page */ +ASSERT_LIST_EQUAL (&heap (node, zone, order1), pages); +CHECK_BUDDY (pages,"Buddy after order-1 allocation" ); + +/* Verify the state of the aggregate counters */ +CHECK (TOTAL_CLAIMS ==1 ,"Expect 1 claims left after allocation" ); +CHECK (FREE_PAGES ==2 ,"Expect 2 available after allocation" ); +CHECK (avail_heap_pages (zone, zone, node) ==2 ,"Expect 2 in zone" ); + +/* +* ACT 2 +*/ + +/* Allocate one of the two remaining order-0 pages for the dummy domain */ + allocated =alloc_domheap_pages (dom1, order0,0 ); +CHECK (allocated == &pages[1 ],"alloc_domheap_pages returned the 2nd page" ); + +/* +* ASSERT 2 +* +* The allocation is expected to split the remaining order-1 +* buddy and allocate an order-0 page from it, leaving the +* remaining order-0 page as a free available page, and the +* claim should have been consumed accordingly. +*/ + +/* Verify the state of the heap after allocation */ +ASSERT (page_list_empty (&heap (node, zone, order2))); +ASSERT (page_list_empty (&heap (node, zone, order1))); +/* The remaining order-0 page should be the only free page we've left */ +ASSERT_LIST_EQUAL (&heap (node, zone, order0), pages); + +/* Verify the state of the aggregate counters */ +CHECK (TOTAL_CLAIMS ==0 ,"Expect all claims consumed after allocation" ); +CHECK (FREE_PAGES ==1 ,"Expect one free page after allocation" ); + + avail_pages_zone =avail_heap_pages (zone, zone, node); +CHECK (avail_pages_zone ==1 ,"Expect one page in zone after allocation" ); + +/* +* PREPARE 3 +*/ + +/* Claim all free memory from another domain to block allocations */ + ret =test_set_global_claims (dom2,FREE_PAGES ); +ASSERT (ret ==0 ); + +/* +* ACT 3 +*/ + +/* Claim more than dom1 already has fails with ENOMEM (claimed by dom2) */ + ret =test_set_global_claims (dom1,domain_tot_pages (dom1) +1 ); +CHECK (ret == -ENOMEM ,"dom 1 claim +1 fails due to insufficient pages" ); + +/* Claim more than dom1's d->max_pages fails with EINVAL */ + ret =test_set_global_claims (dom1, dom1->max_pages +1 ); +CHECK (ret == -EINVAL ,"dom 1 claim fails due to exceeding max_pages" ); + +/* Attempt to allocate an order-0 page with a foreign claim present */ + allocated =alloc_domheap_pages (dom1, order0,0 ); +CHECK (allocated ==NULL ,"dom 1 alloc fails b/c domain 2's claim" ); + +/* +* ASSERT 3 +*/ + +/* Verify the state of the heap after failed allocation (no changes) */ +ASSERT (page_list_empty (&heap (node, zone, order2))); +ASSERT (page_list_empty (&heap (node, zone, order1))); +/* Due to the foreign claim, the remaining page should still be free */ +ASSERT_LIST_EQUAL (&heap (node, zone, order0), pages); + +/* Verify the state of the aggregate counters (no changes expected) */ +CHECK (TOTAL_CLAIMS ==1 ,"Expect domain 2's claim to be still present" ); +CHECK (FREE_PAGES ==1 ,"Expect one free page after failed alloc" ); + + avail_pages_zone =avail_heap_pages (zone, zone, node); +CHECK (avail_pages_zone ==1 ,"Expect one page in zone after allocation" ); +} + +/* +* Test that memory claims are consumed correctly during allocations. +*/ +static void test_cancel_claims (int start_mfn) +{ +struct page_info *page = test_pages + start_mfn; +unsigned long claims; + +/* Create a buddy of order 2 (4 pages) and add it to the heap. */ +test_page_list_add_buddy (page, order2); + claims =FREE_PAGES /2 ; +/* Claim half of the free pages for dom1 */ +ASSERT (test_set_global_claims (dom1, claims) ==0 ); +ASSERT (TOTAL_CLAIMS == claims); + +/* +* Act: Cancel the claims for the dummy domain and verify that the +* claim counts are updated and the free pages are available again. +*/ + +/* Act + Assert 2: Claim all free pages for dom2, should fail */ +ASSERT (test_set_global_claims (dom2,FREE_PAGES ) == -ENOMEM ); +ASSERT (TOTAL_CLAIMS == claims); + +/* Act + Assert 1: Cancel all claims for dom1 */ +ASSERT (test_set_global_claims (dom1,0 ) ==0 ); +ASSERT (TOTAL_CLAIMS ==0 ); + +/* Act + Assert 2: Claim all free pages for dom2, should work */ +ASSERT (test_set_global_claims (dom2,FREE_PAGES ) ==0 ); +ASSERT (TOTAL_CLAIMS ==FREE_PAGES ); +} + +int main (int argc,char *argv[]) +{ +const char *topic ="Test legacy claims with allocation from the heap" ; +const char *program_name =parse_args (argc, argv, topic); + +if ( !program_name ) +return EXIT_FAILURE ; + +init_page_alloc_tests (); + +/* Use domain_set_outstanding_pages() for staking claims */ + install_global_claims = domain_set_outstanding_pages; +RUN_TESTCASE (ADCL , test_alloc_domheap_consumes_claims,0 ); + +/* +* Use test_set_global_claims() which is a wrapper around +* domain_install_claim_set() to check ensure consistent +* behavior with domain_set_outstanding_pages(). +*/ + install_global_claims = test_set_global_claims; +RUN_TESTCASE (ADCG , test_alloc_domheap_consumes_claims,4 ); + +RUN_TESTCASE (TCCL , test_cancel_claims,0 ); + +testcase_print_summary (program_name); +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/tests/alloc/test-claims_numa_redeem.c new file +201 -0
201 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH 3/4 tools/tests/alloc: Add tests for offlining with claims present
In reply to Bernhard KaindlAdd an integration test for offlining pages with outstanding claims. The test offlines two pages, with the second offline operation recalling one claim to prevent over-claiming beyond the available memory. Due to missing checks in the offlining code, there are expected failures which will be fixed in a test-driven manner.
Run this test with both global claims and node-local claims.
--- tools/tests/alloc/test-offlining-claims.c | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 tools/tests/alloc/test-offlining-claims.c
tools/tests/alloc/test-offlining-claims.c new file +106 -0
@@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Integration test for offlining pages with outstanding claims in page_alloc.c. +* +* Copyright (C) 2026 Cloud Software Group +*/ + +/* Enable sysctl support in page_alloc.c for testing get_outstanding_claims() */ +#define CONFIG_SYSCTL +#define CONFIG_NUMA +#include "libtest-page_alloc.h" + +/* +* Claim 3 of 4 pages globally, offline two pages, and the 2nd offline should +* recall one claim to prevent over-claiming beyond the available memory. +* +* As part of offline_page(), reserve_offlined_page() should recall the +* needed claims to not exceed the number of pages that are are remaining. +*/ +static void test_offlining_with_global_claims (int mfn) +{ +struct page_info *page = test_pages + mfn; +uint32_t status =0 ; +memory_claim_t claims[1 ] = { + {.pages =3 , .target =XEN_DOMCTL_CLAIM_MEMORY_GLOBAL } + }; + +/* PREPARE */ +test_page_list_add_buddy (page, order2);/* Add a buddy with 4 free pages*/ +ASSERT (domain_install_claim_set (dom1,ARRAY_SIZE (claims), claims) ==0 ); +offline_page (mfn +3 ,0 , &status);/* Offline the 1st page */ +ASSERT (status &PG_OFFLINE_OFFLINED ); +CHECK (TOTAL_CLAIMS ==3 ,"Still 3 claims before offlining the 2nd page" ); + +/* ACT */ +/* Offlining the 2nd page must reduce the free pages and claims to 2 */ + status =0 ; +offline_page (mfn +1 ,0 , &status);/* Offline the 2nd page */ +ASSERT (status &PG_OFFLINE_OFFLINED ); + +/* ASSERT */ +CHECK_BUDDY (page,"After offlining the 2nd page" ); +CHECK (FREE_PAGES ==2 ,"Expect 2 free pages after offlining two pages" ); +EXPECTED_TO_FAIL_BEGIN (); +CHECK (TOTAL_CLAIMS ==2 ,"Expect 2 claims after offlining two pages" ); +EXPECTED_TO_FAIL_END (1 ); +} + + +/* +* Claim 3 of 4 pages on node0, offline two pages, and the 2nd offline should +* recall one claim to prevent over-claiming beyond the available memory. +* +* As part of offline_page(), reserve_offlined_page() should recall the +* needed claims to not exceed the number of pages that are are remaining. +*/ +static void test_offlining_with_node_claims (int mfn) +{ +struct page_info *page = test_pages + mfn; +uint32_t status =0 ; +memory_claim_t claims[1 ] = { {.pages =3 , .target = node0} }; + +/* PREPARE */ +test_page_list_add_buddy (page, order2);/* Add a buddy with 4 free pages*/ +ASSERT (domain_install_claim_set (dom1,ARRAY_SIZE (claims), claims) ==0 ); +ASSERT (offline_page (mfn +3 ,0 , &status) ==0 );/* Offline the 1st page */ +ASSERT (status &PG_OFFLINE_OFFLINED ); +CHECK (TOTAL_CLAIMS ==3 ,"Still 3 claims before offlining the 2nd page" ); + +/* ACT */ +/* Offlining the 2nd page must reduce the free pages and claims to 2 */ +ASSERT (offline_page (mfn +1 ,0 , &status) ==0 );/* Offline the 2nd page */ +ASSERT (status &PG_OFFLINE_OFFLINED ); + +/* ASSERT */ +CHECK_BUDDY (page,"After offlining the 2nd page" ); +CHECK (FREE_PAGES ==2 ,"Expect 2 free pages after offlining two pages" ); +EXPECTED_TO_FAIL_BEGIN (); +CHECK (TOTAL_CLAIMS ==2 ,"Expect 2 claims after offlining two pages" ); +EXPECTED_TO_FAIL_END (1 ); +} + +int main (int argc,char *argv[]) +{ +const char *topic ="Test offlining with memory claims" ; +const char *program_name =parse_args (argc, argv, topic); + +if ( !program_name ) +return EXIT_FAILURE ; + +init_page_alloc_tests (); + +RUN_TESTCASE (OWGC , test_offlining_with_global_claims,0 ); +RUN_TESTCASE (OWNC , test_offlining_with_node_claims,0 ); + +return testcase_print_summary (program_name); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.39.5
PATCH 4/4 xen/mm: Recall claims when offlining pages if needed
In reply to Bernhard KaindlFix a bug where offlining pages could cause an unsigned underflow in total_avail_pages - outstanding_claims, leading to incorrect claim behavior.
This issue arises when outstanding claims are close to the total available pages. It occurse when domain_set_outstanding_claims() and domain_install_claim_set effectively do this:
unsigned long avail_pages = total_avail_pages - outstanding_claims;
When this unsigned subtraction underflows, staking claims can succeed even when there is insufficient unclaimed memory for the new claim. This leads to a state where claims always succeed, regardless of actual memory availability.
To prevent this, recall claims when offlining pages if needed to maintain equilibrium between total_avail_pages and outstanding claims for global and for per-NUMA-node claims.
--- tools/tests/alloc/test-offlining-claims.c | 4 --- xen/common/page_alloc.c | 42 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-)
tools/tests/alloc/test-offlining-claims.c +0 -4
@@ -41,9 +41,7 @@ static void test_offlining_with_global_claims(int mfn)/* ASSERT */ CHECK_BUDDY (page,"After offlining the 2nd page" );CHECK (FREE_PAGES ==2 ,"Expect 2 free pages after offlining two pages" ); -EXPECTED_TO_FAIL_BEGIN ();CHECK (TOTAL_CLAIMS ==2 ,"Expect 2 claims after offlining two pages" ); -EXPECTED_TO_FAIL_END (1 ); }
@@ -75,9 +73,7 @@ static void test_offlining_with_node_claims(int mfn)/* ASSERT */ CHECK_BUDDY (page,"After offlining the 2nd page" );CHECK (FREE_PAGES ==2 ,"Expect 2 free pages after offlining two pages" ); -EXPECTED_TO_FAIL_BEGIN ();CHECK (TOTAL_CLAIMS ==2 ,"Expect 2 claims after offlining two pages" ); -EXPECTED_TO_FAIL_END (1 ); }int main (int argc,char *argv[])
xen/common/page_alloc.c +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH 1/4] tools/tests/alloc: Unit and Integration Test Framework for page_alloc.c
In reply to Bernhard KaindlQuoted 9 lines · Bernhard Kaindl
Add a test framefork for unit and integration test suites testing the Xen page allocator module
xen/common/page_alloc.cin isolation.It enables test suites to verify the behaviour of the page allocator in situations that are easier to create and validate in isolation, with full control over a synthetic Xen heap state and visibility into the allocator and domain state.
Signed-off-by Bernhard Kaindl <[email protected]>
Just two remarks (nits?) for now:
Quoted 5 lines
--- tools/tests/Makefile | 1 + tools/tests/alloc/.gitignore | 6 + tools/tests/alloc/Makefile | 141 ++++++++ tools/tests/alloc/README.rst | 31 ++
Quoted 8 lines
tools/tests/alloc/check-asserts.h | 347 ++++++++++++++++++ tools/tests/alloc/harness.h | 69 ++++ tools/tests/alloc/hypervisor-macros.h | 101 ++++++ tools/tests/alloc/libtest-page_alloc.h | 356 +++++++++++++++++++ tools/tests/alloc/mock-page_list.h | 307 ++++++++++++++++ tools/tests/alloc/page_alloc-wrapper.h | 465 +++++++++++++++++++++++++ tools/tests/alloc/page_alloc_shim.h | 433 +++++++++++++++++++++++ 11 files changed, 2257 insertions(+)
This is a lot of new code.
Quoted 10 lines
create mode 100644 tools/tests/alloc/.gitignore create mode 100644 tools/tests/alloc/Makefile create mode 100644 tools/tests/alloc/README.rst create mode 100644 tools/tests/alloc/check-asserts.h create mode 100644 tools/tests/alloc/harness.h create mode 100644 tools/tests/alloc/hypervisor-macros.h create mode 100644 tools/tests/alloc/libtest-page_alloc.h create mode 100644 tools/tests/alloc/mock-page_list.h create mode 100644 tools/tests/alloc/page_alloc-wrapper.h create mode 100644 tools/tests/alloc/page_alloc_shim.h
No underscores please in new files' names when dashes will do.
Jan
RE: [PATCH 1/4] tools/tests/alloc: Unit and Integration Test Framework for page_alloc.c
Quoted 4 lines
Quoted 3 lines
Add a test framefork for unit and integration test suites testing the Xen page allocator module
xen/common/page_alloc.cin isolation.Just two remarks (nits?) for now:
[...]
Quoted 8 lines
Quoted 6 lines
tools/tests/alloc/hypervisor-macros.h | 101 ++++++ tools/tests/alloc/libtest-page_alloc.h | 356 +++++++++++++++++++ tools/tests/alloc/mock-page_list.h | 307 ++++++++++++++++ tools/tests/alloc/page_alloc-wrapper.h | 465 +++++++++++++++++++++++++ tools/tests/alloc/page_alloc_shim.h | 433 +++++++++++++++++++++++ 11 files changed, 2257 insertions(+)This is a lot of new code.
Ack, improved for v2. It will be reduced to 1411 lines, 60% smaller.
Changes for v2:
1. Refactor the test environment for minimalism:
- Improve separation of concerns.
- Move extensions to later patch series.
- Simplify code with targeted assertions and concise comments.
2. Fix file names to avoid underscores.
3. Update the include guards to comply with CODING_STYLE.
Bernhard