mirror of
https://github.com/troglobit/libite.git
synced 2026-11-02 13:10:33 +00:00
Add autotest for mkpath() and makepath()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
b59249714b
commit
57c49bfe0c
4 files changed
+26
-21
No files matched your search
@@ -27,17 +27,9 @@ NAME = libite
|
|||||||
PKG = $(NAME)-$(VERSION)
|
PKG = $(NAME)-$(VERSION)
|
||||||
ARCHIVE = $(PKG).tar.xz
|
ARCHIVE = $(PKG).tar.xz
|
||||||
|
|
||||||
CC ?= $(CROSS)gcc
|
|
||||||
AR ?= $(CROSS)ar
|
|
||||||
STRIP ?= $(CROSS)strip
|
|
||||||
INSTALL := install --backup=off
|
|
||||||
STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755
|
|
||||||
|
|
||||||
CFLAGS += -fPIC
|
CFLAGS += -fPIC
|
||||||
CFLAGS += -Os
|
CFLAGS += -Os
|
||||||
CPPFLAGS += -D_GNU_SOURCE
|
|
||||||
CPPFLAGS += -W -Wall
|
CPPFLAGS += -W -Wall
|
||||||
ARFLAGS = crus
|
|
||||||
|
|
||||||
DISTFILES = README LICENSE
|
DISTFILES = README LICENSE
|
||||||
HEADERS = lite.h
|
HEADERS = lite.h
|
||||||
@@ -54,12 +46,6 @@ SYMLIB = $(LIBNAME).so
|
|||||||
STATICLIB = $(LIBNAME).a
|
STATICLIB = $(LIBNAME).a
|
||||||
TARGET = $(STATICLIB) $(SOLIB)
|
TARGET = $(STATICLIB) $(SOLIB)
|
||||||
|
|
||||||
# Default install paths
|
|
||||||
prefix ?= /usr/local
|
|
||||||
libdir ?= $(prefix)/lib
|
|
||||||
datadir ?= $(prefix)/share/doc/$(LIBNAME)
|
|
||||||
incdir ?= $(prefix)/include
|
|
||||||
|
|
||||||
# This magic trick looks like a comment, but works on BSD PMake
|
# This magic trick looks like a comment, but works on BSD PMake
|
||||||
#include <rules.mk>
|
#include <rules.mk>
|
||||||
include rules.mk
|
include rules.mk
|
||||||
@@ -69,6 +55,7 @@ test:
|
|||||||
$(MAKE) -f copyfile.mk
|
$(MAKE) -f copyfile.mk
|
||||||
$(MAKE) -f dir.mk
|
$(MAKE) -f dir.mk
|
||||||
$(MAKE) -f fsendfile.mk
|
$(MAKE) -f fsendfile.mk
|
||||||
|
$(MAKE) -f makepath.mk
|
||||||
$(MAKE) -f pidfilefn.mk
|
$(MAKE) -f pidfilefn.mk
|
||||||
$(MAKE) -f rsync.mk
|
$(MAKE) -f rsync.mk
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -55,7 +55,7 @@ int makepath(char *dir)
|
|||||||
|
|
||||||
/********************************* UNIT TESTS ************************************/
|
/********************************* UNIT TESTS ************************************/
|
||||||
#ifdef UNITTEST
|
#ifdef UNITTEST
|
||||||
#include <stdio.h>
|
#include "lite.h"
|
||||||
|
|
||||||
int checkpath(char *dir)
|
int checkpath(char *dir)
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,8 @@ int checkpath(char *dir)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "ls -ld %s", dir);
|
snprintf(tmp, sizeof(tmp), "ls -ld %s", dir);
|
||||||
system(tmp);
|
if (system(tmp))
|
||||||
|
perror("system");
|
||||||
|
|
||||||
if (!stat(dir, &sb) && S_ISDIR(sb.st_mode))
|
if (!stat(dir, &sb) && S_ISDIR(sb.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -98,11 +99,11 @@ int main(void)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf(stderr, "Testing makepath() ...\n");
|
printf("Testing makepath() ...\n");
|
||||||
for (i = 0; list[i] && !ret; i++)
|
for (i = 0; list[i] && !ret; i++)
|
||||||
ret = test_makepath(list[i]);
|
ret = test_makepath(list[i]);
|
||||||
|
|
||||||
fprintf(stderr, "\nCleaning up ...\n");
|
printf("\nCleaning up ...\n");
|
||||||
for (i = 0; list[i]; i++)
|
for (i = 0; list[i]; i++)
|
||||||
rmdir(list[i]);
|
rmdir(list[i]);
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ int main(void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* compile-command: "gcc -g -o unittest -D_GNU_SOURCE -DUNITTEST makepath.c && ./unittest"
|
* compile-command: "make V=1 -f makepath.mk"
|
||||||
* version-control: t
|
* version-control: t
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
* c-file-style: "linux"
|
* c-file-style: "linux"
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
OBJS =
|
||||||
|
TARGET = makepath.test clean
|
||||||
|
|
||||||
|
include rules.mk
|
||||||
@@ -3,6 +3,15 @@
|
|||||||
# Figure out root of library, unless used as submodule
|
# Figure out root of library, unless used as submodule
|
||||||
ROOTDIR ?= $(shell pwd)
|
ROOTDIR ?= $(shell pwd)
|
||||||
|
|
||||||
|
CC ?= $(CROSS)gcc
|
||||||
|
AR ?= $(CROSS)ar
|
||||||
|
STRIP ?= $(CROSS)strip
|
||||||
|
INSTALL := install --backup=off
|
||||||
|
STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755
|
||||||
|
|
||||||
|
CPPFLAGS += -D_GNU_SOURCE
|
||||||
|
ARFLAGS = crus
|
||||||
|
|
||||||
# Default to silent build, use V=1 to get verbose mode.
|
# Default to silent build, use V=1 to get verbose mode.
|
||||||
ifeq ($V,1)
|
ifeq ($V,1)
|
||||||
Q =
|
Q =
|
||||||
@@ -16,7 +25,11 @@ REDIRECT = >/dev/null
|
|||||||
MAKEFLAGS = --no-print-directory --silent
|
MAKEFLAGS = --no-print-directory --silent
|
||||||
endif
|
endif
|
||||||
|
|
||||||
export ROOTDIR Q PRINT MAKEFLAGS
|
# Default install paths
|
||||||
|
prefix ?= /usr/local
|
||||||
|
libdir ?= $(prefix)/lib
|
||||||
|
datadir ?= $(prefix)/share/doc/$(LIBNAME)
|
||||||
|
incdir ?= $(prefix)/include
|
||||||
|
|
||||||
# Pretty printing and GCC -M for auto dep files
|
# Pretty printing and GCC -M for auto dep files
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
@@ -29,7 +42,7 @@ export ROOTDIR Q PRINT MAKEFLAGS
|
|||||||
|
|
||||||
%.test: %.c
|
%.test: %.c
|
||||||
$(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
|
$(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
|
||||||
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -DUNITTEST $< $(OBJS)
|
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -g -o $@ -DUNITTEST $< $(OBJS)
|
||||||
$(Q)@./$@ $(REDIRECT)
|
$(Q)@./$@ $(REDIRECT)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user