aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
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>
2018-02-14mtd: unittests: Stop testing stat() callsBalint Reczey
Sometimes __xstat is called instead that makes tests fragile. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-02-14mtd: unittests: Decode arg size from ioctl requestBalint Reczey
Signed-off-by: Balint Reczey <balint.reczey@canonical.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-02-14mtd: unittests: Use proper unsigned long type for ioctl requestsBalint Reczey
This fixes tests on s390x Signed-off-by: Balint Reczey <balint.reczey@canonical.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-12-05Run unit test programs through "make check"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-22mtd: tests: Fix check on ebcnt in nandpagetestPaul HENRYS
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>
2017-11-03nandbiterrs: Fix copy & paste failDavid Oberhollenzer
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>
2017-11-03Enable further warning flags, address new warningsDavid Oberhollenzer
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>
2017-11-03jittertest: Use the appropriate versions of abs()David Oberhollenzer
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>
2017-11-02Mark or fix switch cases that fall throughDavid Oberhollenzer
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>
2017-11-02Add no-return attribute to usage() style functionsDavid Oberhollenzer
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>
2017-10-05tests: checkfs: Remove unused source file from makefilesDavid Oberhollenzer
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>
2017-10-05ubi-tests: io_update: fix missleading indentationDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-08-24mtd-utils: tests: Avoid using less than two blocks in nandpagetestMiquel Raynal
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>
2017-07-03mtd-utils: tests: Add Erased Pages Bit Flip TestHarpreet Eli Sangha
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>
2017-06-28Add const modifier to read only strings and string constantsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Silence warnings about unused argumentsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Remove unused variables and functionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Eliminate warnings about missing prototypesDavid Oberhollenzer
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>
2017-06-28Use autoconf header detection correctly for libmissingDavid Oberhollenzer
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>
2017-06-28mtd-utils: tests: Fix nandbiterrs Failure CheckHarpreet Eli Sangha
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>
2017-06-14ubi-utils: Return error code if command line option is unknownDaniel Wagner
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>
2017-02-21ubi: tests: Speedup io_paral by using rand_r()Richard Weinberger
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>
2017-02-21ubi: tests: Support up to 65k NAND page sizeRichard Weinberger
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>
2017-02-21ubi: tests: Replace variable-length array with malloc()David Gstir
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>
2017-02-20Remove README.udev from ubi-tests extra distDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20Remove UDEV_SETTLE_HACKRichard Weinberger
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>
2017-02-20mtd-utils: Fix format specifier definitions for off_t and loff_t.Torsten Fleischer
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>
2016-12-13Fix packaging of unit test filesDavid Oberhollenzer
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>
2016-12-06common: Fix 'unchecked return code' warningsBoris Brezillon
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>
2016-11-17Move ubi-utils libraries to common library locationDavid Oberhollenzer
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>
2016-11-17Add Makefile for unittestsDaniel Walter
Signed-off-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Add unittests for libubiDaniel Walter
Add unittests for most functions provided by libubi Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add unittest for libmtdDaniel Walter
unit tests for most functions provided by libmtd. Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add sysfs tree for unittestsDaniel Walter
add mocked sysfs used by libmtd and libubi unittests Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add unit test helpersDaniel Walter
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17mtd-utils: Add nand sub-page test utilityDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add nand page test utilityDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add flash read test utilityDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add nand flash bit errors testDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add flash speed test utilityDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add flash stress test utilityDavid Oberhollenzer
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>
2016-11-17mtd-utils: Add flash torture test utilityDavid Oberhollenzer
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>
2016-11-17Add libmissingDavid Oberhollenzer
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>
2016-11-17Unify version string printingDavid Oberhollenzer
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>
2016-11-17Integrate tests into autotools build systemDavid Oberhollenzer
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>
2016-11-17Change build system to autotoolsRichard Weinberger
This patch is largely based on Richards original RFC. The major differences to the RFC patch are: - Add missing sumtools & mtdpart targets - Fix name of mkfs.jffs2 target - Add missing subdir-objects option for non-recursive make - Move all automake options to configure.ac - Add manpages to install target - Make XATTR & LZO support configurable - Install binaries to sbin directory like in the old build system - Install flash_erase wrapper script - Add files missing from distribution target Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17Remove duplicate copies of GPLv2 license textDavid Oberhollenzer
Some of the programs in the mtd-utils used to be seperate packages that were at some point merged into mtd-utils. As a result, some subdirectories contain their own README and COPYING files with copies of the GPLv2 license text. Since those programs are now part of mtd-utils that contains a copy of the GPLv2 in the file COPYING in the package root directory, those extra files can be removed, as there is no need for distributing an extra copy of the license text for each individual program in the bundle. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>