diff mbox series

[2/3] fstests: filter: helpers for sysfs error filtering

Message ID 274f52cbb8de26703ddad1672bcf9a8dd0a540a6.1738161075.git.anand.jain@oracle.com (mailing list archive)
State New
Headers show
Series fstests: btrfs: add test case to validate sysfs input arguments | expand

Commit Message

Anand Jain Jan. 29, 2025, 3:19 p.m. UTC
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@oracle.com>
---
 common/filter | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

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