Re: [PATCH v30 12/13] mm/damon: Add user space selftests

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

 



On Wed, 2021-06-16 at 07:31 +0000, SeongJae Park wrote:
> From: SeongJae Park <sjpark@xxxxxxxxx>
> 
> This commit adds a simple user space tests for DAMON.  The tests are
> using kselftest framework.
> 
> Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
> ---
>  tools/testing/selftests/damon/Makefile        |  7 ++
>  .../selftests/damon/_chk_dependency.sh        | 28 +++++++
>  .../testing/selftests/damon/debugfs_attrs.sh  | 75 +++++++++++++++++++
>  3 files changed, 110 insertions(+)
>  create mode 100644 tools/testing/selftests/damon/Makefile
>  create mode 100644 tools/testing/selftests/damon/_chk_dependency.sh
>  create mode 100755 tools/testing/selftests/damon/debugfs_attrs.sh
> 
> [...]
> diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh
> new file mode 100755
> index 000000000000..60342d6c86d8
> --- /dev/null
> +++ b/tools/testing/selftests/damon/debugfs_attrs.sh
> @@ -0,0 +1,75 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +test_write_result() {
> +	file=$1
> +	content=$2
> +	orig_content=$3
> +	expect_reason=$4
> +	expected=$5
> +
> +	echo "$content" > "$file"
> +	if [ $? -ne "$expected" ]
> +	then
> +		echo "writing $content to $file doesn't return $expected"
> +		echo "expected because: $expect_reason"
> +		echo "$orig_content" > "$file"
> +		exit 1
> +	fi
> +}
> +
> +test_write_succ() {
> +	test_write_result "$1" "$2" "$3" "$4" 0
> +}
> +
> +test_write_fail() {
> +	test_write_result "$1" "$2" "$3" "$4" 1
> +}
> +
> +test_content() {
> +	file=$1
> +	orig_content=$2
> +	expected=$3
> +	expect_reason=$4
> +
> +	content=$(cat "$file")
> +	if [ "$content" != "$content" ]

That'll always evaluate false and should compare against "expected"
instead.

> +	then
> +		echo "reading $file expected $expected but $content"
> +		echo "expected because: $expect_reason"
> +		echo "$orig_content" > "$file"
> +		exit 1
> +	fi
> +}
> 
> [...]


Otherwise looking good.

Best regards,
Markus



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879






[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux