diff mbox series

[v3,1/5] fstests: common/rc: set_fs_sysfs_attr: redirect errors to stdout

Message ID e18babf503e66ce798c3df4353174afd4f771303.1740395948.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 Feb. 24, 2025, 12:15 p.m. UTC
Redirect sysfs write errors to stdout as a preparatory patch to enable
testing of expected sysfs write failures. Also, log the executed
sysfs write command and its failure if any to seqres.full for better
debugging and traceability.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/rc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Darrick J. Wong Feb. 24, 2025, 6:18 p.m. UTC | #1
On Mon, Feb 24, 2025 at 08:15:04PM +0800, Anand Jain wrote:
> Redirect sysfs write errors to stdout as a preparatory patch to enable
> testing of expected sysfs write failures. Also, log the executed
> sysfs write command and its failure if any to seqres.full for better
> debugging and traceability.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  common/rc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/common/rc b/common/rc
> index cf6316a224ff..942e201649dd 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -5081,7 +5081,8 @@ _set_fs_sysfs_attr()
>  
>  	local dname=$(_fs_sysfs_dname $dev)
>  
> -	echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr}
> +	echo "echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $seqres.full

Did you mean to    ^ escape ^ these double-quotes?  Without it,
whitespace in $content might not be logged correctly.

--D

> +	echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $seqres.full
>  }
>  
>  # Print the content of /sys/fs/$FSTYP/$DEV/$ATTR
> -- 
> 2.43.5
> 
>
Anand Jain Feb. 25, 2025, 12:20 a.m. UTC | #2
On 2/25/25 02:18, Darrick J. Wong wrote:
> On Mon, Feb 24, 2025 at 08:15:04PM +0800, Anand Jain wrote:
>> Redirect sysfs write errors to stdout as a preparatory patch to enable
>> testing of expected sysfs write failures. Also, log the executed
>> sysfs write command and its failure if any to seqres.full for better
>> debugging and traceability.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   common/rc | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/rc b/common/rc
>> index cf6316a224ff..942e201649dd 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -5081,7 +5081,8 @@ _set_fs_sysfs_attr()
>>   
>>   	local dname=$(_fs_sysfs_dname $dev)
>>   
>> -	echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr}
>> +	echo "echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $seqres.full
> 
> Did you mean to    ^ escape ^ these double-quotes?  Without it,
> whitespace in $content might not be logged correctly.
> 

Oh no! I remember fixing this. Looks like I messed it up during the rebase.

I’ve fixed it locally and will wait before sending.

Thx.


> --D
> 
>> +	echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $seqres.full
>>   }
>>   
>>   # Print the content of /sys/fs/$FSTYP/$DEV/$ATTR
>> -- 
>> 2.43.5
>>
>>
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index cf6316a224ff..942e201649dd 100644
--- a/common/rc
+++ b/common/rc
@@ -5081,7 +5081,8 @@  _set_fs_sysfs_attr()
 
 	local dname=$(_fs_sysfs_dname $dev)
 
-	echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr}
+	echo "echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $seqres.full
+	echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $seqres.full
 }
 
 # Print the content of /sys/fs/$FSTYP/$DEV/$ATTR