libarchive/test/CMakeFiles/
tar/CMakeFiles/
tar/test/CMakeFiles/
+test_utils/.deps/
+test_utils/.dirstamp
doc/html/*.html
doc/man/*.1
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = build/pkgconfig/libarchive.pc
+# Sources needed by all test programs
+test_utils_SOURCES= \
+ test_utils/test_utils.c
+
#
#
# libarchive_test program
#
libarchive_test_SOURCES= \
$(libarchive_la_SOURCES) \
+ $(test_utils_SOURCES) \
libarchive/test/main.c \
libarchive/test/read_open_memory.c \
libarchive/test/test.h \
libarchive/test/test_write_zip_set_compression_store.c \
libarchive/test/test_zip_filename_encoding.c
-libarchive_test_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC $(PLATFORMCPPFLAGS)
+libarchive_test_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/test_utils -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC $(PLATFORMCPPFLAGS)
libarchive_test_LDADD= $(LTLIBICONV)
# The "list.h" file just lists all of the tests defined in all of the sources.
#
bsdtar_test_SOURCES= \
+ $(test_utils_SOURCES) \
tar/test/main.c \
tar/test/test.h \
tar/test/test_0.c \
bsdtar_test_CPPFLAGS=\
-I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
+ -I$(top_srcdir)/test_utils \
-I$(top_srcdir)/tar -I$(top_builddir)/tar/test \
$(PLATFORMCPPFLAGS)
#
bsdcpio_test_SOURCES= \
+ $(test_utils_SOURCES) \
cpio/cmdline.c \
cpio/test/main.c \
cpio/test/test.h \
bsdcpio_test_CPPFLAGS= \
-I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
+ -I$(top_srcdir)/test_utils \
-I$(top_srcdir)/cpio -I$(top_builddir)/cpio/test \
$(PLATFORMCPPFLAGS)
bsdcpio_test_LDADD=libarchive_fe.la
SET(bsdcpio_test_SOURCES
../cmdline.c
../../libarchive_fe/err.c
+ ../../test_utils/test_utils.c
main.c
test.h
test_0.c
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test_utils)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdcpio_test
*/
#include "test.h"
+#include "test_utils.h"
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
/* Use "list.h" to create a list of all tests (functions and names). */
#undef DEFINE_TEST
#define DEFINE_TEST(n) { n, #n, 0 },
-struct { void (*func)(void); const char *name; int failures; } tests[] = {
+struct test_list_t tests[] = {
#include "list.h"
};
return strdup(buff);
}
-static int
-get_test_set(int *test_set, int limit, const char *test)
-{
- int start, end;
- int idx = 0;
-
- if (test == NULL) {
- /* Default: Run all tests. */
- for (;idx < limit; idx++)
- test_set[idx] = idx;
- return (limit);
- }
- if (*test >= '0' && *test <= '9') {
- const char *vp = test;
- start = 0;
- while (*vp >= '0' && *vp <= '9') {
- start *= 10;
- start += *vp - '0';
- ++vp;
- }
- if (*vp == '\0') {
- end = start;
- } else if (*vp == '-') {
- ++vp;
- if (*vp == '\0') {
- end = limit - 1;
- } else {
- end = 0;
- while (*vp >= '0' && *vp <= '9') {
- end *= 10;
- end += *vp - '0';
- ++vp;
- }
- }
- } else
- return (-1);
- if (start < 0 || end >= limit || start > end)
- return (-1);
- while (start <= end)
- test_set[idx++] = start++;
- } else {
- size_t len = strlen(test);
- for (start = 0; start < limit; ++start) {
- const char *name = tests[start].name;
- const char *p;
-
- while ((p = strchr(name, test[0])) != NULL) {
- if (strncmp(p, test, len) == 0) {
- test_set[idx++] = start;
- break;
- } else
- name = p + 1;
- }
-
- }
- }
- return ((idx == 0)?-1:idx);
-}
-
int
main(int argc, char **argv)
{
do {
int test_num;
- test_num = get_test_set(test_set, limit, *argv);
+ test_num = get_test_set(test_set, limit, *argv, tests);
if (test_num < 0) {
printf("*** INVALID Test %s\n", *argv);
free(refdir_alloc);
############################################
IF(ENABLE_TEST)
SET(libarchive_test_SOURCES
+ ../../test_utils/test_utils.c
main.c
read_open_memory.c
test.h
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test_utils)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_libarchive_test
*/
#include "test.h"
+#include "test_utils.h"
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
/* Use "list.h" to create a list of all tests (functions and names). */
#undef DEFINE_TEST
#define DEFINE_TEST(n) { n, #n, 0 },
-struct { void (*func)(void); const char *name; int failures; } tests[] = {
+struct test_list_t tests[] = {
#include "list.h"
};
return strdup(buff);
}
-static int
-get_test_set(int *test_set, int limit, const char *test)
-{
- int start, end;
- int idx = 0;
-
- if (test == NULL) {
- /* Default: Run all tests. */
- for (;idx < limit; idx++)
- test_set[idx] = idx;
- return (limit);
- }
- if (*test >= '0' && *test <= '9') {
- const char *vp = test;
- start = 0;
- while (*vp >= '0' && *vp <= '9') {
- start *= 10;
- start += *vp - '0';
- ++vp;
- }
- if (*vp == '\0') {
- end = start;
- } else if (*vp == '-') {
- ++vp;
- if (*vp == '\0') {
- end = limit - 1;
- } else {
- end = 0;
- while (*vp >= '0' && *vp <= '9') {
- end *= 10;
- end += *vp - '0';
- ++vp;
- }
- }
- } else
- return (-1);
- if (start < 0 || end >= limit || start > end)
- return (-1);
- while (start <= end)
- test_set[idx++] = start++;
- } else {
- size_t len = strlen(test);
- for (start = 0; start < limit; ++start) {
- const char *name = tests[start].name;
- const char *p;
-
- while ((p = strchr(name, test[0])) != NULL) {
- if (strncmp(p, test, len) == 0) {
- test_set[idx++] = start;
- break;
- } else
- name = p + 1;
- }
-
- }
- }
- return ((idx == 0)?-1:idx);
-}
-
int
main(int argc, char **argv)
{
do {
int test_num;
- test_num = get_test_set(test_set, limit, *argv);
+ test_num = get_test_set(test_set, limit, *argv, tests);
if (test_num < 0) {
printf("*** INVALID Test %s\n", *argv);
free(refdir_alloc);
############################################
IF(ENABLE_TAR AND ENABLE_TEST)
SET(bsdtar_test_SOURCES
+ ../../test_utils/test_utils.c
main.c
test.h
test_0.c
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test_utils)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdtar_test
*/
#include "test.h"
+#include "test_utils.h"
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
/* Use "list.h" to create a list of all tests (functions and names). */
#undef DEFINE_TEST
#define DEFINE_TEST(n) { n, #n, 0 },
-struct { void (*func)(void); const char *name; int failures; } tests[] = {
+struct test_list_t tests[] = {
#include "list.h"
};
return strdup(buff);
}
-static int
-get_test_set(int *test_set, int limit, const char *test)
-{
- int start, end;
- int idx = 0;
-
- if (test == NULL) {
- /* Default: Run all tests. */
- for (;idx < limit; idx++)
- test_set[idx] = idx;
- return (limit);
- }
- if (*test >= '0' && *test <= '9') {
- const char *vp = test;
- start = 0;
- while (*vp >= '0' && *vp <= '9') {
- start *= 10;
- start += *vp - '0';
- ++vp;
- }
- if (*vp == '\0') {
- end = start;
- } else if (*vp == '-') {
- ++vp;
- if (*vp == '\0') {
- end = limit - 1;
- } else {
- end = 0;
- while (*vp >= '0' && *vp <= '9') {
- end *= 10;
- end += *vp - '0';
- ++vp;
- }
- }
- } else
- return (-1);
- if (start < 0 || end >= limit || start > end)
- return (-1);
- while (start <= end)
- test_set[idx++] = start++;
- } else {
- size_t len = strlen(test);
- for (start = 0; start < limit; ++start) {
- const char *name = tests[start].name;
- const char *p;
-
- while ((p = strchr(name, test[0])) != NULL) {
- if (strncmp(p, test, len) == 0) {
- test_set[idx++] = start;
- break;
- } else
- name = p + 1;
- }
-
- }
- }
- return ((idx == 0)?-1:idx);
-}
-
int
main(int argc, char **argv)
{
do {
int test_num;
- test_num = get_test_set(test_set, limit, *argv);
+ test_num = get_test_set(test_set, limit, *argv, tests);
if (test_num < 0) {
printf("*** INVALID Test %s\n", *argv);
free(refdir_alloc);
--- /dev/null
+/*
+ * Copyright (c) 2003-2012 Tim Kientzle
+ * Copyright (c) 2012 Andres Mejia
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test_utils.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+int get_test_set(int *test_set, int limit, const char *test,
+ struct test_list_t *tests)
+{
+ int start, end;
+ int idx = 0;
+
+ if (test == NULL) {
+ /* Default: Run all tests. */
+ for (;idx < limit; idx++)
+ test_set[idx] = idx;
+ return (limit);
+ }
+ if (*test >= '0' && *test <= '9') {
+ const char *vp = test;
+ start = 0;
+ while (*vp >= '0' && *vp <= '9') {
+ start *= 10;
+ start += *vp - '0';
+ ++vp;
+ }
+ if (*vp == '\0') {
+ end = start;
+ } else if (*vp == '-') {
+ ++vp;
+ if (*vp == '\0') {
+ end = limit - 1;
+ } else {
+ end = 0;
+ while (*vp >= '0' && *vp <= '9') {
+ end *= 10;
+ end += *vp - '0';
+ ++vp;
+ }
+ }
+ } else
+ return (-1);
+ if (start < 0 || end >= limit || start > end)
+ return (-1);
+ while (start <= end)
+ test_set[idx++] = start++;
+ } else {
+ size_t len = strlen(test);
+ for (start = 0; start < limit; ++start) {
+ const char *name = tests[start].name;
+ const char *p;
+
+ while ((p = strchr(name, test[0])) != NULL) {
+ if (strncmp(p, test, len) == 0) {
+ test_set[idx++] = start;
+ break;
+ } else
+ name = p + 1;
+ }
+
+ }
+ }
+ return ((idx == 0)?-1:idx);
+}
--- /dev/null
+/*
+ * Copyright (c) 2003-2012 Tim Kientzle
+ * Copyright (c) 2012 Andres Mejia
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TEST_UTILS_H
+#define TEST_UTILS_H
+
+struct test_list_t
+{
+ void (*func)(void);
+ const char *name;
+ int failures;
+};
+
+int get_test_set(int *, int, const char *, struct test_list_t *);
+
+#endif /* TEST_UTILS_H */