Added filter helpers to handle sysfs write errors, to ensure the sysfs write command fails with an "invalid argument" error. Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> --- common/filter | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/filter b/common/filter index 7e02ded377cc..30bb9161d620 100644 --- a/common/filter +++ b/common/filter @@ -671,5 +671,29 @@ _filter_flakey_EIO() sed -e "s#.*: Input\/output error#$message#" } +# Filters +# +./common/rc: line 5085: echo: write error: Invalid argument +# to +# Invalid argument +_filter_sysfs_error() +{ + sed 's/.*: \(.*\)$/\1/' +} + +_expect_error_invalid_argument() +{ + local line + + read -r line || { + echo "ERROR: Expected 'Invalid argument' but got no input" >&2 + return 1 + } + + if [[ $line != *"Invalid argument"* ]]; then + echo "ERROR: Expected 'Invalid argument' but got: $line" >&2 + return 1 + fi +} + # make sure this script returns success /bin/true -- 2.47.0