Skip to contentSkip to conversation

selftests: helpers: handle multi line in test_sysfs_prop_optional_list

PATCH Superseded Boris Shtrasman 1 participant 2 messages Jun 25 – Jun 26

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: helpers: handle multi line in test_sysfs_prop_optional_list

Modify test_sysfs_prop_optional_list to allow multi line parameters, in order to comply with checkpatch output that limit line by 100 chars.

Allow use cases like:

test_sysfs_prop_optional_list \
        property_name "value1","value2","val3","very_long_option"\
        ,"extra_long_option" \
	,"even_more_data"
---
 tools/testing/selftests/power_supply/helpers.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/power_supply/helpers.sh +4 -4
index 1ec90d7c9108..8535cb7ed094 100644
@@ -108,7 +108,7 @@ test_sysfs_prop_optional_range() {
 
 test_sysfs_prop_optional_list() {
 	PROP=$1
-	LIST=$2
+	shift
 
 	TEST_NAME="$DEVNAME".sysfs."$PROP"
 
@@ -118,9 +118,9 @@ test_sysfs_prop_optional_list() {
 	valid=0
 
 	OLDIFS=$IFS
-	IFS=","
-	for item in $LIST; do
-		if [ "$DATA" = "$item" ]; then
+	IFS=",IFS"
+	for item in $*; do
+		if [ "$item" ] && [ "$DATA" = "$item" ]; then
 			valid=1
 			break
 		fi
Signature · 1 line
2.47.3
#1 lore raw
Quoted 32 lines · On Thursday, 25 June 2026 15:52:37 Israel Daylight Time Boris Shtrasman wrote:

Modify test_sysfs_prop_optional_list to allow multi line parameters, in order to comply with checkpatch output that limit line by 100 chars.

Allow use cases like:

test_sysfs_prop_optional_list \
        property_name "value1","value2","val3","very_long_option"\
        ,"extra_long_option" \
	,"even_more_data"
---
 tools/testing/selftests/power_supply/helpers.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/power_supply/helpers.sh +1 -1
index 1ec90d7c9108..8535cb7ed094 100644
@@ -108,7 +108,7 @@ test_sysfs_prop_optional_range() {
 
 test_sysfs_prop_optional_list() {
 	PROP=$1
-	LIST=$2
+	shift
 
 	TEST_NAME="$DEVNAME".sysfs."$PROP"
 
@@ -118,9 +118,9 @@ test_sysfs_prop_optional_list() {
 	valid=0
 

tools/testing/selftests/power_supply/helpers.sh test_sysfs_prop_optional_list() { · line 126

Quoted 10 lines
tools/testing/selftests/power_supply/helpers.sh +3 -3
 	OLDIFS=$IFS
-	IFS=","
-	for item in $LIST; do
-		if [ "$DATA" = "$item" ]; then
+	IFS=",IFS"
+	for item in $*; do
+		if [ "$item" ] && [ "$DATA" = "$item" ]; then
 			valid=1
 			break
 		fi

A new version of this patch now at
https://lore.kernel.org/linux-pm/[email protected]/