LIBUBI_PATH=../../ubi-utils/new-utils/
LIBUBI_SRC_PATH=../../ubi-utils/new-utils/src/
LIBUBI_HEADER_PATH=../../ubi-utils/new-utils/include
-UBI_HEADERS_PATH=../../include/
UBIUTILS_PATH=../../ubi-utils/new-utils/
-CC := $(CROSS)gcc
+LIBUBI_PATH=../../ubi-utils/new-utils/
+KERNELHDR := ../../include
-TESTS=io_update volrefcnt integ io_paral io_read io_basic \
+LIBS = libubi
+TARGETS=io_update volrefcnt integ io_paral io_read io_basic \
mkvol_basic mkvol_bad mkvol_paral rsvol
-# 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))
-
-CFLAGS += -Wall -I$(LIBUBI_HEADER_PATH) -I $(UBI_HEADERS_PATH) -L. -O2
+CFLAGS += -I$(LIBUBI_HEADER_PATH) -I $(KERNELHDR) -lpthread
-all: ubi-utils libubi $(TESTS)
+include ../../common.mk
# Compile ubilib with the udevsettle hack
-libubi: $(LIBUBI_SRC_PATH)/libubi.c $(LIBUBI_HEADER_PATH)/libubi.h $(LIBUBI_SRC_PATH)/libubi_int.h
+libubi.a: $(LIBUBI_SRC_PATH)/libubi.c $(LIBUBI_HEADER_PATH)/libubi.h $(LIBUBI_SRC_PATH)/libubi_int.h
$(CC) $(CFLAGS) -I $(LIBUBI_SRC_PATH) -I../../include -DUDEV_SETTLE_HACK -c $(LIBUBI_SRC_PATH)/libubi.c -o libubi.o
ar cr libubi.a libubi.o
-# 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 $@
-
-# *paral tests require libpthread, thus the below rule for them
-%paral: %paral.o common.o
- $(CC) $(CFLAGS) $^ -lubi -lpthread -o $@
-
-ubi-utils:
- make -C $(UBIUTILS_PATH)
+$(TARGETS): $(addprefix $(BUILDDIR)/, common.o) libubi.a
-clean:
- rm -f $(TESTS) $(addsuffix .o, $(TESTS)) libubi.* $(HELPERS) $(addsuffix .o, $(HELPERS))
+clean::
+ rm -f $(TARGETS) $(addsuffix .o, $(TESTS)) libubi.*
/**
* __check_vol_patt - check that volume contains certain data
*
- * @libubi libubi descriptor
- * @dev_info UBI device description
+ * @libubi libubi descriptor
* @test test name
* @func function name
* @line line number
* This function returns %0 if the volume contains only @byte bytes, and %-1 if
* not.
*/
-int __check_vol_patt(libubi_t libubi, struct ubi_dev_info *dev_info,
- const char *test, const char *func, int line,
- const char *node, uint8_t byte)
+int __check_vol_patt(libubi_t libubi, const char *test, const char *func,
+ int line, const char *node, uint8_t byte)
{
int ret, fd;
long long bytes = 0;
__LINE__, vol_id, req)
#define check_vol_patt(node, byte) \
- __check_vol_patt(libubi, &dev_info, TESTNAME, __FUNCTION__, __LINE__, \
- node, byte)
+ __check_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__, node, byte)
#define update_vol_patt(node, bytes, byte) \
__update_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__, \
int __check_volume(libubi_t libubi, struct ubi_dev_info *dev_info,
const char *test, const char *func, int line, int vol_id,
const struct ubi_mkvol_request *req);
-int __check_vol_patt(libubi_t libubi, struct ubi_dev_info *dev_info,
- const char *test, const char *func, int line,
- const char *node, uint8_t byte);
+int __check_vol_patt(libubi_t libubi, const char *test, const char *func,
+ int line, const char *node, uint8_t byte);
int __update_vol_patt(libubi_t libubi, const char *test, const char *func,
int line, const char *node, long long bytes,
uint8_t byte);
static uint64_t total_space = 0;
static struct open_volume_fd *open_volumes;
-static size_t open_volume_count = 0;
+static int open_volume_count = 0;
static const char *ubi_module_load_string;
if (w->offset + w->size < gap_end) {
/* There is a gap. Check all 0xff */
off64_t gap_start = w->offset + w->size;
- size_t size = gap_end - gap_start;
+ ssize_t size = gap_end - gap_start;
if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
error_exit("lseek64 failed");
memset(read_buffer, 0 , size);
if (gap_end > erase_block->offset) {
/* Check all 0xff */
off64_t gap_start = erase_block->offset;
- size_t size = gap_end - gap_start;
+ ssize_t size = gap_end - gap_start;
if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
error_exit("lseek64 failed");
memset(read_buffer, 0 , size);
{
int i, ubi_pos = 0;
char dev_name[1024];
- size_t buf_size = 1024 * 128;
+ ssize_t buf_size = 1024 * 128;
if (ubi_get_info(libubi, &info))
error_exit("ubi_get_info failed");
*/
static int test_aligned(int type)
{
- int i, ebsz;
+ unsigned int i, ebsz;
struct ubi_mkvol_request req;
const char *name = TESTNAME ":test_aligned()";
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
*
* @ptr thread number
*/
-static void * the_thread(void *ptr)
+static void *the_thread(void *ptr)
{
int fd, iter = iterations, vol_id = (int)ptr;
unsigned char *wbuf, *rbuf;
}
for (i = 0; i < THREADS_NUM; i++) {
- ret = pthread_create(&threads[i], NULL, &the_thread, (void*)i);
+ ret = pthread_create(&threads[i], NULL, &the_thread, (void *)i);
if (ret) {
failed("pthread_create");
goto remove;
int alignments[] = ALIGNMENTS(dev_info.leb_size);
struct ubi_vol_info vol_info;
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
- int i;
+ unsigned int i;
for (i = 0; i < sizeof(alignments)/sizeof(int); i++) {
int leb_size;