From 8a00021b2ab5529640e5acaca30a27cdaca04178 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 Jul 2016 16:10:28 +0200 Subject: Integrate tests into autotools build system 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 Signed-off-by: Richard Weinberger --- tests/Makefile | 8 -- tests/checkfs/Makefile | 5 - tests/checkfs/Makemodule.am | 22 ++++ tests/fs-tests/Makefile | 8 -- tests/fs-tests/Makemodule.am | 86 +++++++++++++ tests/fs-tests/fs_help_all.sh.in | 33 +++++ tests/fs-tests/fs_run_all.sh.in | 51 ++++++++ tests/fs-tests/help_all.sh | 27 ---- tests/fs-tests/integrity/Makefile | 31 ----- tests/fs-tests/lib/Makefile | 18 --- tests/fs-tests/run_all.sh | 49 -------- tests/fs-tests/simple/Makefile | 30 ----- tests/fs-tests/stress/Makefile | 11 -- tests/fs-tests/stress/atoms/Makefile | 40 ------ tests/fs-tests/stress/fs_stress00.sh.in | 58 +++++++++ tests/fs-tests/stress/fs_stress01.sh.in | 46 +++++++ tests/fs-tests/stress/stress00.sh | 52 -------- tests/fs-tests/stress/stress01.sh | 40 ------ tests/fs-tests/utils/Makefile | 19 --- tests/jittertest/Makefile | 46 ------- tests/jittertest/Makemodule.am | 24 ++++ tests/ubi-tests/Makefile | 24 ---- tests/ubi-tests/Makefile.am | 7 -- tests/ubi-tests/Makemodule.am | 68 ++++++++++ tests/ubi-tests/runtests.sh | 36 ------ tests/ubi-tests/runubitests.sh.in | 42 +++++++ tests/ubi-tests/stress-test.sh | 212 ------------------------------- tests/ubi-tests/ubi-stress-test.sh.in | 215 ++++++++++++++++++++++++++++++++ 28 files changed, 645 insertions(+), 663 deletions(-) delete mode 100644 tests/Makefile delete mode 100644 tests/checkfs/Makefile create mode 100644 tests/checkfs/Makemodule.am delete mode 100644 tests/fs-tests/Makefile create mode 100644 tests/fs-tests/Makemodule.am create mode 100755 tests/fs-tests/fs_help_all.sh.in create mode 100755 tests/fs-tests/fs_run_all.sh.in delete mode 100755 tests/fs-tests/help_all.sh delete mode 100644 tests/fs-tests/integrity/Makefile delete mode 100644 tests/fs-tests/lib/Makefile delete mode 100755 tests/fs-tests/run_all.sh delete mode 100644 tests/fs-tests/simple/Makefile delete mode 100644 tests/fs-tests/stress/Makefile delete mode 100644 tests/fs-tests/stress/atoms/Makefile create mode 100755 tests/fs-tests/stress/fs_stress00.sh.in create mode 100755 tests/fs-tests/stress/fs_stress01.sh.in delete mode 100755 tests/fs-tests/stress/stress00.sh delete mode 100755 tests/fs-tests/stress/stress01.sh delete mode 100644 tests/fs-tests/utils/Makefile delete mode 100644 tests/jittertest/Makefile create mode 100644 tests/jittertest/Makemodule.am delete mode 100644 tests/ubi-tests/Makefile delete mode 100644 tests/ubi-tests/Makefile.am create mode 100644 tests/ubi-tests/Makemodule.am delete mode 100755 tests/ubi-tests/runtests.sh create mode 100755 tests/ubi-tests/runubitests.sh.in delete mode 100755 tests/ubi-tests/stress-test.sh create mode 100755 tests/ubi-tests/ubi-stress-test.sh.in (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 05b37e9..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -SUBDIRS = checkfs fs-tests jittertest ubi-tests - -all clean tests: $(SUBDIRS) - -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -C $@ $(MAKECMDGOALS) diff --git a/tests/checkfs/Makefile b/tests/checkfs/Makefile deleted file mode 100644 index 14a83d4..0000000 --- a/tests/checkfs/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -TARGETS = checkfs makefiles - -include ../../common.mk - -$(TARGETS): $(addprefix $(BUILDDIR)/, comm.o) diff --git a/tests/checkfs/Makemodule.am b/tests/checkfs/Makemodule.am new file mode 100644 index 0000000..f4e9225 --- /dev/null +++ b/tests/checkfs/Makemodule.am @@ -0,0 +1,22 @@ +checkfs_SOURCES = tests/checkfs/checkfs.c tests/checkfs/comm.c +checkfs_CPPFLAGS = $(AM_CPPFLAGS) + +makefiles_SOURCES = tests/checkfs/makefiles.c tests/checkfs/comm.c +makefiles_CPPFLAGS = $(AM_CPPFLAGS) + +CHECKFS_BINS = \ + makefiles checkfs + +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 diff --git a/tests/fs-tests/Makefile b/tests/fs-tests/Makefile deleted file mode 100644 index d188796..0000000 --- a/tests/fs-tests/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -SUBDIRS = lib simple stress integrity utils - -all clean tests: $(SUBDIRS) - -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -C $@ $(MAKECMDGOALS) diff --git a/tests/fs-tests/Makemodule.am b/tests/fs-tests/Makemodule.am new file mode 100644 index 0000000..031355a --- /dev/null +++ b/tests/fs-tests/Makemodule.am @@ -0,0 +1,86 @@ +integck_SOURCES = tests/fs-tests/integrity/integck.c +integck_LDADD = libubi.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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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 = \ + 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 = \ + 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 new file mode 100755 index 0000000..39219b2 --- /dev/null +++ b/tests/fs-tests/fs_help_all.sh.in @@ -0,0 +1,33 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +echo ------------------------------------------------------------------------------- +$TESTBINDIR/test_1 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/test_2 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/stress_1 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/stress_2 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/stress_3 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/fwrite00 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/gcd_hupper -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/pdfrun -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/rmdir00 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/rndrm00 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/rndwrite00 -h +echo ------------------------------------------------------------------------------- +$TESTBINDIR/integck -h +echo ------------------------------------------------------------------------------- diff --git a/tests/fs-tests/fs_run_all.sh.in b/tests/fs-tests/fs_run_all.sh.in new file mode 100755 index 0000000..a3676f9 --- /dev/null +++ b/tests/fs-tests/fs_run_all.sh.in @@ -0,0 +1,51 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR +if test -z "$TEST_DIR"; +then + TEST_DIR="/mnt/test_file_system" +fi + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/test_1 || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/test_2 || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/integck $TEST_DIR || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/rndrm00 -z0 || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/rmdir00 -z0 || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/stress_1 -z10000000 -e || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/stress_2 -z10000000 || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/stress_3 -z1000000000 -e || exit 1 + +rm -rf ${TEST_DIR}/* + +$TESTBINDIR/fs_stress00.sh 360 || exit 1 + +$TESTBINDIR/fs_stress01.sh 360 || exit 1 diff --git a/tests/fs-tests/help_all.sh b/tests/fs-tests/help_all.sh deleted file mode 100755 index 34b890b..0000000 --- a/tests/fs-tests/help_all.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -echo ------------------------------------------------------------------------------- -./simple/test_1 -h -echo ------------------------------------------------------------------------------- -./simple/test_2 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/stress_1 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/stress_2 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/stress_3 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/fwrite00 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/gcd_hupper -h -echo ------------------------------------------------------------------------------- -./stress/atoms/pdfrun -h -echo ------------------------------------------------------------------------------- -./stress/atoms/rmdir00 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/rndrm00 -h -echo ------------------------------------------------------------------------------- -./stress/atoms/rndwrite00 -h -echo ------------------------------------------------------------------------------- -./integrity/integck -h -echo ------------------------------------------------------------------------------- diff --git a/tests/fs-tests/integrity/Makefile b/tests/fs-tests/integrity/Makefile deleted file mode 100644 index b64bad9..0000000 --- a/tests/fs-tests/integrity/Makefile +++ /dev/null @@ -1,31 +0,0 @@ - -ifeq ($(origin CC),default) -CC = gcc -endif - -COMMON_HEADERS_DIR := ../../../include -LIBUBI_PATH = ../../../ubi-utils/ -LIBUBI_HEADER_PATH = $(LIBUBI_PATH)/include - -CFLAGS := $(CFLAGS) -Wall -g -O2 -I$(COMMON_HEADERS_DIR) -I$(LIBUBI_HEADER_PATH) - -LDFLAGS := $(LDFLAGS) - -TARGETS = integck - -all: $(TARGETS) - -# Compile ubilib -libubi.a: - $(CC) $(CFLAGS) -c $(LIBUBI_PATH)/libubi.c -o libubi.o - $(AR) cr libubi.a libubi.o - -$(TARGETS): libubi.a - -# Disable optimizations to make it possible to use gdb comfortably -# Use -rdynamic to have stack backtraces -debug: libubi.a - $(CC) $(CFLAGS) -O0 -D INTEGCK_DEBUG -rdynamic integck.c libubi.a -o integck - -clean: - rm -f *.o $(TARGETS) libubi.a diff --git a/tests/fs-tests/lib/Makefile b/tests/fs-tests/lib/Makefile deleted file mode 100644 index 8d57824..0000000 --- a/tests/fs-tests/lib/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -ifeq ($(origin CC),default) -CC = gcc -endif - -CFLAGS := $(CFLAGS) -Wall -g -O2 - -LDFLAGS := $(LDFLAGS) - -all: tests.o - -tests.o: tests.h - -clean: - rm -f *.o - -tests: - echo diff --git a/tests/fs-tests/run_all.sh b/tests/fs-tests/run_all.sh deleted file mode 100755 index 7c82f9a..0000000 --- a/tests/fs-tests/run_all.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR -if test -z "$TEST_DIR"; -then - TEST_DIR="/mnt/test_file_system" -fi - -rm -rf ${TEST_DIR}/* - -./simple/test_1 || exit 1 - -rm -rf ${TEST_DIR}/* - -./simple/test_2 || exit 1 - -rm -rf ${TEST_DIR}/* - -./integrity/integck $TEST_DIR || exit 1 - -rm -rf ${TEST_DIR}/* - -./stress/atoms/rndrm00 -z0 || exit 1 - -rm -rf ${TEST_DIR}/* - -./stress/atoms/rmdir00 -z0 || exit 1 - -rm -rf ${TEST_DIR}/* - -./stress/atoms/stress_1 -z10000000 -e || exit 1 - -rm -rf ${TEST_DIR}/* - -./stress/atoms/stress_2 -z10000000 || exit 1 - -rm -rf ${TEST_DIR}/* - -./stress/atoms/stress_3 -z1000000000 -e || exit 1 - -rm -rf ${TEST_DIR}/* - -cd stress || exit 1 - -./stress00.sh 360 || exit 1 - -./stress01.sh 360 || exit 1 - -cd .. || exit 1 diff --git a/tests/fs-tests/simple/Makefile b/tests/fs-tests/simple/Makefile deleted file mode 100644 index d447da3..0000000 --- a/tests/fs-tests/simple/Makefile +++ /dev/null @@ -1,30 +0,0 @@ - -ifeq ($(origin CC),default) -CC = gcc -endif - -CFLAGS := $(CFLAGS) -Wall -g -O2 -I../lib - -LDFLAGS := $(LDFLAGS) - -TARGETS = test_1 \ - test_2 \ - ftrunc \ - orph \ - perf - -all: $(TARGETS) - -$(TARGETS): ../lib/tests.o - -../lib/tests.o: ../lib/tests.h - -clean: - rm -f *.o $(TARGETS) - -tests: all - ./test_1 --sync - ./test_2 --sync - ./ftrunc - ./orph --sync - ./perf diff --git a/tests/fs-tests/stress/Makefile b/tests/fs-tests/stress/Makefile deleted file mode 100644 index c24ff3f..0000000 --- a/tests/fs-tests/stress/Makefile +++ /dev/null @@ -1,11 +0,0 @@ - -SUBDIRS = atoms - -all tests: $(SUBDIRS) - -clean: $(SUBDIRS) - rm -rf run_pdf_test_file_* - -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -C $@ $(MAKECMDGOALS) diff --git a/tests/fs-tests/stress/atoms/Makefile b/tests/fs-tests/stress/atoms/Makefile deleted file mode 100644 index 9fbfd39..0000000 --- a/tests/fs-tests/stress/atoms/Makefile +++ /dev/null @@ -1,40 +0,0 @@ - -ifeq ($(origin CC),default) -CC = gcc -endif - -CFLAGS := $(CFLAGS) -Wall -g -O2 -I../../lib - -LDFLAGS := $(LDFLAGS) - -TARGETS = stress_1 \ - stress_2 \ - stress_3 \ - pdfrun \ - rndwrite00 \ - fwrite00 \ - rmdir00 \ - rndrm00 \ - rndrm99 \ - gcd_hupper - -all: $(TARGETS) - -$(TARGETS): ../../lib/tests.o - -../lib/tests.o: ../../lib/tests.h - -clean: - rm -f *.o $(TARGETS) run_pdf_test_file - -tests: all - ./stress_1 -e - ./stress_2 - ./stress_3 -e - ./pdfrun - ./rndwrite00 -e - ./fwrite00 - ./rmdir00 - ./rndrm00 - ./rndrm99 - ./gcd_hupper diff --git a/tests/fs-tests/stress/fs_stress00.sh.in b/tests/fs-tests/stress/fs_stress00.sh.in new file mode 100755 index 0000000..85ec7a2 --- /dev/null +++ b/tests/fs-tests/stress/fs_stress00.sh.in @@ -0,0 +1,58 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR +if test -z "$TEST_DIR"; +then + TEST_DIR="/mnt/test_file_system" +fi + +FREESPACE=`$TESTBINDIR/free_space "$TEST_DIR"` + +if test -z "$FREESPACE"; +then + echo "Failed to determine free space" + exit 1 +fi + +if test -n "$1"; +then + DURATION="-d$1"; +else + DURATION=""; +fi + +FWRITE00=$TESTBINDIR/fwrite00 +RNDWR=$TESTBINDIR/rndwrite00 +GCHUP=$TESTBINDIR/gcd_hupper +PDFLUSH=$TESTBINDIR/pdfrun +FSIZE=$(( $FREESPACE/15 )); + +$TESTBINDIR/fstest_monitor $DURATION \ +"$FWRITE00 -z $FSIZE -n0 -p 20" \ +"$FWRITE00 -z $FSIZE -n0 -p 10 -s" \ +"$FWRITE00 -z $FSIZE -n0 -p 20 -u" \ +"$FWRITE00 -z $FSIZE -n0 -p 70 -o" \ +"$FWRITE00 -z $FSIZE -n0 -p 15 -s -o -u" \ +"$FWRITE00 -z $FSIZE -n0 -p 10 -u -c" \ +"$FWRITE00 -z $FSIZE -n0 -p 10 -u -o -c" \ +"$FWRITE00 -z $FSIZE -n0 -p 10 -o -c" \ +"$FWRITE00 -z $FSIZE -n0 -p 100 -o -u" \ +"$FWRITE00 -z $FSIZE -n0 -p 100 -s -o -u -c" \ +"$FWRITE00 -z $FSIZE -n0 -p 100 -o -u" \ +"$FWRITE00 -z $FSIZE -n0 -p 100 -u" \ +"$FWRITE00 -z $FSIZE -n0 -p 100 -s -o" \ +"$RNDWR -z $FSIZE -n0 -p 10 -e" \ +"$RNDWR -z $FSIZE -n0 -p 100 -e" \ +"$PDFLUSH -z 1073741824 -n0" + +STATUS=$? + +rm -rf ${TEST_DIR}/* + +exit $STATUS diff --git a/tests/fs-tests/stress/fs_stress01.sh.in b/tests/fs-tests/stress/fs_stress01.sh.in new file mode 100755 index 0000000..d0ea8f9 --- /dev/null +++ b/tests/fs-tests/stress/fs_stress01.sh.in @@ -0,0 +1,46 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR +if test -z "$TEST_DIR"; +then + TEST_DIR="/mnt/test_file_system" +fi + +FREESPACE=`$TESTBINDIR/free_space "$TEST_DIR"` + +if test -z "$FREESPACE"; +then + echo "Failed to determine free space" + exit 1 +fi + +if test -n "$1"; +then + DURATION="-d$1"; +else + DURATION=""; +fi + +FWRITE00=$TESTBINDIR/fwrite00 +RNDWR=$TESTBINDIR/rndwrite00 +PDFLUSH=$TESTBINDIR/pdfrun +FSIZE=$(( $FREESPACE/15 )); + +$TESTBINDIR/fstest_monitor $DURATION \ +"$FWRITE00 -z $FSIZE -n0 -p 300" \ +"$FWRITE00 -z $FSIZE -n0 -u" \ +"$FWRITE00 -z $FSIZE -n0 -u -c" \ +"$FWRITE00 -z $FSIZE -n0 -s -o" \ +"$RNDWR -z $FSIZE -n0 -e" + +STATUS=$? + +rm -rf ${TEST_DIR}/* + +exit $STATUS diff --git a/tests/fs-tests/stress/stress00.sh b/tests/fs-tests/stress/stress00.sh deleted file mode 100755 index 60f8c0d..0000000 --- a/tests/fs-tests/stress/stress00.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR -if test -z "$TEST_DIR"; -then - TEST_DIR="/mnt/test_file_system" -fi - -FREESPACE=`../utils/free_space "$TEST_DIR"` - -if test -z "$FREESPACE"; -then - echo "Failed to determine free space" - exit 1 -fi - -if test -n "$1"; -then - DURATION="-d$1"; -else - DURATION=""; -fi - -FWRITE00=atoms/fwrite00 -RNDWR=atoms/rndwrite00 -GCHUP=atoms/gcd_hupper -PDFLUSH=atoms/pdfrun -FSIZE=$(( $FREESPACE/15 )); - -../utils/fstest_monitor $DURATION \ -"$FWRITE00 -z $FSIZE -n0 -p 20" \ -"$FWRITE00 -z $FSIZE -n0 -p 10 -s" \ -"$FWRITE00 -z $FSIZE -n0 -p 20 -u" \ -"$FWRITE00 -z $FSIZE -n0 -p 70 -o" \ -"$FWRITE00 -z $FSIZE -n0 -p 15 -s -o -u" \ -"$FWRITE00 -z $FSIZE -n0 -p 10 -u -c" \ -"$FWRITE00 -z $FSIZE -n0 -p 10 -u -o -c" \ -"$FWRITE00 -z $FSIZE -n0 -p 10 -o -c" \ -"$FWRITE00 -z $FSIZE -n0 -p 100 -o -u" \ -"$FWRITE00 -z $FSIZE -n0 -p 100 -s -o -u -c" \ -"$FWRITE00 -z $FSIZE -n0 -p 100 -o -u" \ -"$FWRITE00 -z $FSIZE -n0 -p 100 -u" \ -"$FWRITE00 -z $FSIZE -n0 -p 100 -s -o" \ -"$RNDWR -z $FSIZE -n0 -p 10 -e" \ -"$RNDWR -z $FSIZE -n0 -p 100 -e" \ -"$PDFLUSH -z 1073741824 -n0" - -STATUS=$? - -rm -rf ${TEST_DIR}/* - -exit $STATUS diff --git a/tests/fs-tests/stress/stress01.sh b/tests/fs-tests/stress/stress01.sh deleted file mode 100755 index 5913c1c..0000000 --- a/tests/fs-tests/stress/stress01.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR -if test -z "$TEST_DIR"; -then - TEST_DIR="/mnt/test_file_system" -fi - -FREESPACE=`../utils/free_space "$TEST_DIR"` - -if test -z "$FREESPACE"; -then - echo "Failed to determine free space" - exit 1 -fi - -if test -n "$1"; -then - DURATION="-d$1"; -else - DURATION=""; -fi - -FWRITE00=atoms/fwrite00 -RNDWR=atoms/rndwrite00 -PDFLUSH=atoms/pdfrun -FSIZE=$(( $FREESPACE/15 )); - -../utils/fstest_monitor $DURATION \ -"$FWRITE00 -z $FSIZE -n0 -p 300" \ -"$FWRITE00 -z $FSIZE -n0 -u" \ -"$FWRITE00 -z $FSIZE -n0 -u -c" \ -"$FWRITE00 -z $FSIZE -n0 -s -o" \ -"$RNDWR -z $FSIZE -n0 -e" - -STATUS=$? - -rm -rf ${TEST_DIR}/* - -exit $STATUS diff --git a/tests/fs-tests/utils/Makefile b/tests/fs-tests/utils/Makefile deleted file mode 100644 index 9fb60b5..0000000 --- a/tests/fs-tests/utils/Makefile +++ /dev/null @@ -1,19 +0,0 @@ - -ifeq ($(origin CC),default) -CC = gcc -endif - -CFLAGS := $(CFLAGS) -Wall -g -O2 -I../lib - -LDFLAGS := $(LDFLAGS) - -TARGETS = fstest_monitor free_space - -all: $(TARGETS) - -clean: - rm -f *.o $(TARGETS) - -tests: all - ./fstest_monitor - ./free_space > /dev/null diff --git a/tests/jittertest/Makefile b/tests/jittertest/Makefile deleted file mode 100644 index 0209c63..0000000 --- a/tests/jittertest/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -CC=gcc -# uncomment following for performance -CCFLAGS=-O3 -Wall -fomit-frame-pointer - -# uncomment following for debugging. Uncomment either this or the one above. Not both. -# CCFLAGS=-Wall -g - - -all: JitterTest plotJittervsFill - -JitterTest: JitterTest.c Makefile - gcc $(CCFLAGS) -lm JitterTest.c -o JitterTest - -plotJittervsFill: plotJittervsFill.c Makefile - gcc $(CCFLAGS) plotJittervsFill.c -o plotJittervsFill - -clean: - rm -rf *~ - rm -rf core - rm -rf *.o - rm -rf JitterTest - - -dep: - makedepend -I./ *.c -# DO NOT DELETE - -JitterTest.o: /usr/include/stdio.h /usr/include/features.h -JitterTest.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h -JitterTest.o: /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h -JitterTest.o: /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h -JitterTest.o: /usr/include/bits/types.h /usr/include/libio.h -JitterTest.o: /usr/include/_G_config.h /usr/include/bits/stdio_lim.h -JitterTest.o: /usr/include/string.h /usr/include/stdlib.h -JitterTest.o: /usr/include/sys/types.h /usr/include/time.h -JitterTest.o: /usr/include/endian.h /usr/include/bits/endian.h -JitterTest.o: /usr/include/sys/select.h /usr/include/bits/select.h -JitterTest.o: /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h -JitterTest.o: /usr/include/alloca.h /usr/include/sys/time.h -JitterTest.o: /usr/include/bits/time.h /usr/include/signal.h -JitterTest.o: /usr/include/bits/signum.h /usr/include/bits/siginfo.h -JitterTest.o: /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h -JitterTest.o: /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h -JitterTest.o: /usr/include/sched.h /usr/include/bits/sched.h -JitterTest.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h -JitterTest.o: /usr/include/bits/confname.h /usr/include/getopt.h diff --git a/tests/jittertest/Makemodule.am b/tests/jittertest/Makemodule.am new file mode 100644 index 0000000..d4cc121 --- /dev/null +++ b/tests/jittertest/Makemodule.am @@ -0,0 +1,24 @@ +JitterTest_SOURCES = tests/jittertest/JitterTest.c +JitterTest_CPPFLAGS = $(AM_CPPFLAGS) + +plotJittervsFill_SOURCES = tests/jittertest/plotJittervsFill.c +plotJittervsFill_CPPFLAGS = $(AM_CPPFLAGS) + +JITTEREST_BINS = \ + JitterTest plotJittervsFill + +JITTERTEST_SH = \ + 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 diff --git a/tests/ubi-tests/Makefile b/tests/ubi-tests/Makefile deleted file mode 100644 index c434a6f..0000000 --- a/tests/ubi-tests/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -LIBUBI_PATH = ../../ubi-utils/ -LIBUBI_HEADER_PATH = $(LIBUBI_PATH)/include -UBIUTILS_PATH=../../ubi-utils/ - -KERNELHDR := ../../include - -LIBS = libubi -TARGETS=io_update volrefcnt integ io_paral io_read io_basic \ - mkvol_basic mkvol_bad mkvol_paral rsvol - -CFLAGS += -I$(LIBUBI_HEADER_PATH) -I $(KERNELHDR) -LDLIBS += -lpthread - -include ../../common.mk - -# Compile ubilib with the udevsettle hack -libubi.a: $(LIBUBI_PATH)/libubi.c $(LIBUBI_HEADER_PATH)/libubi.h $(LIBUBI_PATH)/libubi_int.h - $(CC) $(CFLAGS) -I $(LIBUBI_PATH) -I../../include -DUDEV_SETTLE_HACK -c $(LIBUBI_PATH)/libubi.c -o libubi.o - ar cr libubi.a libubi.o - -$(TARGETS): $(addprefix $(BUILDDIR)/, helpers.o) libubi.a - -clean:: - rm -f libubi.a diff --git a/tests/ubi-tests/Makefile.am b/tests/ubi-tests/Makefile.am deleted file mode 100644 index d57316a..0000000 --- a/tests/ubi-tests/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -io_basic_SOURCES = io_basic.c helpers.c -io_basic_LDADD = libmtd.a libubi.a -io_basic_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include - -UBITEST_BINS = io_basic - -noinst_PROGRAMS += $(UBITEST_BINS) diff --git a/tests/ubi-tests/Makemodule.am b/tests/ubi-tests/Makemodule.am new file mode 100644 index 0000000..805aeaf --- /dev/null +++ b/tests/ubi-tests/Makemodule.am @@ -0,0 +1,68 @@ +io_basic_SOURCES = tests/ubi-tests/io_basic.c tests/ubi-tests/helpers.c +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_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_LDADD = libubi.a $(PTHREAD_LIBS) +io_paral_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include + +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_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_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_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_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_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_LDADD = libubi.a $(PTHREAD_LIBS) +mkvol_paral_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include + +mkvol_paral_LDADD += $(PTHREAD_CFLAGS) +mkvol_paral_CPPFLAGS += $(PTHREAD_CFLAGS) + +rsvol_SOURCES = tests/ubi-tests/rsvol.c tests/ubi-tests/helpers.c +rsvol_LDADD = libubi.a +rsvol_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include + +UBITEST_BINS = \ + io_basic io_update io_paral io_read volrefcnt integ \ + mkvol_basic mkvol_bad mkvol_paral rsvol + +UBITEST_SH = \ + tests/ubi-tests/runubitests.sh tests/ubi-tests/ubi-stress-test.sh + +UBITEST_HEADER = \ + tests/ubi-tests/helpers.h + +UBITEST_EXTRA = \ + tests/ubi-tests/README.udev + +EXTRA_DIST += $(UBITEST_EXTRA) $(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/runtests.sh b/tests/ubi-tests/runtests.sh deleted file mode 100755 index 539ef9d..0000000 --- a/tests/ubi-tests/runtests.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -euf - -tests="mkvol_basic mkvol_bad mkvol_paral rsvol io_basic io_read io_update io_paral volrefcnt" - -fatal() -{ - echo "Error: $1" 1>&2 - echo "FAILURE" - exit 1 -} - -usage() -{ - cat 1>&2 < -Example: - ${0##*/} /dev/ubi1 - test /dev/ubi1. -EOF -} - -if [ "$#" -lt 1 ]; then - usage - exit 1 -fi - -ubidev="$1" -[ -c "$ubidev" ] || fatal "$ubidev is not character device" - -for t in $tests; do - echo "Running $t $ubidev" - "./$t" "$ubidev" || fatal "$t failed" -done - -echo "SUCCESS" diff --git a/tests/ubi-tests/runubitests.sh.in b/tests/ubi-tests/runubitests.sh.in new file mode 100755 index 0000000..a1b23c4 --- /dev/null +++ b/tests/ubi-tests/runubitests.sh.in @@ -0,0 +1,42 @@ +#!/bin/sh -euf + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +tests="mkvol_basic mkvol_bad mkvol_paral rsvol io_basic io_read io_update io_paral volrefcnt" + +fatal() +{ + echo "Error: $1" 1>&2 + echo "FAILURE" + exit 1 +} + +usage() +{ + cat 1>&2 < +Example: + ${0##*/} /dev/ubi1 - test /dev/ubi1. +EOF +} + +if [ "$#" -lt 1 ]; then + usage + exit 1 +fi + +ubidev="$1" +[ -c "$ubidev" ] || fatal "$ubidev is not character device" + +for t in $tests; do + echo "Running $t $ubidev" + "$TESTBINDIR/$t" "$ubidev" || fatal "$t failed" +done + +echo "SUCCESS" diff --git a/tests/ubi-tests/stress-test.sh b/tests/ubi-tests/stress-test.sh deleted file mode 100755 index a150495..0000000 --- a/tests/ubi-tests/stress-test.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh -euf - -srcdir="$(readlink -ev -- ${0%/*})" -PATH="$srcdir:$srcdir/../..:$PATH" - -fatal() -{ - echo "Error: $1" 1>&2 - exit 1 -} - -usage() -{ - cat 1>&2 </dev/null 2>&1 ||: - rmmod nandsim >/dev/null 2>&1 ||: - rmmod mtdram >/dev/null 2>&1 ||: - - # Below is magic to exit with correct exit code - if [ "$ret" != "0" ]; then - trap false EXIT - else - trap true EXIT - fi -} -trap 'cleanup_handler $?' EXIT -trap 'cleanup_handler 1' HUP PIPE INT QUIT TERM - -# Find MTD device number by pattern in /proc/mtd -# Usage: find_mtd_device -find_mtd_device() -{ - printf "%s" "$(grep "$1" /proc/mtd | sed -e "s/^mtd\([0-9]\+\):.*$/\1/")" -} - -# Just print parameters of the 'run_test' funcion in a user-friendly form. -print_params() -{ - local module="$1"; shift - local size="$1"; shift - local peb_size="$1"; shift - local page_size="$1"; shift - local vid_offs="$1"; shift - local fastmap="$1"; shift - - printf "%s" "$module: ${size}MiB, PEB size ${peb_size}KiB, " - if [ "$module" = "nandsim" ]; then - printf "%s" "page size ${page_size}KiB, VID offset $vid_offs, " - fi - printf "%s\n" "fastmap $fastmap" -} - -# Load mtdram with specified size and PEB size -# Usage: load_mtdram -# 1. Flash size is specified in MiB -# 2. PEB size is specified in KiB -load_mtdram() -{ - local size="$1"; shift - local peb_size="$1"; shift - - size="$(($size * 1024))" - modprobe mtdram total_size="$size" erase_size="$peb_size" || - echo "Error: cannot load $size MiB mtdram" -} - -print_separator() -{ - echo "======================================================================" -} - -# Run a test on nandsim or mtdram with certain geometry. -# Usage: run_test \ -# -# 1. Simulator type (nandsim or mtdram) -# 2. Flash size is specified in MiB -# 3. PEB size is specified in KiB -# 4. Page size is specified in bytes (mtdram ingores this) -# 5. VID header offset (mtdram ingores this) -# 6. Whether fast-map should be enabled (pass "enabled" or "disabled") -run_test() -{ - local module="$1"; - local size="$2"; - local peb_size="$3"; - local page_size="$4"; - local vid_offs="$5" - local fastmap="$6"; - local fm_supported fm_param mtdnum - - print_separator - - # Check if fastmap is supported by UBI - if modinfo ubi | grep -q fm_auto; then - fm_supported="yes" - else - fm_supported="no" - fi - - if [ "$fastmap" = "enabled" ]; then - fm_param= - elif [ "$fm_supported" = "yes" ]; then - fastmap="disabled" - fm_param="fm_auto" - else - echo "Fastmap is not supported, skip" - return 0 - fi - - if [ "$module" = "nandsim" ]; then - print_params "$@" - - load_nandsim.sh "$size" "$peb_size" "$page_size" || - echo "Cannot load nandsim, test skipped" - - mtdnum="$(find_mtd_device "$nandsim_patt")" - elif [ "$module" = "mtdram" ]; then - print_params "$@" - - load_mtdram "$size" "$peb_size" - - mtdnum="$(find_mtd_device "$mtdram_patt")" - else - fatal "$module is not supported" || - echo "Cannot load nandsim, test skipped" - fi - - modprobe ubi mtd="$mtdnum,$vid_offs" $fm_param - runtests.sh /dev/ubi0 ||: - - sudo rmmod ubi - sudo rmmod "$module" -} - -if [ "$#" -lt 1 ] || [ "$1" != "run" ]; then - usage - exit 1 -fi - -# Make sure neither mtdram nor nandsim are used -nandsim_patt="NAND simulator" -mtdram_patt="mtdram test device" -if [ -e /proc/mtd ]; then - ! grep -q "$nandsim_patt" /proc/mtd || - fatal "the nandsim driver is already used" - ! grep -q "$mtdram_patt" /proc/mtd || - fatal "the mtdram driver is already used" -fi - -rmmod ubi >/dev/null 2>&1 ||: - -for module in "mtdram" "nandsim"; do - for fm in "enabled" "disabled"; do - for vid_factor in 1 0; do - print_separator - print_separator - print_separator - echo "Test on $module, fastmap $fm, VID header offset factor $vid_factor" - print_separator - print_separator - - pg_size="512" - vid_offs="$(($pg_size * $vid_factor))" - - run_test "$module" "16" "16" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "32" "16" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "64" "16" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "128" "16" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "256" "16" "$pg_size" "$vid_offs" "$fm" - - pg_size="2048" - vid_offs="$(($pg_size * $vid_factor))" - - run_test "$module" "64" "64" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "128" "64" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "256" "64" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "512" "64" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "1024" "64" "$pg_size" "$vid_offs" "$fm" - - run_test "$module" "64" "128" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "128" "128" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "256" "128" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "512" "128" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "1024" "128" "$pg_size" "$vid_offs" "$fm" - - run_test "$module" "64" "256" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "128" "256" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "256" "256" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "512" "256" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "1024" "256" "$pg_size" "$vid_offs" "$fm" - - run_test "$module" "64" "512" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "128" "512" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "256" "512" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "512" "512" "$pg_size" "$vid_offs" "$fm" - run_test "$module" "1024" "512" "$pg_size" "$vid_offs" "$fm" - done - done -done diff --git a/tests/ubi-tests/ubi-stress-test.sh.in b/tests/ubi-tests/ubi-stress-test.sh.in new file mode 100755 index 0000000..42ccec5 --- /dev/null +++ b/tests/ubi-tests/ubi-stress-test.sh.in @@ -0,0 +1,215 @@ +#!/bin/sh -euf + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libexecpath=@libexecdir@/mtd-utils +TESTBINDIR=@testbindir@ + +fatal() +{ + echo "Error: $1" 1>&2 + exit 1 +} + +usage() +{ + cat 1>&2 </dev/null 2>&1 ||: + rmmod nandsim >/dev/null 2>&1 ||: + rmmod mtdram >/dev/null 2>&1 ||: + + # Below is magic to exit with correct exit code + if [ "$ret" != "0" ]; then + trap false EXIT + else + trap true EXIT + fi +} +trap 'cleanup_handler $?' EXIT +trap 'cleanup_handler 1' HUP PIPE INT QUIT TERM + +# Find MTD device number by pattern in /proc/mtd +# Usage: find_mtd_device +find_mtd_device() +{ + printf "%s" "$(grep "$1" /proc/mtd | sed -e "s/^mtd\([0-9]\+\):.*$/\1/")" +} + +# Just print parameters of the 'run_test' funcion in a user-friendly form. +print_params() +{ + local module="$1"; shift + local size="$1"; shift + local peb_size="$1"; shift + local page_size="$1"; shift + local vid_offs="$1"; shift + local fastmap="$1"; shift + + printf "%s" "$module: ${size}MiB, PEB size ${peb_size}KiB, " + if [ "$module" = "nandsim" ]; then + printf "%s" "page size ${page_size}KiB, VID offset $vid_offs, " + fi + printf "%s\n" "fastmap $fastmap" +} + +# Load mtdram with specified size and PEB size +# Usage: load_mtdram +# 1. Flash size is specified in MiB +# 2. PEB size is specified in KiB +load_mtdram() +{ + local size="$1"; shift + local peb_size="$1"; shift + + size="$(($size * 1024))" + modprobe mtdram total_size="$size" erase_size="$peb_size" || + echo "Error: cannot load $size MiB mtdram" +} + +print_separator() +{ + echo "======================================================================" +} + +# Run a test on nandsim or mtdram with certain geometry. +# Usage: run_test \ +# +# 1. Simulator type (nandsim or mtdram) +# 2. Flash size is specified in MiB +# 3. PEB size is specified in KiB +# 4. Page size is specified in bytes (mtdram ingores this) +# 5. VID header offset (mtdram ingores this) +# 6. Whether fast-map should be enabled (pass "enabled" or "disabled") +run_test() +{ + local module="$1"; + local size="$2"; + local peb_size="$3"; + local page_size="$4"; + local vid_offs="$5" + local fastmap="$6"; + local fm_supported fm_param mtdnum + + print_separator + + # Check if fastmap is supported by UBI + if modinfo ubi | grep -q fm_auto; then + fm_supported="yes" + else + fm_supported="no" + fi + + if [ "$fastmap" = "enabled" ]; then + fm_param= + elif [ "$fm_supported" = "yes" ]; then + fastmap="disabled" + fm_param="fm_auto" + else + echo "Fastmap is not supported, skip" + return 0 + fi + + if [ "$module" = "nandsim" ]; then + print_params "$@" + + $TESTBINDIR/load_nandsim.sh "$size" "$peb_size" "$page_size" || + echo "Cannot load nandsim, test skipped" + + mtdnum="$(find_mtd_device "$nandsim_patt")" + elif [ "$module" = "mtdram" ]; then + print_params "$@" + + load_mtdram "$size" "$peb_size" + + mtdnum="$(find_mtd_device "$mtdram_patt")" + else + fatal "$module is not supported" || + echo "Cannot load nandsim, test skipped" + fi + + modprobe ubi mtd="$mtdnum,$vid_offs" $fm_param + $TESTBINDIR/runubitests.sh /dev/ubi0 ||: + + sudo rmmod ubi + sudo rmmod "$module" +} + +if [ "$#" -lt 1 ] || [ "$1" != "run" ]; then + usage + exit 1 +fi + +# Make sure neither mtdram nor nandsim are used +nandsim_patt="NAND simulator" +mtdram_patt="mtdram test device" +if [ -e /proc/mtd ]; then + ! grep -q "$nandsim_patt" /proc/mtd || + fatal "the nandsim driver is already used" + ! grep -q "$mtdram_patt" /proc/mtd || + fatal "the mtdram driver is already used" +fi + +rmmod ubi >/dev/null 2>&1 ||: + +for module in "mtdram" "nandsim"; do + for fm in "enabled" "disabled"; do + for vid_factor in 1 0; do + print_separator + print_separator + print_separator + echo "Test on $module, fastmap $fm, VID header offset factor $vid_factor" + print_separator + print_separator + + pg_size="512" + vid_offs="$(($pg_size * $vid_factor))" + + run_test "$module" "16" "16" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "32" "16" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "64" "16" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "128" "16" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "256" "16" "$pg_size" "$vid_offs" "$fm" + + pg_size="2048" + vid_offs="$(($pg_size * $vid_factor))" + + run_test "$module" "64" "64" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "128" "64" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "256" "64" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "512" "64" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "1024" "64" "$pg_size" "$vid_offs" "$fm" + + run_test "$module" "64" "128" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "128" "128" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "256" "128" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "512" "128" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "1024" "128" "$pg_size" "$vid_offs" "$fm" + + run_test "$module" "64" "256" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "128" "256" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "256" "256" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "512" "256" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "1024" "256" "$pg_size" "$vid_offs" "$fm" + + run_test "$module" "64" "512" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "128" "512" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "256" "512" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "512" "512" "$pg_size" "$vid_offs" "$fm" + run_test "$module" "1024" "512" "$pg_size" "$vid_offs" "$fm" + done + done +done -- cgit v1.2.3