[PATCH blktests v4 06/17] meta/{018,019}: add test cases to check _set_combined_conditions

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Sat May 4 01:14:37 PDT 2024


Add test cases to confirm that the helper _set_combined_conditions is
working. meta/018 combines two hooks, and meta/019 combines three hooks.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
 tests/meta/018     | 43 ++++++++++++++++++++++++++++++++++++
 tests/meta/018.out |  2 ++
 tests/meta/019     | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/meta/019.out |  2 ++
 tests/meta/rc      |  5 +++++
 5 files changed, 107 insertions(+)
 create mode 100755 tests/meta/018
 create mode 100644 tests/meta/018.out
 create mode 100755 tests/meta/019
 create mode 100644 tests/meta/019.out

diff --git a/tests/meta/018 b/tests/meta/018
new file mode 100755
index 0000000..4b62d82
--- /dev/null
+++ b/tests/meta/018
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Western Digital Corporation or its affiliates.
+#
+# Test _set_combined_conditions() helper
+
+. tests/meta/rc
+
+DESCRIPTION="combine two set_conditions() hooks"
+
+conditions_x() {
+	local index=$1
+
+	if [[ -z $index ]]; then
+		echo 2
+		return
+	fi
+
+	meta_x_index=$index
+	COND_DESC="x=$index"
+}
+
+conditions_y() {
+	local index=$1
+
+	if [[ -z $index ]]; then
+		echo 2
+		return
+	fi
+
+	meta_y_index=$index
+	COND_DESC="y=$index"
+}
+
+set_conditions() {
+	_set_combined_conditions conditions_x conditions_y "$@"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+	echo "(x,y)=(${meta_x_index},${meta_y_index})" >> "$FULL"
+	echo "Test complete"
+}
diff --git a/tests/meta/018.out b/tests/meta/018.out
new file mode 100644
index 0000000..e1af26b
--- /dev/null
+++ b/tests/meta/018.out
@@ -0,0 +1,2 @@
+Running meta/018
+Test complete
diff --git a/tests/meta/019 b/tests/meta/019
new file mode 100755
index 0000000..2ec1ed9
--- /dev/null
+++ b/tests/meta/019
@@ -0,0 +1,55 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Western Digital Corporation or its affiliates.
+#
+# Test _set_combined_conditions() helper
+
+. tests/meta/rc
+
+DESCRIPTION="combine three set_conditions() hooks"
+
+conditions_x() {
+	local index=$1
+
+	if [[ -z $index ]]; then
+		echo 2
+		return
+	fi
+
+	meta_x_index=$index
+	COND_DESC="x=$index"
+}
+
+conditions_y() {
+	local index=$1
+
+	if [[ -z $index ]]; then
+		echo 2
+		return
+	fi
+
+	meta_y_index=$index
+	COND_DESC="y=$index"
+}
+
+conditions_z() {
+	local index=$1
+
+	if [[ -z $index ]]; then
+		echo 2
+		return
+	fi
+
+	meta_z_index=$index
+	COND_DESC="z=$index"
+}
+
+set_conditions() {
+	_set_combined_conditions conditions_x conditions_y conditions_z "$@"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+	echo "(x,y,z)=(${meta_x_index},${meta_y_index},${meta_z_index})" >> "$FULL"
+	echo "Test complete"
+}
diff --git a/tests/meta/019.out b/tests/meta/019.out
new file mode 100644
index 0000000..d8828ab
--- /dev/null
+++ b/tests/meta/019.out
@@ -0,0 +1,2 @@
+Running meta/019
+Test complete
diff --git a/tests/meta/rc b/tests/meta/rc
index 3a472be..a2f556e 100644
--- a/tests/meta/rc
+++ b/tests/meta/rc
@@ -57,3 +57,8 @@ EOF
 		echo "$line" >> /dev/kmsg
 	done < "$TMPDIR/dmesg"
 }
+
+# Global variables shared between set_conditions() and test()
+export meta_x_index=
+export meta_y_index=
+export meta_z_index=
-- 
2.44.0




More information about the Linux-nvme mailing list