fat: Add KUnit tests for checksums and timestamps
Subsystems (2)
PATCH v4 1/1 fat: Add KUnit tests for checksums and timestamps
Add some basic sanity-check tests for the fat_checksum() function and the fat_time_unix2fat() and fat_time_fat2unix() functions. These unit tests verify these functions return correct output for a number of test inputs.
These tests were inspored by -- and serve a similar purpose to -- the timestamp parsing KUnit tests in ext4[1].
Note that, unlike fat_time_unix2fat, fat_time_fat2unix wasn't previously exported, so this patch exports it as well. This is required for the case where we're building the fat and fat_test as modules.
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/inode-test.c
---
Changes since v3:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Update the Kconfig entry to use "depends on" rather than "select", as discussed in [2].
- Depend on "MSDOS_FS || VFAT_FS", rather than "FAT_FS", as we need the CONFIG_FAT_DEFAULT_CODEPAGE symbol to be defined.
Changes since v2:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Comment that the export for fat_time_fat2unix() function is for KUnit tests.
Changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Now export fat_time_fat2unix() so that the test can access it when built as a module.
[2]:
https://lore.kernel.org/linux-ext4/[email protected]/T/#t
fs/fat/Kconfig | 12 +++ fs/fat/Makefile | 2 + fs/fat/fat_test.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fat/misc.c | 2 + 4 files changed, 212 insertions(+) create mode 100644 fs/fat/fat_test.c
fs/fat/Kconfig +12 -0
@@ -115,3 +115,15 @@ config FAT_DEFAULT_UTF8 Say Y if you use UTF-8 encoding for file names, N otherwise. See <file:Documentation/filesystems/vfat.rst> for more information. + +config FAT_KUNIT_TEST + tristate "Unit Tests for FAT filesystems" if !KUNIT_ALL_TESTS + depends on KUNIT & (MSDOS_FS || VFAT_FS) + default KUNIT_ALL_TESTS + help + This builds the FAT KUnit tests + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit + + If unsure, say N
fs/fat/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_MSDOS_FS) += msdos.o fat-y := cache.o dir.o fatent.o file.o inode.o misc.o nfs.o vfat-y := namei_vfat.o msdos-y := namei_msdos.o + +obj-$(CONFIG_FAT_KUNIT_TEST) += fat_test.o
fs/fat/fat_test.c new file +196 -0
196 lines not on this page · raw message
fs/fat/misc.c +2 -0
@@ -229,6 +229,8 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, ts->tv_nsec =0 ; } } +/* Export fat_time_fat2unix() for the fat_test KUnit tests. */ +EXPORT_SYMBOL_GPL (fat_time_fat2unix);/* Convert linear UNIX date to a FAT time/date pair. */ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
kernel test robot
build botI love your patch! Yet something to improve:
Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201023]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/David-Gow/fat-Add-KUnit-tests-for-checksums-and-timestamps/20201024-132133 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f11901ed723d1351843771c3a84b03a253bbf8b2 config: sparc-randconfig-s031-20201024 compiler: sparc-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-17-g2d3af347-dirty
# https://github.com/0day-ci/linux/commit/3904bec3c79102be934e8021abb02c9176f099d7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-Gow/fat-Add-KUnit-tests-for-checksums-and-timestamps/20201024-132133 git checkout 3904bec3c79102be934e8021abb02c9176f099d7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
fs/fat/Kconfig:121:warning: ignoring unsupported character '&'
>> fs/fat/Kconfig:122: syntax error
fs/fat/Kconfig:121: invalid statement fs/fat/Kconfig:122: invalid statement fs/fat/Kconfig:123: invalid statement fs/fat/Kconfig:124: unknown statement "This" fs/fat/Kconfig:126:warning: ignoring unsupported character ',' fs/fat/Kconfig:126: unknown statement "For" fs/fat/Kconfig:127:warning: ignoring unsupported character '/' fs/fat/Kconfig:127:warning: ignoring unsupported character '/' fs/fat/Kconfig:127: unknown statement "to" fs/fat/Kconfig:129:warning: ignoring unsupported character ',' fs/fat/Kconfig:129: unknown statement "If"
make[2]: *** [scripts/kconfig/Makefile:71: oldconfig] Error 1 make[1]: *** [Makefile:604: oldconfig] Error 2
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'oldconfig' not remade because of errors.
--
fs/fat/Kconfig:121:warning: ignoring unsupported character '&'
>> fs/fat/Kconfig:122: syntax error
fs/fat/Kconfig:121: invalid statement fs/fat/Kconfig:122: invalid statement fs/fat/Kconfig:123: invalid statement fs/fat/Kconfig:124: unknown statement "This" fs/fat/Kconfig:126:warning: ignoring unsupported character ',' fs/fat/Kconfig:126: unknown statement "For" fs/fat/Kconfig:127:warning: ignoring unsupported character '/' fs/fat/Kconfig:127:warning: ignoring unsupported character '/' fs/fat/Kconfig:127: unknown statement "to" fs/fat/Kconfig:129:warning: ignoring unsupported character ',' fs/fat/Kconfig:129: unknown statement "If"
make[2]: *** [scripts/kconfig/Makefile:71: olddefconfig] Error 1 make[1]: *** [Makefile:604: olddefconfig] Error 2
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'olddefconfig' not remade because of errors.
vim +122 fs/fat/Kconfig
> 122 default KUNIT_ALL_TESTS
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v5 1/1 fat: Add KUnit tests for checksums and timestamps
In reply to David GowAdd some basic sanity-check tests for the fat_checksum() function and the fat_time_unix2fat() and fat_time_fat2unix() functions. These unit tests verify these functions return correct output for a number of test inputs.
These tests were inspored by -- and serve a similar purpose to -- the timestamp parsing KUnit tests in ext4[1].
Note that, unlike fat_time_unix2fat, fat_time_fat2unix wasn't previously exported, so this patch exports it as well. This is required for the case where we're building the fat and fat_test as modules.
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/inode-test.c
---
Whoops! Sent out a broken early version of this as v4 instead. Sorry about that!
-- David
Changes since v4:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Fix a typo introduced in the Kconfig. It builds now.
Changes since v3:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Update the Kconfig entry to use "depends on" rather than "select", as discussed in [2].
- Depend on "MSDOS_FS || VFAT_FS", rather than "FAT_FS", as we need the CONFIG_FAT_DEFAULT_CODEPAGE symbol to be defined.
Changes since v2:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Comment that the export for fat_time_fat2unix() function is for KUnit tests.
Changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Now export fat_time_fat2unix() so that the test can access it when built as a module.
[2]:
https://lore.kernel.org/linux-ext4/[email protected]/T/#t
fs/fat/Kconfig | 12 +++ fs/fat/Makefile | 2 + fs/fat/fat_test.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fat/misc.c | 2 + 4 files changed, 212 insertions(+) create mode 100644 fs/fat/fat_test.c
fs/fat/Kconfig +12 -0
@@ -115,3 +115,15 @@ config FAT_DEFAULT_UTF8 Say Y if you use UTF-8 encoding for file names, N otherwise. See <file:Documentation/filesystems/vfat.rst> for more information. + +config FAT_KUNIT_TEST + tristate "Unit Tests for FAT filesystems" if !KUNIT_ALL_TESTS + depends on KUNIT & (MSDOS_FS || VFAT_FS) + default KUNIT_ALL_TESTS + help + This builds the FAT KUnit tests + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit + + If unsure, say N
fs/fat/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_MSDOS_FS) += msdos.o fat-y := cache.o dir.o fatent.o file.o inode.o misc.o nfs.o vfat-y := namei_vfat.o msdos-y := namei_msdos.o + +obj-$(CONFIG_FAT_KUNIT_TEST) += fat_test.o
fs/fat/fat_test.c new file +196 -0
196 lines not on this page · raw message
fs/fat/misc.c +2 -0
@@ -229,6 +229,8 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, ts->tv_nsec =0 ; } } +/* Export fat_time_fat2unix() for the fat_test KUnit tests. */ +EXPORT_SYMBOL_GPL (fat_time_fat2unix);/* Convert linear UNIX date to a FAT time/date pair. */ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
PATCH v6 1/1 fat: Add KUnit tests for checksums and timestamps
Add some basic sanity-check tests for the fat_checksum() function and the fat_time_unix2fat() and fat_time_fat2unix() functions. These unit tests verify these functions return correct output for a number of test inputs.
These tests were inspored by -- and serve a similar purpose to -- the timestamp parsing KUnit tests in ext4[1].
Note that, unlike fat_time_unix2fat, fat_time_fat2unix wasn't previously exported, so this patch exports it as well. This is required for the case where we're building the fat and fat_test as modules.
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/inode-test.c
---
I am _so_ sorry: I sent out the wrong version again! It's clearly not my day! This version actually has the fix!
-- David
Changes since v4/v5:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Fix a typo introduced in the Kconfig. It builds now.
Changes since v3:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Update the Kconfig entry to use "depends on" rather than "select", as discussed in [2].
- Depend on "MSDOS_FS || VFAT_FS", rather than "FAT_FS", as we need the CONFIG_FAT_DEFAULT_CODEPAGE symbol to be defined.
Changes since v2:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Comment that the export for fat_time_fat2unix() function is for KUnit tests.
Changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Now export fat_time_fat2unix() so that the test can access it when built as a module.
[2]:
https://lore.kernel.org/linux-ext4/[email protected]/T/#t
fs/fat/Kconfig | 12 +++ fs/fat/Makefile | 2 + fs/fat/fat_test.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fat/misc.c | 2 + 4 files changed, 212 insertions(+) create mode 100644 fs/fat/fat_test.c
fs/fat/Kconfig +12 -0
@@ -115,3 +115,15 @@ config FAT_DEFAULT_UTF8 Say Y if you use UTF-8 encoding for file names, N otherwise. See <file:Documentation/filesystems/vfat.rst> for more information. + +config FAT_KUNIT_TEST + tristate "Unit Tests for FAT filesystems" if !KUNIT_ALL_TESTS + depends on KUNIT && (MSDOS_FS || VFAT_FS) + default KUNIT_ALL_TESTS + help + This builds the FAT KUnit tests + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit + + If unsure, say N
fs/fat/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_MSDOS_FS) += msdos.o fat-y := cache.o dir.o fatent.o file.o inode.o misc.o nfs.o vfat-y := namei_vfat.o msdos-y := namei_msdos.o + +obj-$(CONFIG_FAT_KUNIT_TEST) += fat_test.o
fs/fat/fat_test.c new file +196 -0
196 lines not on this page · raw message
fs/fat/misc.c +2 -0
@@ -229,6 +229,8 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, ts->tv_nsec =0 ; } } +/* Export fat_time_fat2unix() for the fat_test KUnit tests. */ +EXPORT_SYMBOL_GPL (fat_time_fat2unix);/* Convert linear UNIX date to a FAT time/date pair. */ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
OGAWA Hirofumi
maintainerQuoted 10 lines · David Gow
fs/fat/Kconfig +2
-0@@ -115,3 +115,15 @@ config FAT_DEFAULT_UTF8 Say Y if you use UTF-8 encoding for file names, N otherwise. See <file:Documentation/filesystems/vfat.rst> for more information. + +config FAT_KUNIT_TEST
fs/fat/Kconfig config FAT_DEFAULT_UTF8 · line 129
Quoted 10 lines
fs/fat/Kconfig +10
-0+ tristate "Unit Tests for FAT filesystems" if !KUNIT_ALL_TESTS + depends on KUNIT && (MSDOS_FS || VFAT_FS) + default KUNIT_ALL_TESTS + help + This builds the FAT KUnit tests + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit + + If unsure, say N
Maybe, the following would be better? With this, it looks like kunit works whether depends on or select.
Thanks.
fs/fat/Kconfig +13 -1
@@ -77,7 +77,7 @@ config VFAT_FS config FAT_DEFAULT_CODEPAGE int "Default codepage for FAT" - depends on MSDOS_FS || VFAT_FS + depends on FAT_FS default 437 help This option should be set to the codepage of your FAT filesystems.
@@ -115,3 +115,15 @@ config FAT_DEFAULT_UTF8 Say Y if you use UTF-8 encoding for file names, N otherwise. See <file:Documentation/filesystems/vfat.rst> for more information. + +config FAT_KUNIT_TEST + tristate "Unit Tests for FAT filesystems" if !KUNIT_ALL_TESTS + depends on KUNIT && FAT_FS + default KUNIT_ALL_TESTS + help + This builds the FAT KUnit tests + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit + + If unsure, say N
_
Signature · 1 line
OGAWA Hirofumi <[email protected]>