aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
11 daystests: ubifs_tools: Add READMEZhihao Cheng
Add document for fsck.ubifs and mkfs.ubifs testcases, explain all testcases and how to run them. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: Add run_all scriptZhihao Cheng
Add run_all script to run all UBIFS fsck & mkfs testcases. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: mkfs_tests: Add fs content check testZhihao Cheng
Initialize UBIFS image from a given directory, then check whether the fs content in mounted UBIFS is consistent with the original directory. Both UBI volume and file are chosen as storage mediums to test. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add bad images fixing testZhihao Cheng
For kinds of inconsistent UBIFS images(which can simulate corruptions caused by some potentional UBIFS bug), check the result of fsck. This testcase mainly checks whether the behavior is in expected after repairing specific inconsistent UBIFS image. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add corrupted imagesZhihao Cheng
This is a preparation for adding bad images fsck testcase. There is no debugfs tools (for example: debugfs[ext4], xfs_db) for UBIFS, so there is no way to inject precise corruption into UBIFS image, we have to prepare inconsistent UBIFS images in advance like e2fsprogs[1] does. (Goto [2] to see how to generate inconsistent UBIFS images). Original UBIFS image content: / ├── corrupt_file (xattr - user.corrupt:123, 2K data) ├── dir │   ├── block_dev │   ├── char_dev │   ├── dir │   └── file (content: '123') ├── hardl_corrupt_file => corrupt_file └── softl_corrupt_file -> corrupt_file Here's a descriptons of the various testing images: ========================================================================= image | Description | expectancy ------------------------------------------------------------------------- good | good image contains | fsck success, fs content is | kinds of files. | not changed. ------------------------------------------------------------------------- sb_fanout | invalid fanout in | fsck failed. | superblock. | ------------------------------------------------------------------------- sb_fmt_version | invalid fmt_version | fsck failed. | in superblock. | ------------------------------------------------------------------------- sb_leb_size | invalid leb_size in | fsck failed. | superblock. | ------------------------------------------------------------------------- sb_log_lebs | invalid log lebs in | fsck failed. | superblock. | ------------------------------------------------------------------------- sb_min_io_size | invalid min_io_size | fsck failed. | in superblock. | ------------------------------------------------------------------------- master_highest_inum | invalid highest_inum| fsck success, fs content is | in master nodes. | not changed. ------------------------------------------------------------------------- master_lpt | bad lpt pos in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- master_tnc | bad tnc pos in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- master_total_dead | bad total_dead in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- master_total_dirty | bad total_dirty in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- master_total_free | bad total_free in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- journal_log | corrupted log area. | fsck success, fs content is | | not changed. ------------------------------------------------------------------------- journal_bud | corrupted bud area. | fsck success, file data is | | lost. ------------------------------------------------------------------------- orphan_node | bad orphan node. | fsck success, file is | | deleted as expected. ------------------------------------------------------------------------- lpt_dirty | bad dirty in pnode. | fsck success, fs content is | | not changed. ------------------------------------------------------------------------- lpt_flags | bad flags in pnode | fsck success, fs content is | (eg. index). | not changed. ------------------------------------------------------------------------- lpt_free | bad free in pnode. | fsck success, fs content is | | not changed. ------------------------------------------------------------------------- lpt_pos | bad pos in nnode. | fsck success, fs content is | | not changed. ------------------------------------------------------------------------- ltab_dirty | bad dirty in lprops | fsck success, fs content is | table. | not changed. ------------------------------------------------------------------------- ltab_free | bad free in lprops | fsck success, fs content is | table. | not changed. ------------------------------------------------------------------------- index_size | bad index size in | fsck success, fs content is | master nodes. | not changed. ------------------------------------------------------------------------- tnc_lv0_key | bad key in lv0 | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- tnc_lv0_len | bad len in lv0 | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- tnc_lv0_pos | bad pos in lv0 | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- tnc_noleaf_key | bad key in non-leaf | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- tnc_noleaf_len | bad len in non-leaf | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- tnc_noleaf_pos | bad pos in non-leaf | fsck success, fs content is | znode. | not changed. ------------------------------------------------------------------------- corrupted_data_leb | corrupted data leb. | fsck success, partial data of | | file is lost. ------------------------------------------------------------------------- corrupted_idx_leb | corrupted index leb.| fsck success, fs content is | | not changed. ------------------------------------------------------------------------- inode_data | bad data node. | fsck success, file content | | is changed, other files are | | not changed. ------------------------------------------------------------------------- inode_mode | bad inode mode for | fsck success, file is | file. | dropped, other files are not | | changed. ------------------------------------------------------------------------- inode_nlink | wrong nlink for | fsck success, nlink is | file. | corrected, fs content is not | | changed. ------------------------------------------------------------------------- inode_size | wrong inode size | fsck success, inode size is | for file. | corrected, fs content is not | | changed. ------------------------------------------------------------------------- inode_xcnt | wrong inode | fsck success, xattr_cnt is | xattr_cnt for file. | corrected, fs content is not | | changed. ------------------------------------------------------------------------- soft_link_inode_mode| bad inode mode for | fsck success, soft link | solf link file. | file is dropped, other files | | are not changed. ------------------------------------------------------------------------- soft_link_data_len | bad inode data_len | fsck success, soft link | for solt link file. | file is dropped, other files | | are not changed. ------------------------------------------------------------------------- dentry_key | bad dentry key for | fsck success, dentry is | file. | removed, other files are | | not changed. ------------------------------------------------------------------------- dentry_nlen | inconsistent nlen | fsck success, dentry is | and name in dentry | removed, other files are | for file. | not changed. ------------------------------------------------------------------------- dentry_type | inconsistent type | fsck success, dentry is | between dentry and | removed, other files are | inode for file. | not changed. ------------------------------------------------------------------------- xinode_flags | lost UBIFS_XATTR_FL | fsck success, xattr is | in xattr inode | removed, other files are | flags for file. | not changed. ------------------------------------------------------------------------- xinode_key | bad xattr inode key | fsck success, xattr is | for file. | removed, other files are | | not changed. ------------------------------------------------------------------------- xinode_mode | bad xattr inode | fsck success, xattr is | mode for file. | removed, other files are | | not changed. ------------------------------------------------------------------------- xentry_key | bad xattr entry key | fsck success, xattr is | for file. | removed, other files are | | not changed. ------------------------------------------------------------------------- xentry_nlen | inconsistent nlen | fsck success, xattr is | and name in xattr | removed, other files are | entry for file. | not changed. ------------------------------------------------------------------------- xentry_type | inconsistent type | fsck success, xattr is | between xattr entry | removed, other files are | and xattr inode for | not changed. | file. | ------------------------------------------------------------------------- xent_host | the xattr's host | fsck success, file, hard | is a xattr too, the | link and soft link are | flag of corrupt_file| dropped, other files are | inode is modified. | not changed. ------------------------------------------------------------------------- dir_many_dentry | dir has too many | fsck success, hard link is | dentries, the dentry| dropped, other files are not | of hard link is | changed. | modified. | ------------------------------------------------------------------------- dir_lost | bad dentry for dir. | fsck success, the 'file' is | | recovered under lost+found, | | left files under dir are | | removed, other files are not | | changed. ------------------------------------------------------------------------- dir_lost_duplicated | bad inode for dir, | fsck success, the 'file' is | there is a file | recovered with INO_<inum>_1 | under lost+found, | under lost+found, left files | which named with the| under dir are removed, other | inum of the 'file'. | files are not changed. ------------------------------------------------------------------------- dir_lost_not_recover| bad inode for dir, | fsck success, all files | lost+found is a | under dir are removed, | regular file and | other files are not changed. | exists under root | | dir. | ------------------------------------------------------------------------- root_dir | bad '/'. | fsck success, create new | | root dir('/'). All regular | | files are reocovered under | | lost+found, other files are | | removed. ------------------------------------------------------------------------- empty_tnc | all files have bad | fsck success, fs content | inode. | becomes empty. ========================================================================= [1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/tree/tests/README [2] https://bugzilla.kernel.org/show_bug.cgi?id=218924 Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add random_corrupt+fsck testZhihao Cheng
Inject random corruption on UBIFS image by writting random data on kinds of mtd devices (eg. nand, nor), check the consistency of UBIFS after fsck. This testcase simulates random bad UBIFS image caused by hardware exceptions(eg. ecc uncorrectable, unwritten), and makes sure that fsck.ubifs could make UBIFS be consistent after repairing UBIFS image. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add cycle_powercut+fsck testZhihao Cheng
Inject powercut while doing fsstress on mounted UBIFS, check the consistency of UBIFS after fsck. This testscase mainly makes sure that fsck.ubifs can make UBIFS image be consistent in common stress cases and powercut cases. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add corrupt+fsck+fault_inject testZhihao Cheng
Inject memory/io fault while doing fsck for corrupted UBIFS images. This testcase mainly checks whether fsck.ubifs has problems (eg. UAF, null-ptr-def, etc.) in random error paths. Besides, it provides a similar way to simulate powercut during fsck, and checks whether the fsck.ubifs can fix an UBIFS image after many rounds interrupted by kinds of errors. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add powercut+fsck+mount testZhihao Cheng
Inject powercut while doing fsstress on mounted UBIFS for kinds of flashes (eg. nand, nor). This testcase mainly makes sure that fsck.ubifs can make UBIFS image be consistent on different flashes (eg. nand, nor). Because the min_io_size of nor flash is 1, the UBIFS image on nor flash will be different from nand flash after doing powercut, so we need make sure fsck.ubifs can handle these two types of flash. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add cycle mount+fsck testZhihao Cheng
Do fsstress and fsck, check whether there are any files(and their data) are lost after fsck. This testcase mainly checks whether fsck.ubifs could corrupt the filesystem content in common case. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: ubifs_tools: fsck_tests: Add authentication refusing testZhihao Cheng
Authenticated UBIFS image is not supported in fsck, add testcase to check that. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daystests: Add common libs for testing fsck.ubifs/mkfs.ubifsZhihao Cheng
This is a preparation for adding testcases for fsck.ubifs and mkfs.ubifs. Add some common functions, for example: powercut, load_mtdram, mount_ubifs, encryption operations, etc. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Benchmark continuous readsMiquel Raynal
Currently the read throuput test tries: - 1 page - 2 pages - 1 block (64 or more pages, usually) But it might be interesting to see how the speed gradually increases, eg. testing all number of pages from 1 to maybe 16, and then arbitrarilly 32 and 64. Let's add a -C parameter to enable this additional test. The 2-page read/write tests are also moved under this new option. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop read_eraseblock_by_page()Miquel Raynal
The read_eraseblock_by_2pages() has been generalized so it became read_eraseblock_by_npages(), but there is no limitation (besides 0) regarding the number of pages. Hence, drop the _by_page() helper and replace it with the _by_npages(), using 'npages = 1'. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Generalize read_eraseblock_by_2pages()Miquel Raynal
Right now there are only 2 pages that may be read continuously, but why not trying more? At least when the continuous feature is out, this type of benchmarking will be interesting. In order to facilitate later additions, lets make this helper more generic and accept a global 'npages' variable as parameter (because this function is called in a macro, it is simpler like that). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Clarify the number of pages in each set while measuringMiquel Raynal
So far speed calculations have only be done 1 page at a time or 2 pages at a time in a block; so basically all the block was always read because all blocks are multiple of 2. But in the future, if we want to extend the number of pages in a single read, the final number of pages actually read might be less than an erase block size, hence failing the throuput calculations. Make the number of pages in a set explicit. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop an apparently useless blockMiquel Raynal
I know no device without a multiple of 2 number of pages in each block. Even though it might be the case, it is clearly not a big deal and we don't really care about reading the last page, we are doing a speed benchmark; so as long as the throughput calculation knows how much data has been read it's fine. Eitherway, I don't think we ever have fallen in this block because we would read the content of two pages (so one past the block) and put it in a page-wide buffer, which would probably lead to an out-of-bound abort. Just drop the block. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Add support for testing continuous readsMiquel Raynal
In order to trigger a continuous read, the user needs to request at least two pages at the same time. So far the tool would only read single pages, so let's extend its capabilities to test continuous read output when the -c option is passed. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Store the chunks size in an intermediate variableMiquel Raynal
'pagesize' is used for two purposes: - accessing the size of a page - getting the size of the test buffer, which happen to be the size of a page for now. Use an intermediate variable when getting the size of the test buffer, as we will later increase its size. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25fs-tests: integck: Refactor: split out common remount logicCsókás, Bence
remount_tested_fs() and recover_tested_fs() both have almost the same code for remounting the target FS RO then RW. Split this sequence into a new function called remount_ro_rw(). Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Link: https://lore.kernel.org/linux-mtd/5530437c-b564-461f-26af-85bde1a00cb3@huawei.com/T/#mad1d043095b3f64a1f1eddd2d87b1545e329e141 Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25fs-tests: integck: Refactor: split out common remount logicCsókás, Bence
remount_tested_fs() and recover_tested_fs() both have almost the same code for umount'ing the target FS and mount'ing it back. Split this sequence into a new function called umount_and_remount(). Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Remove unused symbolsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30mtd-utils: Add new syntax to get devices by nameBrandon Maier
This introduces a new feature to the MTD command line utilities that allows MTD devices to be referenced by name instead of device node. For example this looks like: > # Display info for the MTD device with name "data" > mtdinfo mtd:data > # Copy file to MTD device with name "data" > flashcp /my/file mtd:data This follows the syntax supported by the kernel which allows MTD device's to be mounted by name[1]. Add the function mtd_find_dev_node() that accepts an MTD "identifier" and returns the MTD's device node. The function accepts a string starting with "mtd:" which it treats as the MTD's name. It then attempts to search for the MTD, and if found maps it back to the /dev/mtdX device node. If the string does not start with "mtd:", then assume it's the old style and refers directly to a MTD device node. The function is then hooked into existing tools like flashcp, mtdinfo, flash_unlock, etc. To load in the new MTD parsing code in a consistent way across programs. [1] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_mtdblock Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Measure read while write latencyMiquel Raynal
The Read While Write (RWW) feature allows to perform reads from the flash array into cache while a program (from cache) or an erase operation happens, provided that the two areas are located on different banks. The main benefit is the possible reduced latency when requesting to read a page while a much longer operation is ongoing, like a write or an erase. We can try to compare the positive impact of such a feature by enhancing the flash_speed test tool with the following test: - Measure the time taken by an eraseblock write in parallel with an eraseblock read. - Measure when the read operation ends. - Compare the two to get the latency saved with the RWW feature. To be sure the mtd_write actually starts (and acquires the necessary locks) before the mtd_read does, we use SCHED_FIFO at rather high (arbitrary) priorities, respectively 42 and 41. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Rework the time counting helpersMiquel Raynal
In order to be able to have interleaved measures, let's not use the start and finish global variables from the time helpers directly, provide parameters for these variables so that we can provide either the global entries, or more specific ones when relevant. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-08-08tests: Remove unused linux/fs.h header from includesKhem Raj
This header is not needed, moreover it includes linux/mount.h which is now in conflict[1] with glibc provided sys/mount.h from glibc 2.36 onwards [1] https://sourceware.org/glibc/wiki/Release/2.36 Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-12-06mtd-tests: use pages during readtest and stressRalph Siemsen
Same fix as a2c6bbc ("mtd-tests: Read and write pages during speed tests") but applied to flash_readtest and flash_stress. Resolves failure of flash_readtest when subpages are present. The test reads a (sub)page followed by the entire OOB. Upon reaching the 2nd subpage, the OOB read fails because it is beyond the end of OOB. Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-10-13mtd-tests: Read and write pages during speed testsMiquel Raynal
The speed test does reads and writes of different sizes: - eraseblock - page - two pages At least this is the theory because, as opposed to the legacy kernel module doing the same measurement, the userspace tool uses the subpage size (hence accessing the same page 4, 8 or 16 times depending on the subpage setting). Of course if the controller does not support subpages, this issue is not visible. Use mtd.min_io_size instead for non-NOR devices in order to get the right bandwidth (at least one that fits the logs). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-07-25Add missing filljffs2.sh to EXTRA_DISTDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Fix test binary installationDavid Oberhollenzer
- Remove "install tests" configure option, we already have an option whether to build tests or not. Don't try to work around autotools semantics that people building the package expect. - Fix the installation path by propperly defining it and using the correct name for the libexec path. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Cleanup: Automake: remove single use variablesDavid Oberhollenzer
Throughout the Automake files, there is a consistent pattern somewhat like this: FOO_BINS = .... sbin_PROGRAMS += $(FOO_BINS) This commit all such patterns whenever the variable is not used anywhere else and appends to the target directly. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Remove headers from EXTRA_DISTDavid Oberhollenzer
This commit removes the C header files from the EXTRA_DIST variables and instead assigns them to the SOURCE variable of the respective components they belong to. This takes care of having them distributed in the release tar ball and helps with dependency tracking a little. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix potentially unterminated stringsDavid Oberhollenzer
This commit fixes some uses of strncpy that could leave the destination buffer unterminated. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix potential negative arguments passed to close(2)David Oberhollenzer
Many tools open a file descriptor, close it a the end and have some form of error path in between that jumps to the end. In some cases, if opening the file fails the error path is taken and the utility ends up closing one or more invalid file descriptors. It's technically not a real issue but something that pretty much any static analysis tool barks at. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix printf format specifiers with the wrong typeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10fs-tests: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10jittertest: fix error check for open system callDavid Oberhollenzer
The value 0 is a valid file descriptor. The existing error handling would not only treat that as an error, but subsequently leak the file descriptor in the error handling path. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-16ubi-tests: fm_param: Replace 'fm_auto' with 'fm_autoconvert'Zhihao Cheng
The value of fm_param should be 'fm_autoconvert' rather than 'fm_auto' when fastmap is supported by kernel. Currently, following verbose will appear in dmesg when fm_param is set to 'fm_auto': ubi: unknown parameter 'fm_auto' ignored This patch replace 'fm_auto' with 'fm_autoconvert' for fm_param, so ubi kernel module can receive correct parameters. ---------------------------------------- Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-16ubi-tests: mkvol test: Checks return value 'ENOSPC' for 'ubi_mkvol'Zhihao Cheng
UBI tests try to create too many volumes in mkvol_bad and mkvol_basic. Currently mtd-utils allows return value 'ENFILE' from 'ubi_mkvol', that works fine in most situations. But what if the number of PEBs equals to the maximum count of volumes? For example, mkvol_basic test will fail in a 64MiB flash with 512KiB PEB size. Following is the output of mkvol_basic test: ====================================================================== ====================================================================== ====================================================================== Test on mtdram, fastmap enabled, VID header offset factor 1 ====================================================================== ====================================================================== ====================================================================== mtdram: 64MiB, PEB size 512KiB, fastmap enabled Running mkvol_basic /dev/ubi0 [mkvol_basic] mkvol_multiple():182: function ubi_mkvol() failed with error 28 (No space left on device) [mkvol_basic] mkvol_multiple():183: vol_id 122 Error: mkvol_basic failed FAILURE The reason is that there is no available PEB to support a new volume. We can see following verbose in dmesg: ubi0: attached mtd0 (name "mtdram test device", size 64 MiB) ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128 ubi0: available PEBs: 122, total reserved PEBs: 6, PEBs reserved for bad PEB handling: 0 The maximum count of volumes is 128, so we can create 128 volumes theoretically. But there are 122 available PEBs becauese of existence of reserved PEBs. In addition, a volume occupies at least one PEB. Actually, we can only create 122 volumes, Therefore, 'ubi_mkvol' returns 'ENOSPC' when mkvol_basic tries to create 123rd volume. And we can see corresponding error message in dmesg: ubi0 error: ubi_create_volume [ubi]: not enough PEBs, only 0 available ubi0 error: ubi_create_volume [ubi]: cannot create volume 122, error -28 So, 'ENOSPC' can happen before 'ENFILE' in flash with a small amount of PEBs. This patch checks return value 'ENOSPC' for 'ubi_mkvol' when mkvol test is trying to create too many volumes. ---------------------------------------- Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-16ubi-tests: io_read: Filter invalid offset value before 'lseek' in io_read testZhihao Cheng
There are many different offset values passed in 'lseek' during io_read testing of ubi test. The offset value maybe a negative number or a big number that exceeds the volume data size, which can lead to ubi tests failure by passing invalid offset value to 'lseek'. For example: Example 1: The data size of volume is 39525 bytes, offset = (sz) - MAX_NAND_PAGE_SIZE - 1, where MAX_NAND_PAGE_SIZE is 65536. Here, offset is a negative value passed to 'lseek', which leads to fail in io_read. ====================================================================== ====================================================================== ====================================================================== Test on mtdram, fastmap enabled, VID header offset factor 1 ====================================================================== ====================================================================== ====================================================================== mtdram: 16MiB, PEB size 16KiB, fastmap enabled Running mkvol_basic /dev/ubi0 Running mkvol_bad /dev/ubi0 Running mkvol_paral /dev/ubi0 Running rsvol /dev/ubi0 Running io_basic /dev/ubi0 Running io_read /dev/ubi0 [io_basic] test_read3():189: function seek() failed with error 22 (Invalid argument) [io_basic] test_read3():190: len = 1 [io_basic] test_read2():237: offset = -26012 [io_basic] test_read1():303: length = 1 [io_basic] test_read():362: alignment = 7905 Error: io_read failed FAILURE Example 2: The data size of volume is 79035 bytes, offset = 2 * MAX_NAND_PAGE_SIZE, where MAX_NAND_PAGE_SIZE is 65536. Here, offset is a value exceeds volume size, which leads to fail in io_read. ====================================================================== ====================================================================== ====================================================================== Test on mtdram, fastmap enabled, VID header offset factor 1 ====================================================================== ====================================================================== ====================================================================== mtdram: 16MiB, PEB size 16KiB, fastmap enabled Running mkvol_basic /dev/ubi0 Running mkvol_bad /dev/ubi0 Running mkvol_paral /dev/ubi0 Running rsvol /dev/ubi0 Running io_basic /dev/ubi0 Running io_read /dev/ubi0 [io_basic] test_read3():185: function seek() failed with error 22 (Invalid argument) [io_basic] test_read3():186: len = 1 [io_basic] test_read2():233: offset = 131072 [io_basic] test_read1():299: length = 1 [io_basic] test_read():358: alignment = 3 Error: io_read failed FAILURE This patch checks offset value before executing 'lseek', invalid offset values are filtered. ---------------------------------------- Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-16ubi-tests: ubi_mkvol_request: Fully initialize 'struct ubi_mkvol_request req'Zhihao Cheng
'struct ubi_mkvol_request req' is one parameter of the function 'ubi_mkvol' , this parameter will be passed to kernel and then be checked. It acts as a local variable in many ubi tests, such as io_basic, io_read, mkvol_bad, mkvol_basic, etc. After commit c355aa465fce ("ubi: expose the volume CRC check skip flag") in linux-stable, 'struct ubi_mkvol_request' supports a new configuration named 'flags', and req.flags will be checked in kernel function 'verify_mkvol_req'. Currently, there is no initialization for req.flags before 'ubi_mkvol' invoked. So, req.flags can be an arbitrary number passed to kernel. When we run ubi tests in qemu (x86_64, kernel image: 5.2.0-rc4), the following errors may occur: ====================================================================== ====================================================================== ====================================================================== Test on mtdram, fastmap enabled, VID header offset factor 1 ====================================================================== ====================================================================== ====================================================================== mtdram: 16MiB, PEB size 16KiB, fastmap enabled Running mkvol_basic /dev/ubi0 Running mkvol_bad /dev/ubi0 [mkvol_bad] test_mkvol():105: ubi_mkvol failed with error 22 (Invalid argument), expected 28 (No space left on device) [mkvol_bad] test_mkvol():105: bytes = 16060929 Error: mkvol_bad failed FAILURE This patch fully initializes every 'struct ubi_mkvol_request req' passed to 'ubi_mkvol', which can fix the bug that the ubi test failed caused by that req.flags was not initialized. And it is still compatible with old kernel before kernel commit c355aa465fce ("ubi: expose the volume CRC check skip flag"). ---------------------------------------- Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-04-29mtd-tests: nandbiterrs: Fix issue that just insert error at bit 7Xiaolei Li
The function insert_biterror should be designed to insert error at the first '1' bit starting at offset byte. But now, only bit 7 of each byte is checked, because checking mask is always 0x80. So, do right shift for checking mask after each checking to check the whole 8 bits of each bytes. Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-04-25unittests: Define the use of _GNU_SOURCEOlliver Schinagl
The unittest suite actually makes use of some _GNU extensions during the build (loff_t for example). So lets enable this in the makefile. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-04-25unittests/libmtd_test: Include fcntl headerOlliver Schinagl
The test library for the mtd unit tests include various type's and macro's that officially live in fcntl. Each file and header should always properly include what they use, so lets add the fcntl headers. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-04-25unittests/test_lib: Include proper header for _IOC_SIZEOlliver Schinagl
The macro _IOC_SIZE is not part of sys/ioctl.h but lives in asm/ioctl.h so we should include the proper header. If we do not, some systems complain during linking that they cannot find the symbol _IOC_SIZE() which was not expanded by the pre-compiler. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-10-02mtd-utils: Instead of doing preprocessor magic, just output off_t as long longThorsten Glaser
Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write): In file included from ../git/lib/libmtd.c:40:0: ../git/lib/libmtd.c: In function 'mtd_read': ../git/include/common.h:110:18: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'off_t {aka long long int}' [-Wformat=] ../git/include/common.h:120:2: note: in expansion of macro 'errmsg' errmsg(fmt, ##__VA_ARGS__); \ ^~~~~~ ../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg' return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t, ^~~~~~~~~~ /usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here #define PRId32 "d" Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-09-08ubi-tests: io_paral: Fix error handling of update_volume()Martin Lund
The io_paral test returns success even in case it throws e.g. the following error message: [io_paral] update_volume():125: written and read data are different This patch fixes so that the io_paral application returns a non-zero error code when an error is detected. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-16Fix unit-test header and file paths for out of tree buildsDavid Oberhollenzer
If we build mtd-utils outside the source path, we cannot use relative paths to refere to headers in the source tree. We have to specify absoulte paths using the top_srcdir variable. This was done right for the utility binaries, but overlooked for the unit test porgrams. This patch fixes the header paths and SYSROOT variable for the unit tests, so they build and run propperly outside the source tree. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-16Fix unit test mockup for oobavail sysfs fileDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-03-05mtd: tests: check erase block count in page testStefan Agner
When there is only a single erase block, the cross erase test does not report sensible errors. Warn in case there is only a single erase block instead of executing the test. Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>