]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: move ubi_jffs2_test.sh to better place
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 23 Dec 2007 18:31:23 +0000 (20:31 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 23 Dec 2007 18:31:23 +0000 (20:31 +0200)
... to tests/ubi-tests/

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/ubi-tests/Makefile
tests/ubi-tests/helpers/ubiupdatevol.c [moved from ubi-utils/src/ubiupdatevol.c with 98% similarity]
tests/ubi-tests/io_update.c
tests/ubi-tests/ubi_jffs2_test.sh [moved from ubi-utils/scripts/ubi_jffs2_test.sh with 89% similarity]
ubi-utils/Makefile

index a2a49d0e46a33fb919968ec1ba912189909e2f5d..a15d93cdb1337c6fbc6c408794d0cc6807cfba6d 100644 (file)
@@ -1,41 +1,47 @@
-UBIUTILS=../../ubi-utils
-INCLUDE1=$(UBIUTILS)/inc
-INCLUDE2=../../include
-LIB=.
+LIBUBI_PATH=../../ubi-utils/
+LIBUBI_SRC_PATH=../../ubi-utils/src
+LIBUBI_HEADER_PATH=../../ubi-utils/inc
+UBIUTILS_PATH=../../ubi-utils/
 
 CC := $(CROSS)gcc
 
-ALL_FILES=libubi io_update rmvol integ
-ALL_FILES+=io_paral io_read io_basic mkvol_basic mkvol_bad mkvol_paral rsvol
+TESTS=io_update rmvol integ io_paral io_read io_basic \
+          mkvol_basic mkvol_bad mkvol_paral rsvol
 
-CFLAGS += -Wall -I$(INCLUDE1) -I$(INCLUDE2) -L$(LIB) -ggdb
+HELPER_NAMES=ubiupdatevol
+HELPERS=$(addprefix helpers/, $(HELPER_NAMES))
 
-all: $(ALL_FILES)
+# Because of implicite rules we use make treats .o files as intermediate, thus
+# it removes the. If you want to prevent the removal, uncomment the below
+#.SECONDARY: $(addsuffix .o, $(TESTS)) $(addsuffix .o, $(HELPERS))
 
-libubi: $(UBIUTILS)/src/libubi.c  $(UBIUTILS)/inc/libubi.h  $(UBIUTILS)/src/libubi_int.h
-       $(CC) $(CFLAGS) -DUDEV_SETTLE_HACK -c $(UBIUTILS)/src/libubi.c -o libubi.o
+CFLAGS += -Wall -I$(LIBUBI_HEADER_PATH) -L $(LIBUBI_PATH) -O0 -ggdb
+
+all: ubi-utils libubi $(TESTS) $(HELPERS)
+
+# Compile ubilib with the udevsettle hack
+libubi: $(LIBUBI_SRC_PATH)/libubi.c  $(LIBUBI_HEADER_PATH)/libubi.h  $(LIBUBI_SRC_PATH)/libubi_int.h
+       $(CC) $(CFLAGS) -I $(LIBUBI_SRC_PATH) -DUDEV_SETTLE_HACK -c $(LIBUBI_SRC_PATH)/libubi.c -o libubi.o
        ar cr libubi.a libubi.o
 
-io_paral: io_paral.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -lpthread -o $@
-io_update: io_update.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-io_read: io_read.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-io_basic: io_basic.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-mkvol_basic: mkvol_basic.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-mkvol_bad: mkvol_bad.c common.c
+# The below cancels existing implicite rule to make programs from .c files,
+# in order to force make using our rule defined below
+%: %.c
+
+# The below is the rule to get an .o file from a .c file
+%.o: %.c
+       $(CC) $(CFLAGS) $< -c -o $@
+
+# And the below is the rule to get final test executable from its .o and common.o
+%: %.o common.o
        $(CC) $(CFLAGS) $^ -lubi -o $@
-mkvol_paral: mkvol_paral.c common.c
+
+# *paral tests require libpthread, thus the below rule for them
+%paral: %paral.o common.o
        $(CC) $(CFLAGS) $^ -lubi -lpthread -o $@
-rsvol: rsvol.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-rmvol: rmvol.c common.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-integ: integ.c
-       $(CC) $(CFLAGS) $^ -lubi -o $@
+
+ubi-utils:
+       make -C $(UBIUTILS_PATH)
 
 clean:
-       rm -rf $(ALL_FILES) $(addsuffix .o, $(ALL_FILES))
+       rm -f $(TESTS) $(addsuffix .o, $(TESTS)) libubi.* $(HELPERS) $(addsuffix .o, $(HELPERS))
similarity index 98%
rename from ubi-utils/src/ubiupdatevol.c
rename to tests/ubi-tests/helpers/ubiupdatevol.c
index 807b9616bcde8da19fec17a58e72687b5e718a78..6863e2a2b755ce0d99d7b59a219bd0c883d386cc 100644 (file)
@@ -39,7 +39,6 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-#include <config.h>
 #include <libubi.h>
 
 #define PROGRAM_VERSION "1.3"
@@ -142,9 +141,8 @@ parse_opt(int argc, char **argv, struct args *args)
 
                        case '?': /* help */
                                fprintf(stderr, "Usage: "
-                                       "ubiupdatevol [OPTION...] <image file>\n%s%s"
-                                       "\nReport bugs to %s\n",
-                                       doc, optionsstr, PACKAGE_BUGREPORT);
+                                       "ubiupdatevol [OPTION...] <image file>\n%s%s\n",
+                                       doc, optionsstr);
                                exit(EXIT_SUCCESS);
                                break;
 
