Age | Commit message (Collapse) | Author |
|
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>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
- 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>
|
|
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>
|
|
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>
|
|
This commit fixes some uses of strncpy that could leave the destination
buffer unterminated.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
'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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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>
|
|
Sometimes __xstat is called instead that makes tests fragile.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This fixes tests on s390x
Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If the number of erase blocks to use is not specified, ebcnt originally
set to -1 leads the program to exit with:
"Cannot run with less than two blocks."
If the number of erase blocks to use is not specified and thus ebcnt is
equal to -1, the expected behaviour is to perform the test on all the
erase blocks of the mtd partition.
This fixes the change introduced in
4458ad6481f60d9884925d5bc62a7954880d181b.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When porting some of the mtd-tests to user space, some code was
simplified. Among others, a while loop that iterates of page contents
was replaced with a for loop, but the old increment was left in place,
so every second byte was skipped.
This patch removes the erroneous second increment.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
mtd_debug: Remove a duplicate if case. MTD_CAP_NANDFLASH has only one
flag set (MTD_WRITEABLE). Directly below, we had a check for
MTD_WRITEABLE in the else branch which can't possible ever have
triggered. Checking for MTD_WRITEABLE in addition to the CAP constants
was probably not intended anyway, given the check for the individual
flags if all else fails.
integck: We already established that "r" is less than the number of
elements in the list, so the loop condition doesn't need to check
if w is NULL in addition. At least this way, the compiler "gets"
that w cannot be NULL below and doesn't issue warnings.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When passing a long argument, actually use labs().
The other case of passing a float to "int abs(int)" and
casting the result to an int doesn't really make sense.
Pull the cast inside the abs().
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Now that C++17 introduced a special fallthrough keyword for
explicitly tagging switch cases that are supposed to fall
through, newer gcc versions also implement a feature request
from 2002 to warn about maybe unwanted fall-throughs in switch
cases in other languages (like C).
For C code, we can either add a gcc specific attribute at the
end of the switch case, or use a special comment that gcc checks
for, indicating that the fall-through behaviour is indeed
intended.
This patch adds a "/* fall-through */" comment at the end of
various case blocks to silence gcc warnings and in some cases
a break, where fall-through was probably not intended.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
A common pattern in command line processing is having a usage()
function that prints out how to use the command line options and
then terminates.
The function is typically used inside a switch block for command
line options like `-h' or unknown options. In a lot of places, the
break keyword is omitted, because the function exits anyway. However,
this triggers gcc warnings about implicit fall-through.
Rather than adding a phony "/* fall-through */" this patch flags the
usage() style function with a gcc attribute, indicating that they do
not return and removes further superfluous break statements.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The file comm.c was erroneously compiled into makefiles. This patch
fixes that in the Automake file.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Forbid the use of less than 2 eraseblocks in nandpagetest. It is obvious
that the test cannot run on zero block, but it cannot run on only one
block neither. The reason is: get_first_and_last_block() will return the
same id for both the first and the last blocks. In erasecrosstest(),
the logic is:
- erase/write/read/verify first block
- erase/write again first block
- erase *last* block
- read/verify first block
When using only one block, 'first' refers to the same block as 'last',
leading to erasing the block before reading it. Hence, the test would
fail with no actual reason.
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Bit flip detection for written and erased pages tend to have different
implementations. Where written pages are detected and corrected using
ECC, erased pages are typically detected by ensuring that the number of
zeros is less than a specified threshold.
As such, it's necessary to have the 'nandbiterrs' test support the
testing of written and erased pages. Bit flips in erased pages are
emulated by rewriting the page in raw mode, to prevent the use of ECC.
Signed-off-by: Harpreet Eli Sangha <harpreet@nestlabs.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch eliminates warnings generated by the -Wmissing-prototypes
option. With this flag set, we are now forced to have prototypes for
all global, exported functions, that have to be made visible to the
definitions and we are forced to mark all local functions as static.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
AC_CHECK_HEADERS already makes sure our config header contains a
HAVE_$FOO_H macro if a header was found. There is no need to
awkwardly set our own Automake conditionals and check for it all
over the place in the Automake files.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
After a page read, the old failure statistics are compared against the
new failure statistics before the new values are actually read.
Signed-off-by: Harpreet "Eli" Sangha <harpreet@nestlabs.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The tools in question will quit with an exit code 0 if the command
line option was not recognized. By returning an error code a calling
script has the possibility to distinguish between a real success and
an invalid invocation.
We need to return -1 instead of EXIT_FAILURE to be consistent with the
other exit code places.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
rand() is not thread safe, but glibc seems to use a shared state which is
protected by a mutex. io_paral spawns a few threads and they call rand()
more or less in parallel, which causes heavy lock contention. That
makes the test extremely slow on some setups.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
io_read and io_update of mtd-utils support NAND with 4k page size only.
Increase that to support up to 65k page size.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
io_read and io_update of mtd-utils use variable-length arrays for test data.
Since this could result in allocating many megabytes using alloca(), switch
to malloc().
Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
UDEV_SETTLE_HACK addresses a problem which does no longer exist on Linux.
These days we have devtmpfs. New devices will automatically created on
the kernel side and user space has no longer to wait for udev.
As udev has a hard dependency on devtmpfs we can depend on it too.
People which don't use udev nor plain devtmpfs are anyways on their own.
Android, I'm looking at you...
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
On 32bit systems (e.g. ARM) the size of off_t can be 4 byte and the size of loff_t 8 byte.
This causes compiler warnings like the following:
flash_erase.c: In function 'show_progress':
flash_erase.c:56:22: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'off_t {aka long int}' [-Wformat=]
bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
and an output like this:
~# flash_erase /dev/mtd2 0 1
Erasing 64 Kibyte @ 6400000000 -- 0 % complete
~#
Since the size of off_t and loff_t can differ from each other, the
printf format specifier should be determined separately for both.
Further the format specifiers should be based directly on the size of the
particular data type.
Signed-off-by: Torsten Fleischer <torfl6749@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|