Skip to contentSkip to conversation

Restore the kernel v5.13 text attribute write behavior

PATCH Applied Bart Van Assche 4 participants 14 messages Aug 5, 2021 – Mar 1, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover Restore the kernel v5.13 text attribute write behavior

Hi Christoph,

This patch series restores the v5.13 text attribute write behavior and also adds unit tests for configfs. Please consider these patches for inclusion in the Linux kernel.

Thanks,

Bart.

Changes compared to v3:
- Changed config CONFIGFS_KUNIT_TEST from tristate into bool. The unit test calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. This was detected by the kernel build robot.

Changes compared to v2:
- Modified description of patch 2/3.

Changes compared to v1:
- Instead of making the text attribute write behavior POSIX compliant, restore the v5.13 behavior.
- Added more unit tests.

Bart Van Assche (3):
configfs: Restore the kernel v5.13 text attribute write behavior
kunit: Add support for suite initialization and cleanup
configfs: Add unit tests

 fs/configfs/Kconfig         |   8 +
 fs/configfs/Makefile        |   2 +
 fs/configfs/configfs-test.c | 429 ++++++++++++++++++++++++++++++++++++
 fs/configfs/file.c          |  18 +-
 include/kunit/test.h        |   4 +
 lib/kunit/test.c            |  14 ++
 6 files changed, 463 insertions(+), 12 deletions(-)
 create mode 100644 fs/configfs/configfs-test.c
#1 lore raw

PATCH v4 1/3 configfs: Restore the kernel v5.13 text attribute write behavior

Instead of appending new text attribute data at the offset specified by the write() system call, only pass the newly written data to the .store() callback.

Cc Bodo Stroesser <[email protected]>
Cc Martin K. Petersen <[email protected]>
Cc Yanko Kaneti <[email protected]>
Cc Brendan Higgins <[email protected]>
---
 fs/configfs/file.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
fs/configfs/file.c +6 -12
index 5a0be9985bae..0ad32150611e 100644
@@ -177,28 +177,22 @@ static ssize_t configfs_bin_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	return retval;
 }
 
