Skip to contentSkip to conversation

damon/{self,kunit}tests: minor fixups for DAMON debugfs interface tests

PATCH Applied SeongJae Park 1 participant 7 messages Oct 28, 2024

Subsystems (3)
lore
Share & tools
lore

SeongJae Park

author maintainer
#0 lore raw

cover damon/{self,kunit}tests: minor fixups for DAMON debugfs interface tests

Fixup small broken window panes in DAMON selftests and kunit tests.

First four patches clean up DAMON debugfs interface selftests output, by fixing segmentation fault of a test program (patch 1), removing unnecessary debugging messages (patch 2), and hiding error messages from expected failures (patches 3 and 4).

Following two patches fix copy-paste mistakes in DAMON Kconfig help message that copied from debugfs kunit test (patch 5) and a comment on the debugfs kunit test code (patch 6).

Andrew Paniakin (1):
selftests/damon/huge_count_read_write: provide sufficiently large
buffer for DEPRECATED file read

SeongJae Park (5):
selftests/damon/huge_count_read_write: remove unnecessary debugging
message
selftests/damon/_debugfs_common: hide expected error message from
test_write_result()
selftests/damon/debugfs_duplicate_context_creation: hide errors from
expected file write failures
mm/damon/Kconfig: update DBGFS_KUNIT prompt copy for SYSFS_KUNIT mm/damon/tests/dbgfs-kunit: fix the header double inclusion guarding
ifdef comment

 mm/damon/Kconfig                                           | 2 +-
 mm/damon/tests/dbgfs-kunit.h                               | 2 +-
 tools/testing/selftests/damon/_debugfs_common.sh           | 7 ++++++-
 .../selftests/damon/debugfs_duplicate_context_creation.sh  | 2 +-
 tools/testing/selftests/damon/huge_count_read_write.c      | 4 +---
 5 files changed, 10 insertions(+), 7 deletions(-)

base-commit: 13583c750117b4e10cdaf5578dcc7723b305ce4e

Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/6 selftests/damon/huge_count_read_write: provide sufficiently large buffer for DEPRECATED file read

From: Andrew Paniakin <[email protected]>

'huge_count_read_write' crashes with segmentation fault when reading DEPRECATED file of DAMON debugfs interface. This is not causing any problem for users or other tests because the purpose of the test is just ensuring the read is not causing kernel warning messages. Nonetheless, it makes the output unnecessarily noisy, and the DEPRECATED file is not properly being tested.

It happens because the size of the content of the file is larger than the size of the buffer for the read. The file contains about 170 characters. Increase the buffer size to 256 characters.

Fixes b4a002889d24 ("selftests/damon: test debugfs file reads/writes with huge count")

---

Note that this fix has originally wrote[1] by Andrew for the downstream version of the same test. Because the downstream version is hosted on GitHub, the original patch was posted via GitHub pull request, not to the mailing list.

[1] https://github.com/damonitor/damon-tests/commit/fec6e1f4559a

 tools/testing/selftests/damon/huge_count_read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/damon/huge_count_read_write.c +1 -1
index a6fe0689f88d..f3c199dc8eba 100644
@@ -18,7 +18,7 @@
 void write_read_with_huge_count(char *file)
 {
 	int filedesc = open(file, O_RDWR);
-	char buf[25];
+	char buf[256];
 	int ret;
 
 	printf("%s %s\n", __func__, file);
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH 2/6 selftests/damon/huge_count_read_write: remove unnecessary debugging message

In reply to SeongJae Park

The program prints expected errors from write/read of the files with invalid huge count, for only debugging purpose. It is only making the output noisy. Remove those.

Fixes b4a002889d24 ("selftests/damon: test debugfs file reads/writes with huge count")
---
 tools/testing/selftests/damon/huge_count_read_write.c | 2 --
 1 file changed, 2 deletions(-)
tools/testing/selftests/damon/huge_count_read_write.c +0 -2
index f3c199dc8eba..53e69a669668 100644
@@ -28,9 +28,7 @@ void write_read_with_huge_count(char *file)
 	}
 
 	write(filedesc, "", 0xfffffffful);
