diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/checkfs/Makemodule.am | 18 | ||||
-rw-r--r-- | tests/fs-tests/Makemodule.am | 42 | ||||
-rwxr-xr-x | tests/fs-tests/fs_help_all.sh.in | 6 | ||||
-rwxr-xr-x | tests/fs-tests/fs_run_all.sh.in | 6 | ||||
-rw-r--r-- | tests/fs-tests/lib/tests.c | 1 | ||||
-rwxr-xr-x | tests/fs-tests/stress/fs_stress00.sh.in | 6 | ||||
-rwxr-xr-x | tests/fs-tests/stress/fs_stress01.sh.in | 6 | ||||
-rw-r--r-- | tests/jittertest/Makemodule.am | 19 | ||||
-rw-r--r-- | tests/mtd-tests/Makemodule.am | 13 | ||||
-rw-r--r-- | tests/mtd-tests/flash_readtest.c | 12 | ||||
-rw-r--r-- | tests/mtd-tests/flash_speed.c | 177 | ||||
-rw-r--r-- | tests/mtd-tests/flash_stress.c | 12 | ||||
-rw-r--r-- | tests/mtd-tests/flash_torture.c | 10 | ||||
-rw-r--r-- | tests/ubi-tests/Makemodule.am | 27 | ||||
-rwxr-xr-x | tests/ubi-tests/runubitests.sh.in | 6 | ||||
-rwxr-xr-x | tests/ubi-tests/ubi-stress-test.sh.in | 6 | ||||
-rw-r--r-- | tests/unittests/Makemodule.am | 10 |
17 files changed, 226 insertions, 151 deletions
diff --git a/tests/checkfs/Makemodule.am b/tests/checkfs/Makemodule.am index 6e1314f..631ab92 100644 --- a/tests/checkfs/Makemodule.am +++ b/tests/checkfs/Makemodule.am @@ -1,22 +1,10 @@ checkfs_SOURCES = tests/checkfs/checkfs.c tests/checkfs/comm.c +checkfs_SOURCES += tests/checkfs/common.h checkfs_CPPFLAGS = $(AM_CPPFLAGS) makefiles_SOURCES = tests/checkfs/makefiles.c makefiles_CPPFLAGS = $(AM_CPPFLAGS) -CHECKFS_BINS = \ - makefiles checkfs +EXTRA_DIST += tests/checkfs/README -CHECKFS_HEADER = \ - tests/checkfs/common.h - -CHECKFS_EXTRA = \ - tests/checkfs/README - -EXTRA_DIST += $(CHECKFS_EXTRA) $(CHECKFS_HEADER) - -if INSTALL_TESTS -pkglibexec_PROGRAMS += $(CHECKFS_BINS) -else -noinst_PROGRAMS += $(CHECKFS_BINS) -endif +test_PROGRAMS += makefiles checkfs diff --git a/tests/fs-tests/Makemodule.am b/tests/fs-tests/Makemodule.am index 2eae860..0c58c9c 100644 --- a/tests/fs-tests/Makemodule.am +++ b/tests/fs-tests/Makemodule.am @@ -3,84 +3,76 @@ integck_LDADD = libubi.a libmissing.a integck_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include test_1_SOURCES = tests/fs-tests/simple/test_1.c tests/fs-tests/lib/tests.c +test_1_SOURCES += tests/fs-tests/lib/tests.h test_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib test_2_SOURCES = tests/fs-tests/simple/test_2.c tests/fs-tests/lib/tests.c +test_2_SOURCES += tests/fs-tests/lib/tests.h test_2_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib ftrunc_SOURCES = tests/fs-tests/simple/ftrunc.c tests/fs-tests/lib/tests.c +ftrunc_SOURCES += tests/fs-tests/lib/tests.h ftrunc_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib perf_SOURCES = tests/fs-tests/simple/perf.c tests/fs-tests/lib/tests.c +perf_SOURCES += tests/fs-tests/lib/tests.h perf_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib orph_SOURCES = tests/fs-tests/simple/orph.c tests/fs-tests/lib/tests.c +orph_SOURCES += tests/fs-tests/lib/tests.h orph_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_1_SOURCES = tests/fs-tests/stress/atoms/stress_1.c -stress_1_SOURCES += tests/fs-tests/lib/tests.c +stress_1_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_2_SOURCES = tests/fs-tests/stress/atoms/stress_2.c -stress_2_SOURCES += tests/fs-tests/lib/tests.c +stress_2_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_2_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_3_SOURCES = tests/fs-tests/stress/atoms/stress_3.c -stress_3_SOURCES += tests/fs-tests/lib/tests.c +stress_3_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_3_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib pdfrun_SOURCES = tests/fs-tests/stress/atoms/pdfrun.c -pdfrun_SOURCES += tests/fs-tests/lib/tests.c +pdfrun_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h pdfrun_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndwrite00_SOURCES = tests/fs-tests/stress/atoms/rndwrite00.c -rndwrite00_SOURCES += tests/fs-tests/lib/tests.c +rndwrite00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndwrite00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib fwrite00_SOURCES = tests/fs-tests/stress/atoms/fwrite00.c -fwrite00_SOURCES += tests/fs-tests/lib/tests.c +fwrite00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h fwrite00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rmdir00_SOURCES = tests/fs-tests/stress/atoms/rmdir00.c -rmdir00_SOURCES += tests/fs-tests/lib/tests.c +rmdir00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rmdir00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndrm00_SOURCES = tests/fs-tests/stress/atoms/rndrm00.c -rndrm00_SOURCES += tests/fs-tests/lib/tests.c +rndrm00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndrm00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndrm99_SOURCES = tests/fs-tests/stress/atoms/rndrm99.c -rndrm99_SOURCES += tests/fs-tests/lib/tests.c +rndrm99_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndrm99_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib gcd_hupper_SOURCES = tests/fs-tests/stress/atoms/gcd_hupper.c -gcd_hupper_SOURCES += tests/fs-tests/lib/tests.c +gcd_hupper_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h gcd_hupper_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib fstest_monitor_SOURCES = tests/fs-tests/utils/fstest_monitor.c free_space_SOURCES = tests/fs-tests/utils/free_space.c -FSTEST_BINS = \ +test_PROGRAMS += \ integck test_1 test_2 ftrunc perf orph \ stress_1 stress_2 stress_3 pdfrun gcd_hupper \ rndwrite00 fwrite00 rmdir00 rndrm00 rndrm99 \ fstest_monitor free_space -FSTEST_SH = \ +test_SCRIPTS += \ tests/fs-tests/fs_help_all.sh tests/fs-tests/fs_run_all.sh \ tests/fs-tests/stress/fs_stress00.sh \ tests/fs-tests/stress/fs_stress01.sh - -FSTEST_HEADER = \ - tests/fs-tests/lib/tests.h - -EXTRA_DIST += $(FSTEST_HEADER) - -if INSTALL_TESTS -pkglibexec_SCRIPTS += $(FSTEST_SH) -pkglibexec_PROGRAMS += $(FSTEST_BINS) -else -noinst_SCRIPTS += $(FSTEST_SH) -noinst_PROGRAMS += $(FSTEST_BINS) -endif diff --git a/tests/fs-tests/fs_help_all.sh.in b/tests/fs-tests/fs_help_all.sh.in index 39219b2..3898fbd 100755 --- a/tests/fs-tests/fs_help_all.sh.in +++ b/tests/fs-tests/fs_help_all.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ echo ------------------------------------------------------------------------------- $TESTBINDIR/test_1 -h diff --git a/tests/fs-tests/fs_run_all.sh.in b/tests/fs-tests/fs_run_all.sh.in index a3676f9..f15a63b 100755 --- a/tests/fs-tests/fs_run_all.sh.in +++ b/tests/fs-tests/fs_run_all.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; diff --git a/tests/fs-tests/lib/tests.c b/tests/fs-tests/lib/tests.c index d1a2e0c..3db0426 100644 --- a/tests/fs-tests/lib/tests.c +++ b/tests/fs-tests/lib/tests.c @@ -35,7 +35,6 @@ #include <sys/vfs.h> #include <sys/mount.h> #include <sys/statvfs.h> -#include <linux/fs.h> #include <linux/jffs2.h> #include "tests.h" diff --git a/tests/fs-tests/stress/fs_stress00.sh.in b/tests/fs-tests/stress/fs_stress00.sh.in index 85ec7a2..f7d317c 100755 --- a/tests/fs-tests/stress/fs_stress00.sh.in +++ b/tests/fs-tests/stress/fs_stress00.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; diff --git a/tests/fs-tests/stress/fs_stress01.sh.in b/tests/fs-tests/stress/fs_stress01.sh.in index d0ea8f9..da6babf 100755 --- a/tests/fs-tests/stress/fs_stress01.sh.in +++ b/tests/fs-tests/stress/fs_stress01.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; diff --git a/tests/jittertest/Makemodule.am b/tests/jittertest/Makemodule.am index d4cc121..d280192 100644 --- a/tests/jittertest/Makemodule.am +++ b/tests/jittertest/Makemodule.am @@ -4,21 +4,8 @@ JitterTest_CPPFLAGS = $(AM_CPPFLAGS) plotJittervsFill_SOURCES = tests/jittertest/plotJittervsFill.c plotJittervsFill_CPPFLAGS = $(AM_CPPFLAGS) -JITTEREST_BINS = \ - JitterTest plotJittervsFill +test_PROGRAMS += JitterTest plotJittervsFill -JITTERTEST_SH = \ - tests/jittertest/filljffs2.sh +test_SCRIPTS += tests/jittertest/filljffs2.sh -JITTERTEST_EXTRA = \ - tests/jittertest/README - -EXTRA_DIST += $(JITTERTEST_EXTRA) $(JITTERTEST_SH) - -if INSTALL_TESTS -pkglibexec_SCRIPTS += $(JITTERTEST_SH) -pkglibexec_PROGRAMS += $(JITTEREST_BINS) -else -noinst_SCRIPTS += $(JITTERTEST_SH) -noinst_PROGRAMS += $(JITTEREST_BINS) -endif +EXTRA_DIST += tests/jittertest/README tests/jittertest/filljffs2.sh diff --git a/tests/mtd-tests/Makemodule.am b/tests/mtd-tests/Makemodule.am index 5925fd9..d02e9e4 100644 --- a/tests/mtd-tests/Makemodule.am +++ b/tests/mtd-tests/Makemodule.am @@ -7,9 +7,12 @@ flash_stress_LDADD = libmtd.a flash_stress_CPPFLAGS = $(AM_CPPFLAGS) flash_speed_SOURCES = tests/mtd-tests/flash_speed.c -flash_speed_LDADD = libmtd.a +flash_speed_LDADD = libmtd.a $(PTHREAD_LIBS) flash_speed_CPPFLAGS = $(AM_CPPFLAGS) +flash_speed_LDADD += $(PTHREAD_CFLAGS) +flash_speed_CPPFLAGS += $(PTHREAD_CFLAGS) + nandbiterrs_SOURCES = tests/mtd-tests/nandbiterrs.c nandbiterrs_LDADD = libmtd.a nandbiterrs_CPPFLAGS = $(AM_CPPFLAGS) @@ -26,12 +29,6 @@ nandsubpagetest_SOURCES = tests/mtd-tests/nandsubpagetest.c nandsubpagetest_LDADD = libmtd.a nandsubpagetest_CPPFLAGS = $(AM_CPPFLAGS) -MTDTEST_BINS = \ +test_PROGRAMS += \ flash_torture flash_stress flash_speed nandbiterrs flash_readtest \ nandpagetest nandsubpagetest - -if INSTALL_TESTS -pkglibexec_PROGRAMS += $(MTDTEST_BINS) -else -noinst_PROGRAMS += $(MTDTEST_BINS) -endif diff --git a/tests/mtd-tests/flash_readtest.c b/tests/mtd-tests/flash_readtest.c index c5fabc9..519ff89 100644 --- a/tests/mtd-tests/flash_readtest.c +++ b/tests/mtd-tests/flash_readtest.c @@ -125,10 +125,14 @@ static void process_options(int argc, char **argv) } } - if (optind < argc) - mtddev = argv[optind++]; - else + if (optind < argc) { + mtddev = mtd_find_dev_node(argv[optind]); + if (!mtddev) + errmsg_die("Can't find MTD device %s", argv[optind]); + optind++; + } else { errmsg_die("No device specified!\n"); + } if (optind < argc) usage(EXIT_FAILURE); @@ -227,7 +231,7 @@ int main(int argc, char **argv) puts("not NAND flash, assume page size is 512 bytes."); pgsize = 512; } else { - pgsize = mtd.subpage_size; + pgsize = mtd.min_io_size; } pgcnt = mtd.eb_size / pgsize; diff --git a/tests/mtd-tests/flash_speed.c b/tests/mtd-tests/flash_speed.c index 0058269..3489233 100644 --- a/tests/mtd-tests/flash_speed.c +++ b/tests/mtd-tests/flash_speed.c @@ -33,6 +33,7 @@ #include <stdlib.h> #include <libmtd.h> #include <getopt.h> +#include <pthread.h> #include <stdio.h> #include <fcntl.h> #include <time.h> @@ -46,7 +47,7 @@ static const char *mtddev; static libmtd_t mtd_desc; static int fd; -static int peb=-1, count=-1, skip=-1, flags=0; +static int peb=-1, count=-1, skip=-1, flags=0, speb=-1; static struct timespec start, finish; static int pgsize, pgcnt; static int goodebcnt; @@ -57,6 +58,7 @@ static const struct option options[] = { { "peb", required_argument, NULL, 'b' }, { "count", required_argument, NULL, 'c' }, { "skip", required_argument, NULL, 's' }, + { "sec-peb", required_argument, NULL, 'k' }, { NULL, 0, NULL, 0 }, }; @@ -69,7 +71,8 @@ static NORETURN void usage(int status) " -b, --peb <num> Start from this physical erase block\n" " -c, --count <num> Number of erase blocks to use (default: all)\n" " -s, --skip <num> Number of blocks to skip\n" - " -d, --destructive Run destructive (erase and write speed) tests\n", + " -d, --destructive Run destructive (erase and write speed) tests\n" + " -k, --sec-peb <num> Start of secondary block to measure RWW latency (requires -d)\n", status==EXIT_SUCCESS ? stdout : stderr); exit(status); } @@ -93,7 +96,7 @@ static void process_options(int argc, char **argv) int c; while (1) { - c = getopt_long(argc, argv, "hb:c:s:d", options, NULL); + c = getopt_long(argc, argv, "hb:c:s:dk:", options, NULL); if (c == -1) break; @@ -126,15 +129,26 @@ static void process_options(int argc, char **argv) goto failmulti; flags |= DESTRUCTIVE; break; + case 'k': + if (speb >= 0) + goto failmulti; + speb = read_num(c, optarg); + if (speb < 0) + goto failarg; + break; default: exit(EXIT_FAILURE); } } - if (optind < argc) - mtddev = argv[optind++]; - else + if (optind < argc) { + mtddev = mtd_find_dev_node(argv[optind]); + if (!mtddev) + errmsg_die("Can't find MTD device %s", argv[optind]); + optind++; + } else { errmsg_die("No device specified!\n"); + } if (optind < argc) usage(EXIT_FAILURE); @@ -144,11 +158,15 @@ static void process_options(int argc, char **argv) skip = 0; if (count < 0) count = 1; + if (speb >= 0 && !(flags & DESTRUCTIVE)) + goto faildestr; return; failmulti: errmsg_die("'-%c' specified more than once!\n", c); failarg: errmsg_die("Invalid argument for '-%c'!\n", c); +faildestr: + errmsg_die("'-k' specified, -d is missing!\n"); } static int write_eraseblock(int ebnum) @@ -258,22 +276,29 @@ static int read_eraseblock_by_2pages(int ebnum) return err; } -static void start_timing(void) +static void start_timing(struct timespec *start) { - clock_gettime(CLOCK_MONOTONIC_RAW, &start); + clock_gettime(CLOCK_MONOTONIC_RAW, start); } -static void stop_timing(void) +static void stop_timing(struct timespec *finish) { - clock_gettime(CLOCK_MONOTONIC_RAW, &finish); + clock_gettime(CLOCK_MONOTONIC_RAW, finish); } -static long calc_speed(void) +static long calc_duration(struct timespec *start, struct timespec *finish) { long ms; - ms = (finish.tv_sec - start.tv_sec) * 1000L; - ms += (finish.tv_nsec - start.tv_nsec) / 1000000L; + ms = (finish->tv_sec - start->tv_sec) * 1000L; + ms += (finish->tv_nsec - start->tv_nsec) / 1000000L; + + return ms; +} + +static long calc_speed(struct timespec *start, struct timespec *finish) +{ + long ms = calc_duration(start, finish); if (ms <= 0) return 0; @@ -313,8 +338,34 @@ static int erase_good_eraseblocks(unsigned int eb, int ebcnt, int ebskip) return err; } +struct thread_arg { + int (*op)(int peb); + int peb; + struct timespec start; + struct timespec finish; +}; + +static void *op_thread(void *ptr) +{ + struct thread_arg *args = ptr; + unsigned long err = 0; + int i; + + start_timing(&args->start); + for (i = 0; i < count; ++i) { + if (bbt[i]) + continue; + err = args->op(args->peb + i * (skip + 1)); + if (err) + break; + } + stop_timing(&args->finish); + + return (void *)err; +} + #define TIME_OP_PER_PEB( op )\ - start_timing();\ + start_timing(&start);\ for (i = 0; i < count; ++i) {\ if (bbt[i])\ continue;\ @@ -322,8 +373,8 @@ static int erase_good_eraseblocks(unsigned int eb, int ebcnt, int ebskip) if (err)\ goto out;\ }\ - stop_timing();\ - speed = calc_speed() + stop_timing(&finish);\ + speed = calc_speed(&start, &finish) int main(int argc, char **argv) { @@ -343,7 +394,7 @@ int main(int argc, char **argv) puts("not NAND flash, assume page size is 512 bytes."); pgsize = 512; } else { - pgsize = mtd.subpage_size; + pgsize = mtd.min_io_size; } pgcnt = mtd.eb_size / pgsize; @@ -428,12 +479,12 @@ int main(int argc, char **argv) /* Erase all eraseblocks */ if (flags & DESTRUCTIVE) { puts("Testing erase speed"); - start_timing(); + start_timing(&start); err = erase_good_eraseblocks(peb, count, skip); if (err) goto out; - stop_timing(); - speed = calc_speed(); + stop_timing(&finish); + speed = calc_speed(&start, &finish); printf("erase speed is %ld KiB/s\n", speed); } @@ -442,7 +493,7 @@ int main(int argc, char **argv) for (k = 1; k < 7; ++k) { blocks = 1 << k; printf("Testing %dx multi-block erase speed\n", blocks); - start_timing(); + start_timing(&start); for (i = 0; i < count; ) { for (j = 0; j < blocks && (i + j) < count; ++j) if (bbt[i + j]) @@ -456,13 +507,93 @@ int main(int argc, char **argv) goto out; i += j; } - stop_timing(); - speed = calc_speed(); + stop_timing(&finish); + speed = calc_speed(&start, &finish); printf("%dx multi-block erase speed is %ld KiB/s\n", blocks, speed); } } + /* Write a page and immediately after try to read another page. Report + * the latency difference when performed on different banks (NOR only). + */ + if (speb >= 0 && mtd.subpage_size == 1) { + long rww_duration_w, rww_latency_end; + long rww_duration_rnw, rww_duration_r_end; + bool rww_r_end_first; + struct thread_arg write_args_peb = { + .op = write_eraseblock, + .peb = peb, + }; + struct thread_arg read_args_speb = { + .op = read_eraseblock, + .peb = speb, + }; + struct sched_param param_write, param_read; + pthread_attr_t attr_write, attr_read; + pthread_t write_thread, read_thread; + void *retval; + + puts("testing read while write latency"); + + /* Change scheduling priorities so that the write thread gets + *scheduled more aggressively than the read thread. + */ + pthread_attr_init(&attr_write); + pthread_attr_setinheritsched(&attr_write, PTHREAD_EXPLICIT_SCHED); + pthread_attr_setschedpolicy(&attr_write, SCHED_FIFO); + param_write.sched_priority = 42; + pthread_attr_setschedparam(&attr_write, ¶m_write); + + pthread_attr_init(&attr_read); + pthread_attr_setinheritsched(&attr_read, PTHREAD_EXPLICIT_SCHED); + pthread_attr_setschedpolicy(&attr_read, SCHED_FIFO); + param_read.sched_priority = 41; + pthread_attr_setschedparam(&attr_read, ¶m_read); + + err = pthread_create(&write_thread, &attr_write, + (void *)op_thread, &write_args_peb); + if (err) { + errmsg("parallel write pthread create failed"); + goto out; + } + + err = pthread_create(&read_thread, &attr_read, + (void *)op_thread, &read_args_speb); + if (err) { + errmsg("parallel read pthread create failed"); + goto out; + } + + pthread_join(read_thread, &retval); + if ((long)retval) { + errmsg("parallel read pthread failed"); + goto out; + } + + pthread_join(write_thread, &retval); + if ((long)retval) { + errmsg("parallel write pthread failed"); + goto out; + } + + rww_duration_w = calc_duration(&write_args_peb.start, + &write_args_peb.finish); + rww_latency_end = calc_duration(&write_args_peb.finish, + &read_args_speb.finish); + rww_r_end_first = rww_latency_end < 0; + if (rww_r_end_first) + rww_duration_rnw = rww_duration_w; + else + rww_duration_rnw = calc_duration(&write_args_peb.start, + &read_args_speb.finish); + + rww_duration_r_end = calc_duration(&write_args_peb.start, + &read_args_speb.finish); + printf("read while write took %ldms, read ended after %ldms\n", + rww_duration_rnw, rww_duration_r_end); + } + puts("finished"); status = EXIT_SUCCESS; out: diff --git a/tests/mtd-tests/flash_stress.c b/tests/mtd-tests/flash_stress.c index 249d8cb..da39e14 100644 --- a/tests/mtd-tests/flash_stress.c +++ b/tests/mtd-tests/flash_stress.c @@ -126,10 +126,14 @@ static void process_options(int argc, char **argv) } } - if (optind < argc) - mtddev = argv[optind++]; - else + if (optind < argc) { + mtddev = mtd_find_dev_node(argv[optind]); + if (!mtddev) + errmsg_die("Can't find MTD device %s", argv[optind]); + optind++; + } else { errmsg_die("No device specified!\n"); + } if (optind < argc) usage(EXIT_FAILURE); @@ -242,7 +246,7 @@ int main(int argc, char **argv) puts("not NAND flash, assume page size is 512 bytes."); pgsize = 512; } else { - pgsize = mtd.subpage_size; + pgsize = mtd.min_io_size; } pgcnt = mtd.eb_size / pgsize; diff --git a/tests/mtd-tests/flash_torture.c b/tests/mtd-tests/flash_torture.c index 5aad8e0..6363f9e 100644 --- a/tests/mtd-tests/flash_torture.c +++ b/tests/mtd-tests/flash_torture.c @@ -144,10 +144,14 @@ static void process_options(int argc, char **argv) } } - if (optind < argc) - mtddev = argv[optind++]; - else + if (optind < argc) { + mtddev = mtd_find_dev_node(argv[optind]); + if (!mtddev) + errmsg_die("Can't find MTD device %s", argv[optind]); + optind++; + } else { errmsg_die("No device specified!\n"); + } if (optind < argc) usage(EXIT_FAILURE); diff --git a/tests/ubi-tests/Makemodule.am b/tests/ubi-tests/Makemodule.am index d1fbab7..13d7b08 100644 --- a/tests/ubi-tests/Makemodule.am +++ b/tests/ubi-tests/Makemodule.am @@ -1,12 +1,15 @@ io_basic_SOURCES = tests/ubi-tests/io_basic.c tests/ubi-tests/helpers.c +io_basic_SOURCES += tests/ubi-tests/helpers.h io_basic_LDADD = libubi.a io_basic_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include io_update_SOURCES = tests/ubi-tests/io_update.c tests/ubi-tests/helpers.c +io_update_SOURCES += tests/ubi-tests/helpers.h io_update_LDADD = libubi.a io_update_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include io_paral_SOURCES = tests/ubi-tests/io_paral.c tests/ubi-tests/helpers.c +io_paral_SOURCES += tests/ubi-tests/helpers.h io_paral_LDADD = libubi.a $(PTHREAD_LIBS) io_paral_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include @@ -14,26 +17,32 @@ io_paral_LDADD += $(PTHREAD_CFLAGS) io_paral_CPPFLAGS += $(PTHREAD_CFLAGS) io_read_SOURCES = tests/ubi-tests/io_read.c tests/ubi-tests/helpers.c +io_read_SOURCES += tests/ubi-tests/helpers.h io_read_LDADD = libubi.a io_read_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include volrefcnt_SOURCES = tests/ubi-tests/volrefcnt.c tests/ubi-tests/helpers.c +volrefcnt_SOURCES += tests/ubi-tests/helpers.h volrefcnt_LDADD = libubi.a volrefcnt_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include integ_SOURCES = tests/ubi-tests/integ.c tests/ubi-tests/helpers.c +integ_SOURCES += tests/ubi-tests/helpers.h integ_LDADD = libubi.a integ_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include mkvol_basic_SOURCES = tests/ubi-tests/mkvol_basic.c tests/ubi-tests/helpers.c +mkvol_basic_SOURCES += tests/ubi-tests/helpers.h mkvol_basic_LDADD = libubi.a mkvol_basic_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include mkvol_bad_SOURCES = tests/ubi-tests/mkvol_bad.c tests/ubi-tests/helpers.c +mkvol_bad_SOURCES += tests/ubi-tests/helpers.h mkvol_bad_LDADD = libubi.a mkvol_bad_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include mkvol_paral_SOURCES = tests/ubi-tests/mkvol_paral.c tests/ubi-tests/helpers.c +mkvol_paral_SOURCES += tests/ubi-tests/helpers.h mkvol_paral_LDADD = libubi.a $(PTHREAD_LIBS) mkvol_paral_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include @@ -41,25 +50,13 @@ mkvol_paral_LDADD += $(PTHREAD_CFLAGS) mkvol_paral_CPPFLAGS += $(PTHREAD_CFLAGS) rsvol_SOURCES = tests/ubi-tests/rsvol.c tests/ubi-tests/helpers.c +rsvol_SOURCES += tests/ubi-tests/helpers.h rsvol_LDADD = libubi.a rsvol_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include -UBITEST_BINS = \ +test_PROGRAMS += \ io_basic io_update io_paral io_read volrefcnt integ \ mkvol_basic mkvol_bad mkvol_paral rsvol -UBITEST_SH = \ +test_SCRIPTS += \ tests/ubi-tests/runubitests.sh tests/ubi-tests/ubi-stress-test.sh - -UBITEST_HEADER = \ - tests/ubi-tests/helpers.h - -EXTRA_DIST += $(UBITEST_HEADER) - -if INSTALL_TESTS -pkglibexec_SCRIPTS += $(UBITEST_SH) -pkglibexec_PROGRAMS += $(UBITEST_BINS) -else -noinst_SCRIPTS += $(UBITEST_SH) -noinst_PROGRAMS += $(UBITEST_BINS) -endif diff --git a/tests/ubi-tests/runubitests.sh.in b/tests/ubi-tests/runubitests.sh.in index a1b23c4..1675308 100755 --- a/tests/ubi-tests/runubitests.sh.in +++ b/tests/ubi-tests/runubitests.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -euf -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ tests="mkvol_basic mkvol_bad mkvol_paral rsvol io_basic io_read io_update io_paral volrefcnt" diff --git a/tests/ubi-tests/ubi-stress-test.sh.in b/tests/ubi-tests/ubi-stress-test.sh.in index 657ef4b..e178076 100755 --- a/tests/ubi-tests/ubi-stress-test.sh.in +++ b/tests/ubi-tests/ubi-stress-test.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -euf -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ fatal() { diff --git a/tests/unittests/Makemodule.am b/tests/unittests/Makemodule.am index df1041d..277cac2 100644 --- a/tests/unittests/Makemodule.am +++ b/tests/unittests/Makemodule.am @@ -1,9 +1,11 @@ ubilib_test_SOURCES = tests/unittests/libubi_test.c lib/libubi.c +ubilib_test_SOURCES += tests/unittests/test_lib.h ubilib_test_LDADD = $(CMOCKA_LIBS) ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I$(top_srcdir)/include -DSYSFS_ROOT='"$(top_srcdir)/tests/unittests/sysfs_mock"' mtdlib_test_SOURCES = tests/unittests/libmtd_test.c lib/libmtd.c lib/libmtd_legacy.c +mtdlib_test_SOURCES += tests/unittests/test_lib.h mtdlib_test_LDADD = $(CMOCKA_LIBS) mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write mtdlib_test_CPPFLAGS = -O0 -D_GNU_SOURCE --std=gnu99 $(CMOCKA_CFLAGS) -I$(top_srcdir)/lib/ -I$(top_srcdir)/include -DSYSFS_ROOT='"$(top_srcdir)/tests/unittests/sysfs_mock"' @@ -12,13 +14,7 @@ TEST_BINS = \ ubilib_test \ mtdlib_test -UNITTEST_HEADER = \ - tests/unittests/test_lib.h - -UNITTEST_EXTRA = \ - tests/unittests/sysfs_mock - -EXTRA_DIST += $(UNITTEST_HEADER) $(UNITTEST_EXTRA) +EXTRA_DIST += tests/unittests/sysfs_mock TESTS += $(TEST_BINS) check_PROGRAMS += $(TEST_BINS) |