-/* Fill [buffer, buffer + pos) with data coming from @from. */
-static int fill_write_buffer(struct configfs_buffer *buffer, loff_t pos,
+/* Fill @buffer with data coming from @from. */
+static int fill_write_buffer(struct configfs_buffer *buffer,
 			     struct iov_iter *from)
 {
-	loff_t to_copy;
 	int copied;
-	u8 *to;
 
 	if (!buffer->page)
 		buffer->page = (char *)__get_free_pages(GFP_KERNEL, 0);
 	if (!buffer->page)
 		return -ENOMEM;
 
-	to_copy = SIMPLE_ATTR_SIZE - 1 - pos;
-	if (to_copy <= 0)
-		return 0;
-	to = buffer->page + pos;
-	copied = copy_from_iter(to, to_copy, from);
+	copied = copy_from_iter(buffer->page, SIMPLE_ATTR_SIZE - 1, from);
 	buffer->needs_read_fill = 1;
 	/* if buf is assumed to contain a string, terminate it by \0,
 	 * so e.g. sscanf() can scan the string easily */
-	to[copied] = 0;
+	buffer->page[copied] = 0;
 	return copied ? : -EFAULT;
 }
 
@@ -227,10 +221,10 @@ static ssize_t configfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct file *file = iocb->ki_filp;
 	struct configfs_buffer *buffer = file->private_data;
-	ssize_t len;
+	int len;
 
 	mutex_lock(&buffer->mutex);
-	len = fill_write_buffer(buffer, iocb->ki_pos, from);
+	len = fill_write_buffer(buffer, from);
 	if (len > 0)
 		len = flush_write_buffer(file, buffer, len);
 	if (len > 0)
#2 lore raw

PATCH v4 2/3 kunit: Add support for suite initialization and cleanup

In reply to Bart Van Assche

A common feature of unit testing frameworks is support for sharing a test configuration across multiple unit tests. Add this functionality to the KUnit framework. This functionality will be used in the next patch in this series.

---
 include/kunit/test.h |  4 ++++
 lib/kunit/test.c     | 14 ++++++++++++++
 2 files changed, 18 insertions(+)
include/kunit/test.h +4 -0
index 24b40e5c160b..a6eef96a409c 100644
@@ -215,6 +215,8 @@ static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
  * struct kunit_suite - describes a related collection of &struct kunit_case
  *
  * @name:	the name of the test. Purely informational.
+ * @init_suite:	called once per test suite before the test cases.
+ * @exit_suite:	called once per test suite after all test cases.
  * @init:	called before every test case.
  * @exit:	called after every test case.
  * @test_cases:	a null terminated array of test cases.
@@ -229,6 +231,8 @@ static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
  */
 struct kunit_suite {
 	const char name[256];
+	int (*init_suite)(void);
+	void (*exit_suite)(void);
 	int (*init)(struct kunit *test);
 	void (*exit)(struct kunit *test);
 	struct kunit_case *test_cases;
lib/kunit/test.c +14 -0
index d79ecb86ea57..c271692ced93 100644
@@ -397,9 +397,19 @@ int kunit_run_tests(struct kunit_suite *suite)
 {
 	char param_desc[KUNIT_PARAM_DESC_SIZE];
 	struct kunit_case *test_case;
+	int res = 0;
 
 	kunit_print_subtest_start(suite);
 
+	if (suite->init_suite)
+		res = suite->init_suite();
+
+	if (res < 0) {
+		kunit_log(KERN_INFO, suite, KUNIT_SUBTEST_INDENT
+			  "# Suite initialization failed (%d)\n", res);
+		goto end;
+	}
+
 	kunit_suite_for_each_test_case(suite, test_case) {
 		struct kunit test = { .param_value = NULL, .param_index = 0 };
 		test_case->status = KUNIT_SKIPPED;
@@ -439,6 +449,10 @@ int kunit_run_tests(struct kunit_suite *suite)
 				      test.status_comment);
 	}
 
+	if (suite->exit_suite)
+		suite->exit_suite();
+
+end:
 	kunit_print_subtest_end(suite);
 
 	return 0;
#3 lore raw

PATCH v4 3/3 configfs: Add unit tests

In reply to Bart Van Assche

Testing configfs read and write behavior is non-trivial and tedious. Hence these configfs kunit tests that make it easier to test configfs text and binary attribute support. This is how I run these tests:

set -e
if [ -e .config ]; then
make ARCH=um mrproper
fi
if [ ! -e .kunit/.kunitconfig ]; then
cat <<EOF >.kunit/.kunitconfig
CONFIG_CONFIGFS_FS=y
CONFIG_CONFIGFS_KUNIT_TEST=y
CONFIG_KUNIT=y
CONFIG_PROVE_LOCKING=y
CONFIG_SYSFS=y
CONFIG_UBSAN=y
EOF
cp .kunit/.kunitconfig .kunit/.config
fi
./tools/testing/kunit/kunit.py run

Cc Bodo Stroesser <[email protected]>
Cc Martin K. Petersen <[email protected]>
Cc Yanko Kaneti <[email protected]>
Cc Brendan Higgins <[email protected]>
---
 fs/configfs/Kconfig         |   8 +
 fs/configfs/Makefile        |   2 +
 fs/configfs/configfs-test.c | 429 ++++++++++++++++++++++++++++++++++++
 3 files changed, 439 insertions(+)
 create mode 100644 fs/configfs/configfs-test.c
fs/configfs/Kconfig +8 -0
index 272b64456999..bbd7867407df 100644
@@ -10,3 +10,11 @@ config CONFIGFS_FS
 
 	  Both sysfs and configfs can and should exist together on the
 	  same system. One is not a replacement for the other.
+
+config CONFIGFS_KUNIT_TEST
+	bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+	depends on CONFIGFS_FS && KUNIT=y
+	default KUNIT_ALL_TESTS
+	help
+	  Run the configfs unit tests at boot time. For more information, see
+	  also the Kunit documentation in Documentation/dev-tools/kunit/.
fs/configfs/Makefile +2 -0
index 0200498ede27..388003fa9f37 100644
@@ -6,3 +6,5 @@
 obj-$(CONFIG_CONFIGFS_FS)	+= configfs.o
 
 configfs-objs	:= inode.o file.o dir.o symlink.o mount.o item.o
+
+obj-$(CONFIG_CONFIGFS_KUNIT_TEST) += configfs-test.o
fs/configfs/configfs-test.c new file +429 -0

429 lines not on this page · raw message

#4 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 18 lines

text and binary attribute support. This is how I run these tests:

set -e
if [ -e .config ]; then
make ARCH=um mrproper
fi
if [ ! -e .kunit/.kunitconfig ]; then
cat <<EOF >.kunit/.kunitconfig
CONFIG_CONFIGFS_FS=y
CONFIG_CONFIGFS_KUNIT_TEST=y
CONFIG_KUNIT=y
CONFIG_PROVE_LOCKING=y
CONFIG_SYSFS=y
CONFIG_UBSAN=y
EOF
cp .kunit/.kunitconfig .kunit/.config
fi
./tools/testing/kunit/kunit.py run

This is very useful documentation, but shouldn't it go into a README.kunit or similar instead of a commit message?

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 4 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+	bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+	depends on CONFIGFS_FS && KUNIT=y
+	default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

Quoted 6 lines
fs/configfs/configfs-test.c new file +6 -0
+static int mkdir(const char *name, umode_t mode)
+{
+	struct dentry *dentry;
+	struct path path;
+	int err;
+

fs/configfs/configfs-test.c line 118

Quoted 10 lines
fs/configfs/configfs-test.c new file +10 -0
+	err = get_file_mode(name);
+	if (err >= 0 && S_ISDIR(err))
+		return 0;
+
+	dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY);
+	if (IS_ERR(dentry))
+		return PTR_ERR(dentry);
+
+	err = vfs_mkdir(&init_user_ns, d_inode(path.dentry), dentry, mode);
+	done_path_create(&path, dentry);

To me this sounds like userspace would be a better place for these kinds of tests.

#5 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 19 lines · Christoph Hellwig
Quoted 18 lines

text and binary attribute support. This is how I run these tests:

set -e
if [ -e .config ]; then
make ARCH=um mrproper
fi
if [ ! -e .kunit/.kunitconfig ]; then
cat <<EOF >.kunit/.kunitconfig
CONFIG_CONFIGFS_FS=y
CONFIG_CONFIGFS_KUNIT_TEST=y
CONFIG_KUNIT=y
CONFIG_PROVE_LOCKING=y
CONFIG_SYSFS=y
CONFIG_UBSAN=y
EOF
cp .kunit/.kunitconfig .kunit/.config
fi
./tools/testing/kunit/kunit.py run

Quoted 2 lines

This is very useful documentation, but shouldn't it go into a README.kunit or similar instead of a commit message?

I can store this documentation in a new README, but isn't this something that has already been explained in Documentation/dev-tools/kunit/kunit-tool.rst?

Quoted 7 lines

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 4 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+	bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+	depends on CONFIGFS_FS && KUNIT=y
+	default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

Quoted 11 lines
Quoted 11 lines
fs/configfs/configfs-test.c new file +11 -0
+static int mkdir(const char *name, umode_t mode)
+{
+	struct dentry *dentry;
+	struct path path;
+	int err;
+
+	err = get_file_mode(name);
+	if (err >= 0 && S_ISDIR(err))
+		return 0;
+
+	dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY);
Quoted 8 lines

fs/configfs/configfs-test.c line 118

Quoted 5 lines
fs/configfs/configfs-test.c new file +5 -0
+	if (IS_ERR(dentry))
+		return PTR_ERR(dentry);
+
+	err = vfs_mkdir(&init_user_ns, d_inode(path.dentry), dentry, mode);
+	done_path_create(&path, dentry);

To me this sounds like userspace would be a better place for these kinds of tests.

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

Thanks,

Bart.

Nacked-by NAK
#6 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 3 lines · Bart Van Assche

I can store this documentation in a new README, but isn't this something that has already been explained in Documentation/dev-tools/kunit/kunit-tool.rst?

So reference that.

Quoted 11 lines
Quoted 8 lines

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 5 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+	bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+	depends on CONFIGFS_FS && KUNIT=y
+	default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

You should probably document that. But then again this is another big red flag that this code should live in userspace.

Quoted 7 lines
Quoted 2 lines

To me this sounds like userspace would be a better place for these kinds of tests.

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

But userspace is the right place to do this kind of pathname based file system I/O.

So for the current in-kernel approach:

#7 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 18 lines · Christoph Hellwig
Quoted 10 lines · Bart Van Assche
Quoted 7 lines

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 4 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+	bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+	depends on CONFIGFS_FS && KUNIT=y
+	default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

You should probably document that. But then again this is another big red flag that this code should live in userspace.

Quoted 3 lines
Quoted 2 lines

To me this sounds like userspace would be a better place for these kinds of tests.

Quoted 7 lines
Quoted 4 lines

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

But userspace is the right place to do this kind of pathname based file system I/O.

Shuah, as selftest maintainer, can you recommend an approach? How about splitting patch 3/3 from this series into a kernel module (the code that creates the configfs test attributes) and user space code (the code that reads and writes the configfs attributes) and adding the user space code in a subdirectory of tools/testing/selftests/?

Thanks,

Bart.

maintainer
#8 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 24 lines · Bart Van Assche
Quoted 23 lines · Christoph Hellwig
Quoted 10 lines · Bart Van Assche
Quoted 7 lines
Quoted 4 lines

+config CONFIGFS_KUNIT_TEST
+    bool "Configfs Kunit test" if !KUNIT_ALL_TESTS +    depends on CONFIGFS_FS && KUNIT=y
+    default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y?  What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

You should probably document that.  But then again this is another big red flag that this code should live in userspace.

Quoted 7 lines
Quoted 2 lines

To me this sounds like userspace would be a better place for these kinds of tests.

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

Quoted 5 lines
Quoted 2 lines

But userspace is the right place to do this kind of pathname based file system I/O.

Shuah, as selftest maintainer, can you recommend an approach? How about splitting patch 3/3 from this series into a kernel module (the code that creates the configfs test attributes) and user space code (the code that reads and writes the configfs attributes) and adding the user space code in a subdirectory of tools/testing/selftests/?

I am missing a lot of context here. I don't see this series in my inbox except patch 2/3 which says:

"A common feature of unit testing frameworks is support for sharing a test configuration across multiple unit tests. Add this functionality to the KUnit framework. This functionality will be used in the next patch in this series."

That doesn't tell me much other than what happens that it is a common unit testing framework without explaining why it should be done this way.

Taking a quick look at the original message on lore - I agree with Christoph that this code belongs in userspace. I would like to see the division of kernel userspace.

Why do the unit tests need to call do_mount() - can whatever the unit tests are currently doing can be done from userspace.

If part of the test code must live in kernel space then kernel test module approach can be used.

thanks,
-- Shuah

#9 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 32 lines · Shuah Khan
Quoted 24 lines · Bart Van Assche
Quoted 23 lines · Christoph Hellwig
Quoted 10 lines · Bart Van Assche
Quoted 7 lines

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 4 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+    bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+    depends on CONFIGFS_FS && KUNIT=y
+    default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

You should probably document that. But then again this is another big red flag that this code should live in userspace.

Quoted 7 lines
Quoted 2 lines

To me this sounds like userspace would be a better place for these kinds of tests.

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

Quoted 5 lines
Quoted 2 lines

But userspace is the right place to do this kind of pathname based file system I/O.

Shuah, as selftest maintainer, can you recommend an approach? How about splitting patch 3/3 from this series into a kernel module (the code that creates the configfs test attributes) and user space code (the code that reads and writes the configfs attributes) and adding the user space code in a subdirectory of tools/testing/selftests/?

Quoted 7 lines

I am missing a lot of context here. I don't see this series in my inbox except patch 2/3 which says:

"A common feature of unit testing frameworks is support for sharing a test configuration across multiple unit tests. Add this functionality to the KUnit framework. This functionality will be used in the next patch in this series."

Yeah, I mentioned this to one of the other KUnit people who said he might want to post some comments. Bart, could you CC [email protected] and/or [email protected] if/when you send follow-up patches?

Actually, I suppose regardless of what you do with this patch, you will probably want to merge via the kselftest tree (KUnit changes and many tests go through the kselftest tree as well). So, you should probably CC [email protected] no matter what.

Quoted 19 lines

That doesn't tell me much other than what happens that it is a common unit testing framework without explaining why it should be done this way.

Taking a quick look at the original message on lore - I agree with Christoph that this code belongs in userspace. I would like to see the division of kernel userspace.

Why do the unit tests need to call do_mount() - can whatever the unit tests are currently doing can be done from userspace.

If part of the test code must live in kernel space then kernel test module approach can be used.

thanks,
-- Shuah

#10 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 47 lines · Brendan Higgins
Quoted 32 lines · Shuah Khan
Quoted 24 lines · Bart Van Assche
Quoted 23 lines · Christoph Hellwig
Quoted 10 lines · Bart Van Assche
Quoted 7 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+config CONFIGFS_KUNIT_TEST
+    bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+    depends on CONFIGFS_FS && KUNIT=y
+    default KUNIT_ALL_TESTS

Why does it depend on KUNIT=y? What is the issue with a modular KUNIT build?

The unit tests calls do_mount(). do_mount() has not been exported and hence is not available to kernel modules. Hence the exclusion of KUNIT=m.

You should probably document that. But then again this is another big red flag that this code should live in userspace.

Quoted 7 lines
Quoted 2 lines

To me this sounds like userspace would be a better place for these kinds of tests.

Splitting the code that can only be run from inside the kernel (creation of configfs attributes) and the code that can be run from user space and making sure that the two run in a coordinated fashion would involve a significant amount of work. I prefer to keep the current approach.

Quoted 5 lines
Quoted 2 lines

But userspace is the right place to do this kind of pathname based file system I/O.

Shuah, as selftest maintainer, can you recommend an approach? How about splitting patch 3/3 from this series into a kernel module (the code that creates the configfs test attributes) and user space code (the code that reads and writes the configfs attributes) and adding the user space code in a subdirectory of tools/testing/selftests/?

Quoted 7 lines

I am missing a lot of context here. I don't see this series in my inbox except patch 2/3 which says:

"A common feature of unit testing frameworks is support for sharing a test configuration across multiple unit tests. Add this functionality to the KUnit framework. This functionality will be used in the next patch in this series."

Yeah, I mentioned this to one of the other KUnit people who said he might want to post some comments. Bart, could you CC [email protected] and/or [email protected] if/when you send follow-up patches?

Quoted 17 lines

Actually, I suppose regardless of what you do with this patch, you will probably want to merge via the kselftest tree (KUnit changes and many tests go through the kselftest tree as well). So, you should probably CC [email protected] no matter what.

Quoted 12 lines

That doesn't tell me much other than what happens that it is a common unit testing framework without explaining why it should be done this way.

Taking a quick look at the original message on lore - I agree with Christoph that this code belongs in userspace. I would like to see the division of kernel userspace.

Why do the unit tests need to call do_mount() - can whatever the unit tests are currently doing can be done from userspace.

If part of the test code must live in kernel space then kernel test module approach can be used.

I am not sure if you are still working on this test or not, but Kees recently posted a patch to create a KUnit UAPI:
https://lore.kernel.org/lkml/[email protected]/

Not sure if you have any interest, or even if this would be the right tool for the job, but I figured it's worth a look because it might save you the effort of having to completely rewrite your test.

Cheers

#11 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

In reply to Christoph Hellwig
Quoted 20 lines · Christoph Hellwig
Quoted 19 lines

text and binary attribute support. This is how I run these tests:

set -e
if [ -e .config ]; then
make ARCH=um mrproper
fi
if [ ! -e .kunit/.kunitconfig ]; then
cat <<EOF >.kunit/.kunitconfig
CONFIG_CONFIGFS_FS=y
CONFIG_CONFIGFS_KUNIT_TEST=y
CONFIG_KUNIT=y
CONFIG_PROVE_LOCKING=y
CONFIG_SYSFS=y
CONFIG_UBSAN=y
EOF
cp .kunit/.kunitconfig .kunit/.config
fi
./tools/testing/kunit/kunit.py run

Quoted 2 lines

This is very useful documentation, but shouldn't it go into a README.kunit or similar instead of a commit message?

You could also put this in a .kunitconfig specific to your subsystem like we did for ext4:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/.kunitconfig

You can then build using this .kunitconfig with something like:

./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4/.kunitconfig

Quoted 4 lines

fs/configfs/Kconfig config CONFIGFS_FS · line 17

Quoted 4 lines
fs/configfs/Kconfig +4 -0
+config CONFIGFS_KUNIT_TEST
+     bool "Configfs Kunit test" if !KUNIT_ALL_TESTS
+     depends on CONFIGFS_FS && KUNIT=y
+     default KUNIT_ALL_TESTS

Cheers!

#12 lore raw

Re: [PATCH v4 3/3] configfs: Add unit tests

Quoted 24 lines · Brendan Higgins
Quoted 20 lines · Christoph Hellwig
Quoted 19 lines

text and binary attribute support. This is how I run these tests:

set -e
if [ -e .config ]; then
make ARCH=um mrproper
fi
if [ ! -e .kunit/.kunitconfig ]; then
cat <<EOF >.kunit/.kunitconfig
CONFIG_CONFIGFS_FS=y
CONFIG_CONFIGFS_KUNIT_TEST=y
CONFIG_KUNIT=y
CONFIG_PROVE_LOCKING=y
CONFIG_SYSFS=y
CONFIG_UBSAN=y
EOF
cp .kunit/.kunitconfig .kunit/.config
fi
./tools/testing/kunit/kunit.py run

Quoted 2 lines

This is very useful documentation, but shouldn't it go into a README.kunit or similar instead of a commit message?

Quoted 8 lines

You could also put this in a .kunitconfig specific to your subsystem like we did for ext4:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/.kunitconfig

You can then build using this .kunitconfig with something like:

./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4/.kunitconfig

Will look into this. Thanks for the feedback!

Bart.

#13 lore raw
In reply to Bart Van Assche

Thanks,

I've applied patch 1 and will send it to Linus this week.

Patch 2 seems like something that should go through the kunit tree, and if we do so patch 3 should go along with that.