Age | Commit message (Collapse) | Author |
|
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>
|
|
Previously, the unit test sysfs mock files and headers were not
added to the distribution packag. Not packaging the header leads
to compilation of the unit tests failing. Not packaging the stub
files caueses the unit tests themselves to fail.
This patch explicitly adds the header and sysfs mock files to the
distribution target, allowing the unit tests to be used outside
the git tree.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Several tools are simply not checking return code of functions marked
with 'warn_unused_result'.
Provide wrappers for the read/write functions to avoid patching old
code and providing proper error handling.
Fix the remaining ones (calls to fgets() and system()).
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
|
|
Historically, the mtd-utils and ubi-utils were seperate packages. The
ubi-utils were at some point merged into the mtd-utils. They first
appeared in the release tar-ball in version 1.1.0 in their own
sub-hirarchy with their own buildsystem, readme, documentation, etc.
A lot of the duplicated stuff got centralized/removed over time.
This patch further cleans up the directory hirarchy duplication by
moving common libraries from the ubi-utils/ into the central lib/
and include/ directories in the top directory of the mtd-utils package.
This includes:
- libuib.a & libubigen.a used by the ubi utilities
- libscan.a currently only used by ubiformat
- libiniparser.a used by ubinize
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Add unittests for most functions provided by
libubi
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
|
|
unit tests for most functions provided by
libmtd.
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
|
|
add mocked sysfs used by libmtd and libubi
unittests
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
|
|
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
|
|
Basically a user space port of the mtd sub page test kernel module.
In addition to the module parameters, the utility supports using
only a sub-range of the flash erase blocks with a configurable
stride and can restore the block contents after the test.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd page test kernel module.
In addition to the module parameters, the utility supports using
only a sub-range of the flash erase blocks with a configurable stride.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd read test kernel module.
In addition to the module parameters, the utility can scan only
a sub-range of the flash erase block with a configurable stride.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd speed test kernel module.
In addition to the module parameters, the utility can resture
the block contents after test and allows setting the maxium writes
for the test.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd speed test kernel module.
In addition to the block offset and count module parameters, the
utility supports a block stride and can restore the block contents
after test. Furthermore, a flag can be used to disable destructive
tests (i.e. only perform read speed tests).
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd stress test kernel module.
In addition to the block offset and count module parameters, the
utility supports a block stride and can restore the block contents
after test.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Basically a user space port of the mtd torture test kernel module. In
addition to the block offset and count module parameters, the utility
supports a block stride and can restore the block contents after test.
In contrast to the kernel module, the torture test is implemented by
the libmtd mtd_toruture function and thus doesn't allow for similarly
fine grained options on diagnostics.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
This patch adds a libmissing library to mtd-utils, containing
implementations of functionality found in glibc but typically
missing from embedded C libraries such as uclibc ot musl.
For now, the library only contains stub implementations of
the backtrace*() family of functions.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
When a program does sophisticated enough command line processing
(i.e. getopt), make sure it responds to -V and --version.
When a program prints a version string, make sure it uses the
common_print_version macro to print out its name, that it is part
of mtd-utils and the mtd-utils version from the build system in a
fashion similar to common program packages like the GNU coreutils.
When a program responds to -V/--version or -h/--help, make sure it
reports success exit status.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
Add automake files for the test binaries. If configured to do so,
install the test binaries to libexec/mtd-utils and use autoconf to
fix the paths in the test scripts.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|