@@ -184,6 +182,7 @@ ubi_truncate_volume(struct args *args, int64_t bytes,libubi_t libubi)
        ofd = open(path, O_RDWR);
        if (ofd < 0) {
                fprintf(stderr, "Cannot open volume %s\n", path);
+               perror("open");
                exit(EXIT_FAILURE);
        }
        rc = ubi_update_start(libubi, ofd, bytes);
index 543cb8c24a8f1bc34119dc17dc0b72781c9d0144..4f8a3743516cee3c673eb061b100f664dcc12b4f 100644 (file)
@@ -185,7 +185,7 @@ static int test_update1(struct ubi_vol_info *vol_info)
        }
 
        for (i = 0; i < SEQ_SZ; i++) {
-               int ret, stop = 0, len;
+               int ret, stop = 0, len = 0;
                off_t off = 0;
                unsigned char buf1[vol_info->rsvd_bytes];
 
similarity index 89%
rename from ubi-utils/scripts/ubi_jffs2_test.sh
rename to tests/ubi-tests/ubi_jffs2_test.sh
index 883903dbee3ea18052c2bd9dd3d274ec44c9f50b..a6172babac6a23da571b9f52e29cd0cae7b9b3b5 100755 (executable)
 #     Tue Oct 31 14:14:54 CET 2006
 #
 
-VERSION="1.1"
-
-export PATH=$PATH:/bin:~/bin:/usr/local/bin:/home/dedekind/work/prj/ubi/tools/flashutils/bin/
+# Make sure we have UBI utilities in the PATH
+export PATH=../../ubi-utils:$PATH
 
+VERSION="1.1"
 ITERATIONS=250
 ALIGNMENT=2048
 
-UBIMKVOL="ubimkvol -a $ALIGNMENT"
-UBIRMVOL=ubirmvol
-UBIUPDATEVOL=ubiupdatevol
+UBIMKVOL="ubimkvol"
+UBIRMVOL="ubirmvol"
+# This test script uses special program to update volumes
+UBIUPDATEVOL="helpers/ubiupdatevol"
 
 SIZE_512K=524288
 SIZE_1M=1310720
@@ -90,23 +91,11 @@ fix_sysfs_issue ()
 }
 
 #
-# FIXME Udev needs some time until the device nodes are created.
-#       This will cause trouble if after ubimkvol an update attempt
-#       is started immediately, since the device node is not yet
-#       available. We should either fix the tools with inotify or
-#       other ideas or figure out a different way to solve the problem
-#       e.g. to use ubi0 and make the volume device nodes obsolete...
+# Wait for while udev creates device nodes
 #
 udev_wait ()
 {
-    echo -n "FIXME Waiting for udev to create/delete device node "
-    grep 2\.6\.5 /proc/version > /dev/null
-    if [ $? -eq "0" ]; then
-       for i in `seq 0 5`; do
-           sleep 1; echo -n ".";
-       done
-       echo " ok"
-    fi
+       udevsettle || sleep 2;
 }
 
 # delete_volume - Delete a volume. If it does not exist, do not try
@@ -131,7 +120,7 @@ delete_volume ()
        passed
 
        echo -n "*** Delete volume if it exists ... "
-       $UBIRMVOL -d0 -n$volume
+       $UBIRMVOL $UBI_DEVICE -n$volume
        if [ $? -ne "0" ] ; then
            exit_failure
        fi
@@ -159,8 +148,8 @@ writevol_test ()
     delete_volume $volume
 
     echo "*** Try to create volume"
-    echo "    $UBIMKVOL -d0 -n$volume -t$type -NNEW$volume -s $size ... "
-    $UBIMKVOL -d0 -n$volume -t$type -N"NEW$volume" -s $size
+    echo "    $UBIMKVOL $UBI_DEVICE -a $ALIGNMENT -n$volume -t$type -NNEW$volume -s $size ... "
+    $UBIMKVOL $UBI_DEVICE -n$volume -t$type -N"NEW$volume" -s $size
     if [ $? -ne "0" ] ; then
        exit_failure
     fi
@@ -169,7 +158,7 @@ writevol_test ()
 
 ### Try to create same volume again
     echo -n "*** Try to create some volume again, this must fail ... "
-    $UBIMKVOL -d0 -n$volume -t$type -N"NEW$volume" -s $size
+    $UBIMKVOL $UBI_DEVICE -a $ALIGNMENT -n$volume -t$type -N"NEW$volume" -s $size
     if [ $? -eq "0" ] ; then
        exit_failure
     fi
@@ -384,6 +373,13 @@ if [ $? -ne "0" ]; then
     exit_failure
 fi
 
+if [ "x$1" == "x" ]; then
+       echo "Please, specify ubi device to test, e.g., $0 /dev/ubi0";
+       exit_failure;
+fi
+
+UBI_DEVICE=$1
+
 # Set to zero if not running on example hardware
 grep 1142 /proc/cpuinfo > /dev/null
 if [ $? -eq "0" ]; then
index 6a0391fe61670e5a171af47c692f20c3479480b7..abd5dc4e9db1be5a92ee21032c0784f949c0d0b2 100644 (file)
@@ -25,7 +25,7 @@ vpath   %.c ./src
 %.o: %.c
        $(CC) $(CFLAGS) -g -c -o $@ $< -g -Wp,-MD,.$(shell basename $<).dep
 
-all: $(TARGETS)
+all: $(TARGETS) libubi
 
 IGNORE=${wildcard .*.c.dep}
 -include ${IGNORE}
@@ -33,6 +33,9 @@ IGNORE=${wildcard .*.c.dep}
 clean:
        rm -rf *.o $(TARGETS) .*.c.dep
 
+libubi: libubi.o
+       ar cr libubi.a libubi.o
+
 ubinfo: ubinfo.o common.o libubi.o
        $(CC) $(LDFLAGS) -o $@ $^