Skip to content

Commit

Permalink
Reduced multi-pthread test to 100xN tests, add more AC_CHECK_HEADERs
Browse files Browse the repository at this point in the history
15 minute time-out happened with debian hurd i386, therefore reduced
multi-pthread tests down to 100xN tests instead of 3000 tests.
Added --enable-test-a-lot so that developers, can run a larger batch.

FreeBSD failed to compile due to missing gettimeofday which was present
in version0.3. Edited test files so that tests can be run on systems
that have gettimeofday() and systems running the older ftime().
  • Loading branch information
JoesCat committed Jul 20, 2015
1 parent 32beb1a commit 579045d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- 2015-Jul-19
* Add patch for failure in hurd-i386 build (debian 1%0.5.20150702-2)

- 2015-Jul-02
* Libspiro Version 0.5.20150702
* Important bug fix issue #11 (missing file not included in 0v4).
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AM_LDFLAGS = $(WLSLIB) $(LS_LIB) -no-undefined --mode=link
LIBTOOL_DEPS = @LIBTOOL_DEPS@

DISTCLEANFILES = libspiro.pc
DISTCHECK_CONFIGURE_FLAGS = --enable-verbose_lib --enable-test_inputs
DISTCHECK_CONFIGURE_FLAGS = --enable-verbose_lib --enable-test_inputs --enable-test-a-lot

lib_LTLIBRARIES = libspiro.la

Expand Down
25 changes: 25 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ AC_CHECK_HEADER([pthread.h],[havepthreads=true]
[have_pthreads = xfalse])
AM_CONDITIONAL([WANTPTHREADS],[test x$havepthreads = xtrue])

#-------------------------------------------
# call-test uses sys/timeb.h to display test
# time lengths but libspiro doesn't need it.
AC_CHECK_FUNC([gettimeofday],[have_gettimeofday=true],[have_gettimeofday=false])
AC_CHECK_HEADER([sys/time.h],[],[have_gettimeofday=false])
if test x"${have_gettimeofday}" = xtrue; then
AC_DEFINE_UNQUOTED([DO_TIME_DAY],[1],[Use 'gettimeofday()==true, else use older sys/timeb.h])
else
AC_CHECK_HEADER([sys/timeb.h],[],
[AC_MSG_ERROR([ERROR: Please install time.h and sys/timeb.h developer files],[1])])
fi

#-------------------------------------------
# The 'make check' test 'call-testm.c' runs
# many threads at once to test calculations.
# This number is set at a default of 100 to
# meet automated-test 'time-out' deadlines.
# Recommend maintainers/developers run 1000+
testalot=100
AC_ARG_ENABLE([test_a_lot],
AS_HELP_STRING([--enable-test_a_lot],[Run lots of multithread tests.]),
[testalot=2000])
AC_DEFINE_UNQUOTED([S_TESTP],[$testalot],
[Do 'S_TESTS' multi-thread 'call-testm' checks when you run 'make check'.])

#-------------------------------------------
# Platform specific stuff ($host)
AC_CANONICAL_HOST
Expand Down
16 changes: 14 additions & 2 deletions tests/call-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/timeb.h> /* for get_time */
#ifdef DO_TIME_DAY
#include <sys/time.h> /* for gettimeofday */
#else
#include <sys/timeb.h> /* for old get_time */
#endif

#include "spiroentrypoints.h" /* call spiro through here */
#include "bezctx.h" /* bezctx structure */
Expand All @@ -35,11 +39,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#endif

static double get_time (void) {
#ifdef DO_TIME_DAY
struct timeval tv;

gettimeofday(&tv, NULL);

return tv.tv_sec + 1e-6 * tv.tv_usec;
#else
struct timeb tb;

ftime(&tb);

return tb.time + 1e-3 * tb.millitm;
#endif
}

#ifndef DO_CALL_TESTM
Expand Down Expand Up @@ -470,7 +482,7 @@ int test_multi_curves(void) {
/* 10x larger curves due to rounding errors on double values, */
/* so, we either need a more complex curve test-check at end, */
/* or we can cleverly increase in increments of "1/S_TESTS". */
#define S_TESTS 4000
#define S_TESTS S_TESTP*4

#ifdef HAVE_PTHREADS
pthread_attr_t tattr;
Expand Down
14 changes: 13 additions & 1 deletion tests/unit-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/timeb.h> /* for get_time */
#ifdef DO_TIME_DAY
#include <sys/time.h> /* for gettimeofday */
#else
#include <sys/timeb.h> /* for old get_time */
#endif

#include "bezctx.c"
#include "spiro.c"

int n; /* = 4; */

static double get_time (void) {
#ifdef DO_TIME_DAY
struct timeval tv;

gettimeofday(&tv, NULL);

return tv.tv_sec + 1e-6 * tv.tv_usec;
#else
struct timeb tb;

ftime(&tb);

return tb.time + 1e-3 * tb.millitm;
#endif
}

int test_integ(void) {
Expand Down

0 comments on commit 579045d

Please sign in to comment.