Re: [PATCH blktests 1/5] tests/throtl: add first test for blk-throttle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/15/24 19:00, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@xxxxxxxxxx>
>
> Test basic functionality.
>
> Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
> ---
>   tests/throtl/001     | 84 ++++++++++++++++++++++++++++++++++++++++++++
>   tests/throtl/001.out |  6 ++++
>   tests/throtl/rc      | 15 ++++++++
>   3 files changed, 105 insertions(+)
>   create mode 100755 tests/throtl/001
>   create mode 100644 tests/throtl/001.out
>   create mode 100644 tests/throtl/rc
>
> diff --git a/tests/throtl/001 b/tests/throtl/001
> new file mode 100755
> index 0000000..79ecf07
> --- /dev/null
> +++ b/tests/throtl/001
> @@ -0,0 +1,84 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2024 Yu Kuai
> +#
> +# Test basic functionality of blk-throttle
> +
> +. tests/throtl/rc
> +
> +DESCRIPTION="basic functionality"
> +QUICK=1
> +
> +CG=/sys/fs/cgroup
> +TEST_DIR=$CG/blktests_throtl
> +devname=nullb0
> +dev=""
> +
> +set_up_test() {
> +	if ! _init_null_blk nr_devices=1; then
> +		return 1;
> +	fi
> +
> +	dev=$(cat /sys/block/$devname/dev)
> +	echo +io > $CG/cgroup.subtree_control
> +	mkdir $TEST_DIR
> +

move above to 3 lines to rc with helper instead of repeating the
code for every test ?

> +	return 0;
> +}
> +
> +clean_up_test() {
> +	rmdir $TEST_DIR
> +	echo -io > $CG/cgroup.subtree_control
> +	_exit_null_blk

same here ?

> +}
> +
> +config_throtl() {
> +	echo "$dev $*" > $TEST_DIR/io.max
> +}
> +
> +remove_config() {
> +	echo "$dev rbps=max wbps=max riops=max wiops=max" > $TEST_DIR/io.max
> +}
> +

same here for above two helper ?

> +test_io() {
> +	config_throtl "$1"
> +
> +	{
> +		sleep 0.1
> +		start_time=$(date +%s.%N)
> +
> +		if [ "$2" == "read" ]; then
> +			dd if=/dev/$devname of=/dev/null bs=4k count=256 iflag=direct status=none
> +		elif [ "$2" == "write" ]; then
> +			dd of=/dev/$devname if=/dev/zero bs=4k count=256 oflag=direct status=none
> +		fi

Is there a any specific reason to use dd and not fio ?

> +
> +		end_time=$(date +%s.%N)
> +		elapsed=$(echo "$end_time - $start_time" | bc)
> +		printf "%.0f\n" "$elapsed"
> +	} &
> +
> +	pid=$!
> +	echo $! > $TEST_DIR/cgroup.procs
> +	wait $pid
> +
> +	remove_config
> +}
> +

apparently test_io is also repeated can be moved to rc with right 
parameters ?

> +test() {
> +	echo "Running ${TEST_NAME}"
> +
> +	if ! set_up_test; then
> +		return 1;
> +	fi
> +
> +	_1MB=$((1024 * 1024))

starting variable name with _ seems a but weired, why not just pass
$((1024 *1024)) ?

> +
> +	test_io wbps=$_1MB write
> +	test_io wiops=256 write
> +	test_io rbps=$_1MB read
> +	test_io riops=256 read
> +
> +	clean_up_test
> +	echo "Test complete"
> +}
> diff --git a/tests/throtl/001.out b/tests/throtl/001.out
> new file mode 100644
> index 0000000..a3edfdd
> --- /dev/null
> +++ b/tests/throtl/001.out
> @@ -0,0 +1,6 @@
> +Running throtl/001
> +1
> +1
> +1
> +1
> +Test complete
> diff --git a/tests/throtl/rc b/tests/throtl/rc
> new file mode 100644
> index 0000000..8fa8b58
> --- /dev/null
> +++ b/tests/throtl/rc
> @@ -0,0 +1,15 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2024 Yu Kuai
> +#
> +# Tests for blk-throttle
> +
> +. common/rc
> +. common/null_blk
> +
> +group_requires() {
> +	_have_root
> +	_have_null_blk
> +	_have_kernel_option BLK_DEV_THROTTLING
> +	_have_cgroup2_controller io
> +}

apart from that thanks for the tests ..

-ck






[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux