[LTP] [PATCH v3] sysctl/sysctl02: Add new regression test for overflow file-max

Yang Xu xuyang2018.jy@cn.fujitsu.com
Fri Jun 21 03:26:19 CEST 2019


> Hi,
>
> LGTM, below are just small formatting issues.
> I'm going to merge it with these changes below.
>
>> Signed-off-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> ---
>>   runtest/commands                      |  1 +
>>   testcases/commands/sysctl/sysctl02.sh | 96 +++++++++++++++++++++++++++
>>   2 files changed, 97 insertions(+)
>>   create mode 100755 testcases/commands/sysctl/sysctl02.sh
> ...
>> +sysctl_test_overflow()
>> +{
>> +	local old_value=$(cat "$dir""$name")
>> +
>> +	sysctl -w "fs.file-max"=$1>/dev/null 2>&1
>> +
>> +	local test_value=$(cat "$dir""$name")
> again, why 2 stings instead of one?
> local test_value=$(cat "$dir$name")
Hi Petr

  I use 2 strings because sysctl uses "fs.file-max" but cat uses "fs/file-max" file.
  Your big changes look good to me.  Thanks for your changes.

>> +
>> +	echo ${test_value} |grep -q ${old_value}
>> +	if [ $? -eq 0 ]; then
>> +		tst_res TPASS "file-max overflow, reject it and keep old value."
> Please don't use dot
>
>> +	else
>> +		tst_res TFAIL "file-max overflow and set it to ${test_value}."
> Here as well.
>
>> +	fi
>> +	cleanup
>> +}
>> +
>> +sysctl_test_zero()
>> +{
>> +	sysctl -w "fs.file-max"=0>/dev/null 2>&1
> Please use -q option instead of redirecting.
>> +	[ ! -f "$syms_file" ]&&  tst_brk TCONF \
>> +		"$syms_file was not supported"
>> +	cat $syms_file  |grep kasan_report>/dev/null 2>&1
>> +	if [ $? -eq 0 ]; then
> Also grep has -q, no need to use pipe:
>
> if grep -q kasan_report $syms_file; then
>
>> +		dmesg | grep "KASAN: global-out-of-bounds in __do_proc_doulongvec_minmax">/dev/null
> -q here as well.
>
>> +		if [ $? -eq 0 ]; then
>> +			tst_res TFAIL "file-max is set 0 and trigger a KASAN error"
>> +		else
>> +			tst_res TPASS \
>> +				"file-max is set 0 and doesn't trigger a KASAN error"
> Probably can be on single line.
>
>> +		fi
>> +	else
>> +		tst_res TCONF "kernel doesn't support KASAN"
>> +	fi
>> +}
>> +
>> +cleanup()
>> +{
>> +	sysctl -w "fs.""$name"=${orig_value}>/dev/null 2>&1
> It's safe not quote string ($name is safe, but you can of course)
> sysctl -q -w fs.$name=$orig_value
>
>> +}
>> +
>> +tst_run
>
> .
>





More information about the ltp mailing list