On Fri, 2023-11-17 at 14:35 -0800, [email protected] wrote:
> From: Alison Schofield <[email protected]>
>
[..]
Rest of the series is looking good, just a few minor things below.
>
> +
> +find_media_errors()
> +{
> + local json="$1"
> +
> + nr="$(jq -r ".nr_records" <<< "$json")"
> + if [[ $nr != $NR_ERRS ]]; then
Minor shellcheck complaint, the right hand side of a [[ ]] check should
be quoted, so [[ $nr != "$NR_ERRS" ]]
> + echo "$mem: $NR_ERRS poison records expected, $nr found"
$mem is never set, maybe it needs to be extracted from the json above?
> + err "$LINENO"
> + fi
> +}
> +
> +# Turn tracing on. Note that 'cxl list --poison' does toggle the tracing.
> +# Turning it on here allows the test user to also view inject and clear
> +# trace events.
> +echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable
> +
> +# Poison by memdev
> +# Inject then clear into cxl_test known pmem and ram partitions
> +find_memdev
> +inject_poison_sysfs "$memdev" "0x40000000"
> +inject_poison_sysfs "$memdev" "0x40001000"
> +inject_poison_sysfs "$memdev" "0x600"
> +inject_poison_sysfs "$memdev" "0x0"
> +NR_ERRS=4
> +json=$("$CXL" list -m "$memdev" --poison | jq -r '.[].poison')
> +find_media_errors "$json"
Instead of setting NR_ERRS 'globally', just pass it to the
find_media_errors function as well alongside $json, and maybe rename it
to validate_nr_records() or something. More generaly, no need to
capitalize something like NR_ERRS - all caps is usually only for
variables coming from the env.
> +clear_poison_sysfs "$memdev" "0x40000000"
> +clear_poison_sysfs "$memdev" "0x40001000"
> +clear_poison_sysfs "$memdev" "0x600"
> +clear_poison_sysfs "$memdev" "0x0"
> +NR_ERRS=0
> +json=$("$CXL" list -m "$memdev" --poison | jq -r '.[].poison')
Fairly minor but shellcheck complains about quoting all the "$()"
command substitutions.
> +find_media_errors "$json"
> +
> +# Poison by region
> +# Inject then clear into cxl_test known pmem dpa mappings
> +create_region
> +inject_poison_sysfs "$mem0" "0x40000000"
> +inject_poison_sysfs "$mem1" "0x40000000"
> +NR_ERRS=2
> +json=$("$CXL" list -r "$region" --poison | jq -r '.[].poison')
> +find_media_errors "$json"
> +clear_poison_sysfs "$mem0" "0x40000000"
> +clear_poison_sysfs "$mem1" "0x40000000"
> +NR_ERRS=0
> +json=$("$CXL" list -r "$region" --poison | jq -r '.[].poison')
> +find_media_errors "$json"
> +
> +check_dmesg "$LINENO"
> +
> +modprobe -r cxl-test
> diff --git a/test/meson.build b/test/meson.build
> index 224adaf41fcc..2706fa5d633c 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -157,6 +157,7 @@ cxl_create_region = find_program('cxl-create-region.sh')
> cxl_xor_region = find_program('cxl-xor-region.sh')
> cxl_update_firmware = find_program('cxl-update-firmware.sh')
> cxl_events = find_program('cxl-events.sh')
> +cxl_poison = find_program('cxl-poison.sh')
>
> tests = [
> [ 'libndctl', libndctl, 'ndctl' ],
> @@ -186,6 +187,7 @@ tests = [
> [ 'cxl-create-region.sh', cxl_create_region, 'cxl' ],
> [ 'cxl-xor-region.sh', cxl_xor_region, 'cxl' ],
> [ 'cxl-events.sh', cxl_events, 'cxl' ],
> + [ 'cxl-poison.sh', cxl_poison, 'cxl' ],
> ]
>
> if get_option('destructive').enabled()