aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-23 20:31:23 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-23 20:31:23 +0200
commit725a91ea5ee4914a5187f26f18372062733bf036 (patch)
treeed4d5b5ab019eb50bcf2db41c38fe9d7228e741e
parent8b8b18dbb8f8a8b58f3e96ca2970c645be735757 (diff)
ubi-utils: move ubi_jffs2_test.sh to better place
... to tests/ubi-tests/ Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--tests/ubi-tests/Makefile64
-rw-r--r--tests/ubi-tests/helpers/ubiupdatevol.c (renamed from ubi-utils/src/ubiupdatevol.c)7
-rw-r--r--tests/ubi-tests/io_update.c2
-rwxr-xr-xtests/ubi-tests/ubi_jffs2_test.sh (renamed from ubi-utils/scripts/ubi_jffs2_test.sh)44
-rw-r--r--ubi-utils/Makefile5
5 files changed, 63 insertions, 59 deletions
diff --git a/tests/ubi-tests/Makefile b/tests/ubi-tests/Makefile
index a2a49d0..a15d93c 100644
--- a/tests/ubi-tests/Makefile
+++ b/tests/ubi-tests/Makefile
@@ -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))
diff --git a/ubi-utils/src/ubiupdatevol.c b/tests/ubi-tests/helpers/ubiupdatevol.c
index 807b961..6863e2a 100644
--- a/ubi-utils/src/ubiupdatevol.c
+++ b/tests/ubi-tests/helpers/ubiupdatevol.c
@@ -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);
diff --git a/tests/ubi-tests/io_update.c b/tests/ubi-tests/io_update.c
index 543cb8c..4f8a374 100644
--- a/tests/ubi-tests/io_update.c
+++ b/tests/ubi-tests/io_update.c
@@ -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];
diff --git a/ubi-utils/scripts/ubi_jffs2_test.sh b/tests/ubi-tests/ubi_jffs2_test.sh
index 883903d..a6172ba 100755
--- a/ubi-utils/scripts/ubi_jffs2_test.sh
+++ b/tests/ubi-tests/ubi_jffs2_test.sh
@@ -14,16 +14,17 @@
# 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
diff --git a/ubi-utils/Makefile b/ubi-utils/Makefile
index 6a0391f..abd5dc4 100644
--- a/ubi-utils/Makefile
+++ b/ubi-utils/Makefile
@@ -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 $@ $^