-	perror("after write: ");
 	ret = read(filedesc, buf, 0xfffffffful);
-	perror("after read: ");
 	close(filedesc);
 }
 
Signature · 1 line
2.39.5
author maintainer
#3 lore raw

PATCH 3/6 selftests/damon/_debugfs_common: hide expected error message from test_write_result()

In reply to SeongJae Park

DAMON debugfs interface selftests use test_write_result() to check if valid or invalid writes to files of the interface success or fail as expected. File write error messages from expected failures are only making the output noisy. Hide such expected error messages.

Fixes b348eb7abd09 ("mm/damon: add user space selftests")
---
 tools/testing/selftests/damon/_debugfs_common.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/damon/_debugfs_common.sh +6 -1
index aa995516870b..54d45791b0d9 100644
@@ -8,7 +8,12 @@ test_write_result() {
 	expect_reason=$4
 	expected=$5
 
-	echo "$content" > "$file"
+	if [ "$expected" = "0" ]
+	then
+		echo "$content" > "$file"
+	else
+		echo "$content" > "$file" 2> /dev/null
+	fi
 	if [ $? -ne "$expected" ]
 	then
 		echo "writing $content to $file doesn't return $expected"
Signature · 1 line
2.39.5
author maintainer
#4 lore raw

PATCH 4/6 selftests/damon/debugfs_duplicate_context_creation: hide errors from expected file write failures

In reply to SeongJae Park

debugfs_duplicate_context_creation.sh does an invalid file write to ensure it fails. Check of the failure is sufficient, so the error message from the failure only makes the output unnecessarily noisy. Hide it.

Fixes ade38b8ca5ce ("selftest/damon: add a test for duplicate context dirs creation")
---
 .../selftests/damon/debugfs_duplicate_context_creation.sh       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh +1 -1
index 4a76e37ef16b..bd6c22d96ead 100755
@@ -12,7 +12,7 @@ then
 	exit 1
 fi
 
-if echo foo > "$DBGFS/mk_contexts"
+if echo foo > "$DBGFS/mk_contexts" 2> /dev/null
 then
 	echo "duplicate context creation success"
 	exit 1
Signature · 1 line
2.39.5
author maintainer
#5 lore raw

PATCH 5/6 mm/damon/Kconfig: update DBGFS_KUNIT prompt copy for SYSFS_KUNIT

In reply to SeongJae Park

CONFIG_DAMON_SYSFS_KUNIT_TEST prompt is copied from that for DAMON debugfs interface kunit tests, and not correctly updated. Fix it.

Fixes b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()")
---
 mm/damon/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/Kconfig +1 -1
index 35b72f88983a..d0357f3e9372 100644
@@ -60,7 +60,7 @@ config DAMON_SYSFS
 	  the interface for arbitrary data access monitoring.
 
 config DAMON_SYSFS_KUNIT_TEST
-	bool "Test for damon debugfs interface" if !KUNIT_ALL_TESTS
+	bool "Test for damon sysfs interface" if !KUNIT_ALL_TESTS
 	depends on DAMON_SYSFS && KUNIT=y
 	default KUNIT_ALL_TESTS
 	help
Signature · 1 line
2.39.5
author maintainer
#6 lore raw

PATCH 6/6 mm/damon/tests/dbgfs-kunit: fix the header double inclusion guarding ifdef comment

In reply to SeongJae Park

Closing part of double inclusion guarding macro for dbgfs-kunit.h was copy-pasted from somewhere (maybe before the initial mainline merge of DAMON), and not properly updated. Fix it.

Fixes 17ccae8bb5c9 ("mm/damon: add kunit tests")
---
 mm/damon/tests/dbgfs-kunit.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/tests/dbgfs-kunit.h +1 -1
index d2ecfcc8db86..087e53f641a8 100644
@@ -168,6 +168,6 @@ static struct kunit_suite damon_test_suite = {
 };
 kunit_test_suite(damon_test_suite);
 
-#endif /* _DAMON_TEST_H */
+#endif /* _DAMON_DBGFS_TEST_H */
 
 #endif	/* CONFIG_DAMON_KUNIT_TEST */
Signature · 1 line
2.39.5