[LTP] [PATCH v5 3/3] controllers/cpuacct: fix rmdir failures on early test abort

Krzysztof Kozlowski krzysztof.kozlowski@canonical.com
Thu Sep 2 10:24:01 CEST 2021


On 02/09/2021 10:18, Petr Vorel wrote:
> Hi Krzysztof,
> 
> ...
>> -	if [ -d "$testpath/subgroup_1" ]; then
>> -		rmdir $testpath/subgroup_*
>> +	if [ "$testpath" ]; then
>> +		if [ -d "$testpath/subgroup_1" ]; then
>> +			rmdir $testpath/subgroup_*
>> +		fi
>> +		rmdir $testpath
>>  	fi
> 
>> -	rmdir $testpath
>> -
> 
> LGTM, but how about use `rm -rf' instead?
> 
> e.g.
> 
> if [ "$testpath" ]; then
> 	rm -rf $testpath
> fi
> 
> That could simplify checks. Or is it needed to use `rmdir' to make sure there is
> no content in the directory? I suppose check like this is needed in cleanup,
> thus no problem to use `rm -rf'.

It isn't the point of this patch. I don't add here rmdir - all this code
was here before. The only thing added here is to check whether the
"testpath" variable is set or not.

I think using rm -rf should work, but anyway it's a separate commit :)


Best regards,
Krzysztof


More information about the ltp mailing list