aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-28 10:41:36 +0200
committerMattias Andrée <maandree@kth.se>2018-08-28 10:41:36 +0200
commit60513cb5508a8197f5219dc3d06c0331c99863a6 (patch)
tree210f152018f18646c1f0cbca21602875562366bb
parentFix vputenvf (diff)
downloadlibsimple-60513cb5508a8197f5219dc3d06c0331c99863a6.tar.gz
libsimple-60513cb5508a8197f5219dc3d06c0331c99863a6.tar.bz2
libsimple-60513cb5508a8197f5219dc3d06c0331c99863a6.tar.xz
Add test function to all .c files
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--Makefile38
-rw-r--r--allocn.c13
-rw-r--r--encalloc.c13
-rw-r--r--enmalloc.c13
-rw-r--r--enmemdup.c13
-rw-r--r--enrealloc.c13
-rw-r--r--enstrdup.c13
-rw-r--r--enstrndup.c13
-rw-r--r--envmalloczn.c13
-rw-r--r--envputenvf.c13
-rw-r--r--envreallocn.c13
-rw-r--r--recvfd.c13
-rw-r--r--recvfrom_timestamped.c13
-rw-r--r--sendfd.c13
-rw-r--r--strtotimespec.c13
-rw-r--r--strtotimeval.c13
-rw-r--r--vweprintf.c13
17 files changed, 209 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 1f75567..763ccda 100644
--- a/Makefile
+++ b/Makefile
@@ -59,43 +59,7 @@ OBJ =\
vweprintf.o\
libsimple.o
-TESTS =\
- asprintf.test\
- difftimespec.test\
- difftimeval.test\
- doubletotimespec.test\
- doubletotimeval.test\
- isutf8.test\
- memdup.test\
- memends.test\
- memmem.test\
- memrchr.test\
- memrmem.test\
- memstarts.test\
- minimise_number_string.test\
- multimespec.test\
- multimeval.test\
- rawmemchr.test\
- rawmemrchr.test\
- strcaseends.test\
- strcasestr.test\
- strends.test\
- strncasestr.test\
- strndup.test\
- strnstr.test\
- strrcasestr.test\
- strrncasestr.test\
- strrnstr.test\
- strrstr.test\
- strstarts.test\
- sumtimespec.test\
- sumtimeval.test\
- timespec2timeval.test\
- timespectostr.test\
- timevaltostr.test\
- vasprintf.test\
- vputenvf.test\
- libsimple.test
+TESTS = $(OBJ:.o=.test)
all: libsimple.a $(TESTS)
$(OBJ): $(@:.o=.c) libsimple.h
diff --git a/allocn.c b/allocn.c
index 7b78ba7..671f8a3 100644
--- a/allocn.c
+++ b/allocn.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
static inline size_t
@@ -36,3 +37,15 @@ libsimple_vreallocn(void *ptr, size_t n, va_list ap) /* TODO test */
n = alloc_size_product(n, ap);
return !n ? NULL : realloc(ptr, n);
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/encalloc.c b/encalloc.c
index 34d8856..1277d7b 100644
--- a/encalloc.c
+++ b/encalloc.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_encalloc(int status, size_t n, size_t m) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/enmalloc.c b/enmalloc.c
index db26753..0a13f03 100644
--- a/enmalloc.c
+++ b/enmalloc.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_enmalloc(int status, size_t n) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/enmemdup.c b/enmemdup.c
index 37f9995..8693af6 100644
--- a/enmemdup.c
+++ b/enmemdup.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_enmemdup(int status, const void *s, size_t n) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/enrealloc.c b/enrealloc.c
index e996319..04feede 100644
--- a/enrealloc.c
+++ b/enrealloc.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_enrealloc(int status, void *ptr, size_t n) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/enstrdup.c b/enstrdup.c
index a5e2b81..2adb309 100644
--- a/enstrdup.c
+++ b/enstrdup.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_enstrdup(int status, const char *s) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/enstrndup.c b/enstrndup.c
index 23dd9fe..7dd6595 100644
--- a/enstrndup.c
+++ b/enstrndup.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_enstrndup(int status, const char *s, size_t n) /* TODO test */
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/envmalloczn.c b/envmalloczn.c
index 661e18a..832ce67 100644
--- a/envmalloczn.c
+++ b/envmalloczn.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_envmalloczn(int status, int clear, size_t n, va_list ap) /* TODO test
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/envputenvf.c b/envputenvf.c
index 583859f..cf30208 100644
--- a/envputenvf.c
+++ b/envputenvf.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -13,3 +14,15 @@ libsimple_envputenvf(int status, const char *fmt, va_list ap) /* TODO test */
exit(status);
}
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/envreallocn.c b/envreallocn.c
index ec64d29..44b69e3 100644
--- a/envreallocn.c
+++ b/envreallocn.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -15,3 +16,15 @@ libsimple_envreallocn(int status, void *ptr, size_t n, va_list ap) /* TODO test
}
return ret;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/recvfd.c b/recvfd.c
index 3892998..cd8ecb6 100644
--- a/recvfd.c
+++ b/recvfd.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
int
@@ -38,3 +39,15 @@ libsimple_recvfd(int sock) /* TODO test */
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
return fd;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/recvfrom_timestamped.c b/recvfrom_timestamped.c
index f5f8e53..49e8e3f 100644
--- a/recvfrom_timestamped.c
+++ b/recvfrom_timestamped.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
ssize_t
@@ -55,3 +56,15 @@ libsimple_recvfrom_timestamped(int fd, void *restrict buf, size_t n, int flags,
return r;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/sendfd.c b/sendfd.c
index 5d41fa4..5220761 100644
--- a/sendfd.c
+++ b/sendfd.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
int
@@ -29,3 +30,15 @@ libsimple_sendfd(int sock, int fd) /* TODO test */
return -(sendmsg(sock, &msg, 0) != (ssize_t)iov.iov_len);
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/strtotimespec.c b/strtotimespec.c
index 1e6e8d1..bd28260 100644
--- a/strtotimespec.c
+++ b/strtotimespec.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
int
@@ -142,3 +143,15 @@ overflow:
errno = ERANGE;
return -1;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/strtotimeval.c b/strtotimeval.c
index a0a18b9..6c30c88 100644
--- a/strtotimeval.c
+++ b/strtotimeval.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
int
@@ -13,3 +14,15 @@ libsimple_strtotimeval(struct timeval *restrict tv, const char *restrict s, char
errno = ERANGE;
return r;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/vweprintf.c b/vweprintf.c
index f46bd26..d994c0e 100644
--- a/vweprintf.c
+++ b/vweprintf.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
+#ifndef TEST
extern char *argv0;
@@ -54,3 +55,15 @@ libsimple_vweprintf(const char *fmt, va_list ap) /* TODO test */
errno = saved_errno;
}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif