* [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing @ 2026-03-14 6:21 Alison Schofield 2026-03-14 6:21 ` [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow Alison Schofield 2026-04-16 21:08 ` [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Dave Jiang 0 siblings, 2 replies; 4+ messages in thread From: Alison Schofield @ 2026-03-14 6:21 UTC (permalink / raw) To: nvdimm, linux-cxl; +Cc: Alison Schofield Add replay_regions() and supporting helpers to the CXL test common library. The helpers capture the current region configuration, trigger a region replay by unbinding and rebinding the cxl_acpi driver, and verify that the regions reconstructed during enumeration match the original configuration. Replay is enabled by instructing the cxl_test module to preserve its decoder registry across the driver unbind/bind cycle. This allows the decoder programming associated with user-created regions to survive topology teardown so that the regions are reconstructed during driver initialization as auto-discovered regions. Region signatures are derived from region attributes and memdev serial numbers so that the replayed configuration can be compared independent of topology enumeration order and device numbering. These helpers provide a reusable mechanism for CXL tests that need to exercise region replay behavior. A unit test, cxl-region-replay.sh, is posted in a follow-on patch and demonstrates the workflow. Signed-off-by: Alison Schofield <alison.schofield@intel.com> --- test/common | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/common b/test/common index 2eb11b7396d0..048f9680f277 100644 --- a/test/common +++ b/test/common @@ -168,3 +168,112 @@ check_dmesg() # CXL COMMON CXL_TEST_QOS_CLASS=42 + +# CXL region replay helpers +# +# replay_regions() snapshots the current region configuration, performs +# a cxl_acpi driver unbind/bind cycle to trigger region replay, and +# verifies that the regions reconstructed during enumeration match the +# original configuration. +# +# This allows tests to create regions through the user interface and +# then replay them as auto-discovered regions during driver +# initialization. +# +# See example usage in test/cxl-region-replay.sh. + +CXL_EXPECTED_REGION_SIGS="" + +cxl_get_memdev_serial() +{ + local memdev="$1" + + "$CXL" list -m "$memdev" | jq -r '.[0].serial' +} + +cxl_emit_region_signature() +{ + local region="$1" + local region_json size type ways gran state + local entry pos memdev serial sig + + region_json=$("$CXL" list -R --targets -r "$region") + [[ -n "$region_json" && "$region_json" != "[]" ]] || return 1 + + size=$(jq -r '.[0].size' <<<"$region_json") + type=$(jq -r '.[0].type' <<<"$region_json") + ways=$(jq -r '.[0].interleave_ways' <<<"$region_json") + gran=$(jq -r '.[0].interleave_granularity' <<<"$region_json") + state=$(jq -r '.[0].decode_state' <<<"$region_json") + + sig="size=$size type=$type ways=$ways gran=$gran" + + while IFS= read -r entry; do + pos=$(jq -r '.position' <<<"$entry") + memdev=$(jq -r '.memdev' <<<"$entry") + serial=$(cxl_get_memdev_serial "$memdev") || return 1 + [[ -n "$serial" && "$serial" != "null" ]] || return 1 + sig="$sig pos=$pos serial=$serial" + done < <(jq -c '.[0].mappings | sort_by(.position)[]' <<<"$region_json") + + echo "$sig state=$state" +} + +cxl_collect_region_signatures() +{ + local region + local -a regions=() + + mapfile -t regions < <("$CXL" list -Ri | jq -r '.[].region' | sort) || return 1 + + for region in "${regions[@]}"; do + cxl_emit_region_signature "$region" || return 1 + done | sort +} + +cxl_capture_expected_region_signatures() +{ + CXL_EXPECTED_REGION_SIGS=$(cxl_collect_region_signatures) || return 1 +} + +cxl_verify_replayed_regions() +{ + local actual_region_sigs + local -a expected_lines=() + local -a actual_lines=() + local i + local expected_line actual_line + local expected_struct actual_struct + local expected_state actual_state + + actual_region_sigs=$(cxl_collect_region_signatures) || return 1 + + mapfile -t expected_lines < <(printf '%s\n' "$CXL_EXPECTED_REGION_SIGS" | sed '/^$/d') + mapfile -t actual_lines < <(printf '%s\n' "$actual_region_sigs" | sed '/^$/d') + + [ "${#expected_lines[@]}" -eq "${#actual_lines[@]}" ] || return 1 + + for ((i = 0; i < ${#expected_lines[@]}; i++)); do + expected_line=${expected_lines[i]} + actual_line=${actual_lines[i]} + + expected_struct=${expected_line% state=*} + expected_state=${expected_line##* state=} + actual_struct=${actual_line% state=*} + actual_state=${actual_line##* state=} + + [ "$expected_struct" = "$actual_struct" ] || return 1 + [ "$expected_state" != "commit" ] || [ "$actual_state" = "commit" ] || return 1 + done +} + +replay_regions() +{ + echo "replaying existing regions" + cxl_capture_expected_region_signatures || return 1 + echo 1 > /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry + echo cxl_acpi.0 > /sys/bus/platform/drivers/cxl_acpi/unbind + echo cxl_acpi.0 > /sys/bus/platform/drivers/cxl_acpi/bind + echo 0 > /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry + cxl_verify_replayed_regions || return 1 +} base-commit: d6f32b0afba6c36fbde2aae67230b71f9e70cb07 -- 2.37.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow 2026-03-14 6:21 [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Alison Schofield @ 2026-03-14 6:21 ` Alison Schofield 2026-04-16 21:09 ` Dave Jiang 2026-04-16 21:08 ` [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Dave Jiang 1 sibling, 1 reply; 4+ messages in thread From: Alison Schofield @ 2026-03-14 6:21 UTC (permalink / raw) To: nvdimm, linux-cxl; +Cc: Alison Schofield Add a CXL unit test that exercises the replay_regions() helpers introduced in test/common. The test creates regions through the user interface, captures the resulting region configuration, performs a cxl_acpi driver unbind/bind cycle, and verifies that the regions reconstructed during enumeration match the original configuration. This validates the decoder replay mechanism implemented in the kernel cxl_test module by replaying user-created regions as auto-discovered regions during driver initialization. Signed-off-by: Alison Schofield <alison.schofield@intel.com> --- test/cxl-region-replay.sh | 148 ++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 + 2 files changed, 150 insertions(+) create mode 100644 test/cxl-region-replay.sh diff --git a/test/cxl-region-replay.sh b/test/cxl-region-replay.sh new file mode 100644 index 000000000000..3049ca9f34b5 --- /dev/null +++ b/test/cxl-region-replay.sh @@ -0,0 +1,148 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 Intel Corporation. All rights reserved. + +. $(dirname $0)/common + +rc=77 + +set -ex + +trap 'err $LINENO' ERR + +check_prereq "jq" + +modprobe -r cxl_test +modprobe cxl_test + +# Replay support is exposed by cxl_acpi after cxl_test loads +if [ ! -e /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry ]; then + do_skip "test requires decoder registry replay support" +fi + +rc=1 + +# Demonstrate and validate CXL region replay support in cxl_test. +# +# Replay helpers in test/common snapshot the current region topology, +# replay the configuration, and verify that the reconstructed regions +# match the original configuration. +# +# Tests should use the common helper: +# replay_regions +# +# This test serves as both a sanity check for replay support and an +# example of how other cxl_test unit tests can use replay_regions(). + +destroy_regions() { + $CXL destroy-region -f -b cxl_test all +} + +create_region() { + region=$($CXL create-region -d "$decoder" -m "$memdevs" | + jq -r ".region") + + if [[ ! $region ]]; then + echo "create-region failed for $decoder" + err "$LINENO" + fi +} + +create_x2_pmem_region() { + # Find a pmem-capable x2 decoder + decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] | + select(.pmem_capable == true) | + select(.nr_targets == 2) | + .decoder") + + # Select one memdev for each host-bridge interleave position + port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 0) | .target") + port_dev1=$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 1) | .target") + mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev") + mem1=$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev") + memdevs="$mem0 $mem1" + create_region +} + +create_x4_ram_region() { + # Find a volatile-capable x2 decoder + decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] | + select(.volatile_capable == true) | + select(.nr_targets == 2) | + .decoder") + + # Select two memdevs for each host-bridge interleave position + port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 0) | .target") + port_dev1=$($CXL list -T -d "$decoder" | jq -r ".[] | + .targets | .[] | select(.position == 1) | .target") + mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev") + mem1=$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev") + mem2=$($CXL list -M -p "$port_dev0" | jq -r ".[1].memdev") + mem3=$($CXL list -M -p "$port_dev1" | jq -r ".[1].memdev") + memdevs="$mem0 $mem1 $mem2 $mem3" + create_region +} + +AUTO_MEMDEVS="" +AUTO_ROOT_DECODER="" + +capture_auto_region() { + local region_json dec_json + + region_json=$($CXL list -R --targets) + + # Expect exactly one auto region + [ "$(jq 'length' <<<"$region_json")" -eq 1 ] || err "$LINENO" + + AUTO_MEMDEVS=$(jq -r '.[0].mappings | sort_by(.position) | .[].memdev' \ + <<<"$region_json" | xargs) + [[ $AUTO_MEMDEVS ]] || err "$LINENO" + + dec_json=$($CXL list -R --decoders) + AUTO_ROOT_DECODER=$(jq -r '.[0]["root decoders"][0].decoder' <<<"$dec_json") + [[ $AUTO_ROOT_DECODER ]] || err "$LINENO" +} + +create_user_region_in_auto_region_space() { + decoder="$AUTO_ROOT_DECODER" + memdevs="$AUTO_MEMDEVS" + create_region +} + +# To remove the auto region, destroy and recreate in user space. +# With that action, there will be no 'auto' decoders and it will not be +# preserved across acpi rebind. +# +# This is done here as example if test wants the resources freed +remove_auto_region() { + capture_auto_region + destroy_regions + create_user_region_in_auto_region_space + destroy_regions + replay_regions || err "$LINENO" +} + +# Replay the built-in auto region +[ "$($CXL list -R | jq 'length')" -ne 0 ] || err "$LINENO" +replay_regions || err "$LINENO" + +# Remove the built-in auto region to free up resources +remove_auto_region +[ "$($CXL list -R | jq 'length')" -eq 0 ] || err "$LINENO" + +# Create and replay a volatile region +create_x4_ram_region +replay_regions || err "$LINENO" + +# Add-on a pmem region +create_x2_pmem_region + +# Replay both the x4_ram and x2_pmem +replay_regions || err "$LINENO" + +check_dmesg "$LINENO" + +modprobe -r cxl_test diff --git a/test/meson.build b/test/meson.build index 8a3718d2b558..fb195e07d0ba 100644 --- a/test/meson.build +++ b/test/meson.build @@ -169,6 +169,7 @@ cxl_destroy_region = find_program('cxl-destroy-region.sh') cxl_qos_class = find_program('cxl-qos-class.sh') cxl_translate = find_program('cxl-translate.sh') cxl_elc = find_program('cxl-elc.sh') +cxl_region_replay = find_program('cxl-region-replay.sh') tests = [ [ 'libndctl', libndctl, 'ndctl' ], @@ -203,6 +204,7 @@ tests = [ [ 'cxl-qos-class.sh', cxl_qos_class, 'cxl' ], [ 'cxl-translate.sh', cxl_translate, 'cxl' ], [ 'cxl-elc.sh', cxl_elc, 'cxl' ], + [ 'cxl-region-replay.sh', cxl_region_replay, 'cxl' ], ] if get_option('destructive').enabled() -- 2.37.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow 2026-03-14 6:21 ` [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow Alison Schofield @ 2026-04-16 21:09 ` Dave Jiang 0 siblings, 0 replies; 4+ messages in thread From: Dave Jiang @ 2026-04-16 21:09 UTC (permalink / raw) To: Alison Schofield, nvdimm, linux-cxl On 3/13/26 11:21 PM, Alison Schofield wrote: > Add a CXL unit test that exercises the replay_regions() helpers > introduced in test/common. > > The test creates regions through the user interface, captures the > resulting region configuration, performs a cxl_acpi driver unbind/bind > cycle, and verifies that the regions reconstructed during enumeration > match the original configuration. > > This validates the decoder replay mechanism implemented in the kernel > cxl_test module by replaying user-created regions as auto-discovered > regions during driver initialization. > > Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> > --- > test/cxl-region-replay.sh | 148 ++++++++++++++++++++++++++++++++++++++ > test/meson.build | 2 + > 2 files changed, 150 insertions(+) > create mode 100644 test/cxl-region-replay.sh > > diff --git a/test/cxl-region-replay.sh b/test/cxl-region-replay.sh > new file mode 100644 > index 000000000000..3049ca9f34b5 > --- /dev/null > +++ b/test/cxl-region-replay.sh > @@ -0,0 +1,148 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (C) 2022 Intel Corporation. All rights reserved. > + > +. $(dirname $0)/common > + > +rc=77 > + > +set -ex > + > +trap 'err $LINENO' ERR > + > +check_prereq "jq" > + > +modprobe -r cxl_test > +modprobe cxl_test > + > +# Replay support is exposed by cxl_acpi after cxl_test loads > +if [ ! -e /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry ]; then > + do_skip "test requires decoder registry replay support" > +fi > + > +rc=1 > + > +# Demonstrate and validate CXL region replay support in cxl_test. > +# > +# Replay helpers in test/common snapshot the current region topology, > +# replay the configuration, and verify that the reconstructed regions > +# match the original configuration. > +# > +# Tests should use the common helper: > +# replay_regions > +# > +# This test serves as both a sanity check for replay support and an > +# example of how other cxl_test unit tests can use replay_regions(). > + > +destroy_regions() { > + $CXL destroy-region -f -b cxl_test all > +} > + > +create_region() { > + region=$($CXL create-region -d "$decoder" -m "$memdevs" | > + jq -r ".region") > + > + if [[ ! $region ]]; then > + echo "create-region failed for $decoder" > + err "$LINENO" > + fi > +} > + > +create_x2_pmem_region() { > + # Find a pmem-capable x2 decoder > + decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] | > + select(.pmem_capable == true) | > + select(.nr_targets == 2) | > + .decoder") > + > + # Select one memdev for each host-bridge interleave position > + port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] | > + .targets | .[] | select(.position == 0) | .target") > + port_dev1=$($CXL list -T -d "$decoder" | jq -r ".[] | > + .targets | .[] | select(.position == 1) | .target") > + mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev") > + mem1=$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev") > + memdevs="$mem0 $mem1" > + create_region > +} > + > +create_x4_ram_region() { > + # Find a volatile-capable x2 decoder > + decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] | > + select(.volatile_capable == true) | > + select(.nr_targets == 2) | > + .decoder") > + > + # Select two memdevs for each host-bridge interleave position > + port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] | > + .targets | .[] | select(.position == 0) | .target") > + port_dev1=$($CXL list -T -d "$decoder" | jq -r ".[] | > + .targets | .[] | select(.position == 1) | .target") > + mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev") > + mem1=$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev") > + mem2=$($CXL list -M -p "$port_dev0" | jq -r ".[1].memdev") > + mem3=$($CXL list -M -p "$port_dev1" | jq -r ".[1].memdev") > + memdevs="$mem0 $mem1 $mem2 $mem3" > + create_region > +} > + > +AUTO_MEMDEVS="" > +AUTO_ROOT_DECODER="" > + > +capture_auto_region() { > + local region_json dec_json > + > + region_json=$($CXL list -R --targets) > + > + # Expect exactly one auto region > + [ "$(jq 'length' <<<"$region_json")" -eq 1 ] || err "$LINENO" > + > + AUTO_MEMDEVS=$(jq -r '.[0].mappings | sort_by(.position) | .[].memdev' \ > + <<<"$region_json" | xargs) > + [[ $AUTO_MEMDEVS ]] || err "$LINENO" > + > + dec_json=$($CXL list -R --decoders) > + AUTO_ROOT_DECODER=$(jq -r '.[0]["root decoders"][0].decoder' <<<"$dec_json") > + [[ $AUTO_ROOT_DECODER ]] || err "$LINENO" > +} > + > +create_user_region_in_auto_region_space() { > + decoder="$AUTO_ROOT_DECODER" > + memdevs="$AUTO_MEMDEVS" > + create_region > +} > + > +# To remove the auto region, destroy and recreate in user space. > +# With that action, there will be no 'auto' decoders and it will not be > +# preserved across acpi rebind. > +# > +# This is done here as example if test wants the resources freed > +remove_auto_region() { > + capture_auto_region > + destroy_regions > + create_user_region_in_auto_region_space > + destroy_regions > + replay_regions || err "$LINENO" > +} > + > +# Replay the built-in auto region > +[ "$($CXL list -R | jq 'length')" -ne 0 ] || err "$LINENO" > +replay_regions || err "$LINENO" > + > +# Remove the built-in auto region to free up resources > +remove_auto_region > +[ "$($CXL list -R | jq 'length')" -eq 0 ] || err "$LINENO" > + > +# Create and replay a volatile region > +create_x4_ram_region > +replay_regions || err "$LINENO" > + > +# Add-on a pmem region > +create_x2_pmem_region > + > +# Replay both the x4_ram and x2_pmem > +replay_regions || err "$LINENO" > + > +check_dmesg "$LINENO" > + > +modprobe -r cxl_test > diff --git a/test/meson.build b/test/meson.build > index 8a3718d2b558..fb195e07d0ba 100644 > --- a/test/meson.build > +++ b/test/meson.build > @@ -169,6 +169,7 @@ cxl_destroy_region = find_program('cxl-destroy-region.sh') > cxl_qos_class = find_program('cxl-qos-class.sh') > cxl_translate = find_program('cxl-translate.sh') > cxl_elc = find_program('cxl-elc.sh') > +cxl_region_replay = find_program('cxl-region-replay.sh') > > tests = [ > [ 'libndctl', libndctl, 'ndctl' ], > @@ -203,6 +204,7 @@ tests = [ > [ 'cxl-qos-class.sh', cxl_qos_class, 'cxl' ], > [ 'cxl-translate.sh', cxl_translate, 'cxl' ], > [ 'cxl-elc.sh', cxl_elc, 'cxl' ], > + [ 'cxl-region-replay.sh', cxl_region_replay, 'cxl' ], > ] > > if get_option('destructive').enabled() ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing 2026-03-14 6:21 [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Alison Schofield 2026-03-14 6:21 ` [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow Alison Schofield @ 2026-04-16 21:08 ` Dave Jiang 1 sibling, 0 replies; 4+ messages in thread From: Dave Jiang @ 2026-04-16 21:08 UTC (permalink / raw) To: Alison Schofield, nvdimm, linux-cxl On 3/13/26 11:21 PM, Alison Schofield wrote: > Add replay_regions() and supporting helpers to the CXL test common > library. The helpers capture the current region configuration, trigger > a region replay by unbinding and rebinding the cxl_acpi driver, and > verify that the regions reconstructed during enumeration match the > original configuration. > > Replay is enabled by instructing the cxl_test module to preserve its > decoder registry across the driver unbind/bind cycle. This allows the > decoder programming associated with user-created regions to survive > topology teardown so that the regions are reconstructed during driver > initialization as auto-discovered regions. > > Region signatures are derived from region attributes and memdev serial > numbers so that the replayed configuration can be compared independent > of topology enumeration order and device numbering. > > These helpers provide a reusable mechanism for CXL tests that need to > exercise region replay behavior. A unit test, cxl-region-replay.sh, is > posted in a follow-on patch and demonstrates the workflow. > > Signed-off-by: Alison Schofield <alison.schofield@intel.com> Not that I'm great at bash and jq but it looks ok to me. Reviewed-by: Dave Jiang <dave.jiang@intel.com> > --- > test/common | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 109 insertions(+) > > diff --git a/test/common b/test/common > index 2eb11b7396d0..048f9680f277 100644 > --- a/test/common > +++ b/test/common > @@ -168,3 +168,112 @@ check_dmesg() > > # CXL COMMON > CXL_TEST_QOS_CLASS=42 > + > +# CXL region replay helpers > +# > +# replay_regions() snapshots the current region configuration, performs > +# a cxl_acpi driver unbind/bind cycle to trigger region replay, and > +# verifies that the regions reconstructed during enumeration match the > +# original configuration. > +# > +# This allows tests to create regions through the user interface and > +# then replay them as auto-discovered regions during driver > +# initialization. > +# > +# See example usage in test/cxl-region-replay.sh. > + > +CXL_EXPECTED_REGION_SIGS="" > + > +cxl_get_memdev_serial() > +{ > + local memdev="$1" > + > + "$CXL" list -m "$memdev" | jq -r '.[0].serial' > +} > + > +cxl_emit_region_signature() > +{ > + local region="$1" > + local region_json size type ways gran state > + local entry pos memdev serial sig > + > + region_json=$("$CXL" list -R --targets -r "$region") > + [[ -n "$region_json" && "$region_json" != "[]" ]] || return 1 > + > + size=$(jq -r '.[0].size' <<<"$region_json") > + type=$(jq -r '.[0].type' <<<"$region_json") > + ways=$(jq -r '.[0].interleave_ways' <<<"$region_json") > + gran=$(jq -r '.[0].interleave_granularity' <<<"$region_json") > + state=$(jq -r '.[0].decode_state' <<<"$region_json") > + > + sig="size=$size type=$type ways=$ways gran=$gran" > + > + while IFS= read -r entry; do > + pos=$(jq -r '.position' <<<"$entry") > + memdev=$(jq -r '.memdev' <<<"$entry") > + serial=$(cxl_get_memdev_serial "$memdev") || return 1 > + [[ -n "$serial" && "$serial" != "null" ]] || return 1 > + sig="$sig pos=$pos serial=$serial" > + done < <(jq -c '.[0].mappings | sort_by(.position)[]' <<<"$region_json") > + > + echo "$sig state=$state" > +} > + > +cxl_collect_region_signatures() > +{ > + local region > + local -a regions=() > + > + mapfile -t regions < <("$CXL" list -Ri | jq -r '.[].region' | sort) || return 1 > + > + for region in "${regions[@]}"; do > + cxl_emit_region_signature "$region" || return 1 > + done | sort > +} > + > +cxl_capture_expected_region_signatures() > +{ > + CXL_EXPECTED_REGION_SIGS=$(cxl_collect_region_signatures) || return 1 > +} > + > +cxl_verify_replayed_regions() > +{ > + local actual_region_sigs > + local -a expected_lines=() > + local -a actual_lines=() > + local i > + local expected_line actual_line > + local expected_struct actual_struct > + local expected_state actual_state > + > + actual_region_sigs=$(cxl_collect_region_signatures) || return 1 > + > + mapfile -t expected_lines < <(printf '%s\n' "$CXL_EXPECTED_REGION_SIGS" | sed '/^$/d') > + mapfile -t actual_lines < <(printf '%s\n' "$actual_region_sigs" | sed '/^$/d') > + > + [ "${#expected_lines[@]}" -eq "${#actual_lines[@]}" ] || return 1 > + > + for ((i = 0; i < ${#expected_lines[@]}; i++)); do > + expected_line=${expected_lines[i]} > + actual_line=${actual_lines[i]} > + > + expected_struct=${expected_line% state=*} > + expected_state=${expected_line##* state=} > + actual_struct=${actual_line% state=*} > + actual_state=${actual_line##* state=} > + > + [ "$expected_struct" = "$actual_struct" ] || return 1 > + [ "$expected_state" != "commit" ] || [ "$actual_state" = "commit" ] || return 1 > + done > +} > + > +replay_regions() > +{ > + echo "replaying existing regions" > + cxl_capture_expected_region_signatures || return 1 > + echo 1 > /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry > + echo cxl_acpi.0 > /sys/bus/platform/drivers/cxl_acpi/unbind > + echo cxl_acpi.0 > /sys/bus/platform/drivers/cxl_acpi/bind > + echo 0 > /sys/bus/platform/devices/cxl_acpi.0/decoder_reset_preserve_registry > + cxl_verify_replayed_regions || return 1 > +} > > base-commit: d6f32b0afba6c36fbde2aae67230b71f9e70cb07 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-16 21:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-14 6:21 [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Alison Schofield 2026-03-14 6:21 ` [ndctl PATCH 2/2] test/cxl-region-replay.sh: add test of region replay workflow Alison Schofield 2026-04-16 21:09 ` Dave Jiang 2026-04-16 21:08 ` [ndctl PATCH 1/2] test/common: add helpers for CXL region replay testing Dave Jiang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox