aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
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>
2016-08-25fs-tests: integrity: don't include header <bits/stdio_lim.h>Rahul Bedarkar
In commit ca7a5eda221d("integck.c: Fix buffer overflow in save_file") we started including header <bits/stdio_lim.h>. But with musl C library, we get following build error integck.c:37:28: fatal error: bits/stdio_lim.h: No such file or directory #include <bits/stdio_lim.h> ^ compilation terminated. make[2]: *** [integck] Error 1 Header <bits/stdio_lim.h> is not available in musl C library. However <stdio.h> has all definition that <bits/stdio_lim.h> supposed to be providing. Moreover <bits/stdio_lim.h> shouldn't be included directly instead we should be using <stdio.h>. Since we already include <stdio.h> and in case of uClibc or glibc <bits/stdio_lim.h> gets included internally, we can safely remove it. This build issue is found by Buildroot autobuilder http://autobuild.buildroot.net/results/175/1754861457af520480cc34d7d2d0edff2868ff66/ Fixes: ca7a5eda221d("integck.c: Fix buffer overflow in save_file") Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-09-29mtd: tests: Fix endian issue with CRC generation algorithmPaul McGougan
The calculation of the CRC in /tests/checkfs/makefiles.c was writing the CRC Into the produced files in host byte-order which would cause CRC validation to fail on big-endian systems as the validation is performed bytewise. Signed-off-by: Paul McGougan <pmcgougan AT topcon.com> [Brian: add endian.h] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fix 'new blank line at EOF' problemsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fix the trailing whitespace problemsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: ubi-tests: fix a some overflowsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fs-tests: pass TEST_DIR to integck in run_all.shDongsheng Yang
Test integck requires a parameter but run_all.sh did no pass any to it. Then: integck: error!: test file-system was not specified (use -h for help) Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-04-15mtd-utils: integck: Use $(CC) and $(AR) instead of 'gcc' and 'ar' consistentlyMats Kärrman
Not using the macros may be a problem when cross-compiling. Signed-off-by: Mats Karrman <mats.karrman@tritech.se> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck: fix identation a bitArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: Fix buffer overflow in save_fileElie De Brauwer
In the problem above I've spend several hours waiting for the issue to appear, only to had the 'luck' that it was found in a file whose name was 256 bytes in length, resulting in the write to fail. Closer examination showed that the buffer to store the path was 256 bytes in length, but this buffer also includes /tmp and the read/write suffix and should be able to contain a filename which is up to 255 bytes (NAME_MAX in linux/limits.h) in size which is a bad fit. So that array is modified to FILENAME_MAX (stdio_lim.h) and some checking is added to truncate the filename should it cause an overflow. The following log shows the first patch in action (see the correct seed), and shows why this third patch is needed: <quote> integck:     File Data: integck:         Offset: 0  Size: 1  Seed: 5008310  R.Off: 0 integck:     1 writes integck:     ============================================ integck:     Write Info: integck:         Offset: 0  Size: 1  Seed: 5008310  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 8246352  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 5078796  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 2267087  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 3602680  R.Off: 0 integck:     5 writes or truncations integck:     ============================================ integck: Saving /tmp/yqcnfygfitaatyeyvffrguegcdttamcnyhowhgieljfuxfipiljsjcbluaeaghwyinkggommsbwnmvekihgnwgiibccpbwfrpxuxwkmnyghnutrudienngxwgorudbskedaaekiuiyqksfazrwzfwbfhzjjqoiulebtlpbfiuffmsnguqkjzqjqizimsmhbqqagaebjdhqwmzdxghiavtcxubegawlgtvstuqurkurpnrckjfkgostdtpg.integ.sav.readn integck: error!: condition 'w_fd != -1' failed in save_file() at integck.c:1445 integck: error 36 (File name too long) </quote> Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: rework file_check_data to immediately dump the buffer containing ↵Elie De Brauwer
the errors See my problem description int the previous commit, the point is that integck in file_check_data reads a buffer, and then checks if the data is correct,  it will do a seek(0), and reread from the same fd. The point is that in the scenario I observed integck failed (due to a buffer mismatch) but the it saved (and what was in flash) was actually correct. So I modified this function to dump the buffers to stderr at the moment an error is found. Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: Only verify the operation after all datastructures have been updatedElie De Brauwer
<quote> integck: File Data: integck: Offset: 0 Size: 196 Seed: 5999877 R.Off: 0 integck: Offset: 196 Size: 33 Seed: 4160795 R.Off: 0 integck: Offset: 229 Size: 1252 Seed: 8070052 R.Off: 0 integck: Offset: 1481 Size: 612 Seed: 4160795 R.Off: 1285 integck: Offset: 2093 Size: 6 Seed: 6946586 R.Off: 0 integck: Offset: 2099 Size: 536 Seed: 4160795 R.Off: 1903 integck: Offset: 2635 Size: 1562 Seed: 9845455 R.Off: 0 integck: Offset: 4197 Size: 80 Seed: 702818 R.Off: 0 integck: Offset: 4277 Size: 115 Seed: 9845455 R.Off: 1642 integck: 9 writes integck: ============================================ integck: Write Info: integck: Offset: 826 Size: 357 Seed: 5908448 R.Off: 0 integck: Offset: 4197 Size: 80 Seed: 702818 R.Off: 0 ... </quote> And I would expect the file data listing to include at offset 826 something with a size of 357 and a seed of 5908448. Clearly it is not there (which is already extremely confusing). The point is that file_write_info first updates the raw_write, then verifies the data (passing the new write) and only after that updates the write structure. But in file_check_data only the newly written data is verified (passed as an argument) whilst the save_file() function to dump the file uses the raw_writes to recreate the written data (while raw_writes is only updated after after this check would have succeeded). Several lines to say that in this patch the verify only gets called _after_ the datastructures are updated. Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-12-03ubi-tests: fix pthreads linkingBrian Norris
Technically, '-l' linker options should be included only after the objects which must link to the library. So when we include '-lpthread' in the LDFLAGS variable, it gets placed too early (i.e., before the io_paral.o object), and so the pthread linkage never occurs. The following error probably only shows up with linkers that don't link pthreads by default. $ make tests V=1 ... gcc -I../../ubi-utils//include -I ../../include -lpthread -Wall -Wextra -Wwrite-strings -Wno-sign-compare -ffunction-sections -fdata-sections -Wl,--gc-sections -g -o /home/norris/git/mtd-utils/tests/ubi-tests/io_paral /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o /home/norris/git/mtd-utils/tests/ubi-tests/helpers.o libubi.a /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o: In function `main': /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:287: undefined reference to `pthread_create' /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:295: undefined reference to `pthread_create' /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:303: undefined reference to `pthread_join' collect2: ld returned 1 exit status make[2]: *** [/home/norris/git/mtd-utils/tests/ubi-tests/io_paral] Error 1 ... $ ld --version GNU ld (GNU Binutils for Ubuntu) 2.22 ... $ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 ... Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: switch to using common.h from the top levelArtem Bityutskiy
Sorry, the commit is huge, I just did not have time to split it. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: rename common.[ch] to helpers.[ch]Artem Bityutskiy
... to avoid confusion when the local common.h shadows the top-level common.h. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: ubi_leb_change_start() no longer uses 'dtype'.Bill Pringlemeir
This will not compile for me (due to bit rot?). Maybe the program is never used? Signed-off-by: Bill Pringlemeir <bpringlemeir@nbsps.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25consistency between u_int32_t / off_t / off64_tRichard Genoud
We should use the off_t type instead of off64_t or u_int32_t as its length is controlled by the WITHOUT_LARGEFILE flag. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25tests: io_update correct lseek parameters orderRichard Genoud
There's a typo in lseek parameters order. But, due to the value of SEEK_SET, this commit doesn't introduce a change. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-23ubiattach: introduce max_beb_per1024 in UBI_IOCATTRichard Genoud
The ioctl UBI_IOCATT has been extended with max_beb_per1024 parameter. This parameter is used for adjusting the "maximum expected number of bad blocks per 1024 blocks" for each mtd device. The number of physical erase blocks (PEB) that UBI will reserve for bad block handling is now: whole_flash_chipset__PEB_number * max_beb_per1024 / 1024 This means that for a 4096 PEB NAND device with 3 MTD partitions: mtd0: 512 PEB mtd1: 1536 PEB mtd2: 2048 PEB the commands: ubiattach -m 0 -d 0 -b 20 /dev/ubi_ctrl ubiattach -m 1 -d 1 -b 20 /dev/ubi_ctrl ubiattach -m 2 -d 2 -b 20 /dev/ubi_ctrl will attach mtdx to UBIx and reserve: 80 PEB for bad block handling on UBI0 80 PEB for bad block handling on UBI1 80 PEB for bad block handling on UBI2 => for the whole device, 240 PEB will be reserved for bad block handling. This may seems a waste of space, but as far as the bad blocks can appear every where on a flash device, in the worst case scenario they can all appear in one MTD partition. So the maximum number of expected erase blocks given by the NAND manufacturer should be reserve on each MTD partition. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-22UBI: sync ubi-user.h with kernel v3.6-rc1Richard Genoud
Also remove the eraseblock type support, because kernel commit a65a0eb6d198e058687a9214683bd1c418f20d39 set the dtype parameter as obsolete. Also adjust to some renames: * 'UBI_PROP_DIRECT_WRITE' -> 'UBI_VOL_PROP_DIRECT_WRITE' * 'struct ubi_set_prop_req' -> 'struct ubi_set_vol_prop_req'. * 'UBI_IOCSETPROP' -> 'UBI_IOCSETVOLPROP' Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03stress-test.sh: remove a warningArtem Bityutskiy
If /proc/mtd does not exist, we have this warning: grep: /proc/mtd: No such file or directory Get rid of this. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03stress-test.sh: add mtdram testsArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03stress-test.sh: support testing without sub-pagesArtem Bityutskiy
Run the tests with VID header at the second page as well for better coverage. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03stress-test.sh: develop the test furtherArtem Bityutskiy
Add a lot of test passes on nandsim with different geometry. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03runtests.sh: print more consistent messagesArtem Bityutskiy
On success we print "SUCCESS", lets print "FAILURE" on failure. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-03stress-test.sh: do not use pipe unnecessarilyArtem Bityutskiy
Use 'grep patt file' instead of cat file | grep patt. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-02tests: ubi: add stress-test.shArtem Bityutskiy
It is not finished yet, but it will run all tests on nandsim and mtdram of different geometry. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-02tests: ubi: clean-up runtests.sh some moreArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-02tests: ubi: clean-up the runtests.sh scriptArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2011-10-14tests: checkfs: remove unused codeAndy Shevchenko
There are two variables which are not used anymore. Thos patch removes useless lines and suppresses gcc warnings. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-23mtd-utils: use __func__ instead of __FUNCTION__Brian Norris
__func__ is more portable Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-06-29mtd-utils: update .gitignore filesBrian Norris
First, the top-level Makefile should not tell git to ignore sub-level .gitignore files. Second, add simple .gitignores to ignore the executables generated under the various `tests' subdirectories. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>