diff options
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | config/ac-macros/misc.m4 | 97 | ||||
-rw-r--r-- | configure.in | 54 | ||||
-rw-r--r-- | include/atomic/x86-gcc.h | 3 | ||||
-rw-r--r-- | include/my_global.h | 38 | ||||
-rw-r--r-- | include/my_sys.h | 5 | ||||
-rw-r--r-- | mysys/Makefile.am | 1 | ||||
-rw-r--r-- | unittest/Makefile.am | 25 | ||||
-rw-r--r-- | unittest/README.txt | 23 | ||||
-rw-r--r-- | unittest/examples/Makefile.am | 11 | ||||
-rw-r--r-- | unittest/examples/no_plan-t.c (renamed from unittest/examples/no_plan.t.c) | 0 | ||||
-rw-r--r-- | unittest/examples/simple-t.c (renamed from unittest/examples/simple.t.c) | 0 | ||||
-rw-r--r-- | unittest/examples/skip-t.c (renamed from unittest/examples/skip.t.c) | 0 | ||||
-rw-r--r-- | unittest/examples/skip_all-t.c (renamed from unittest/examples/skip_all.t.c) | 0 | ||||
-rw-r--r-- | unittest/examples/todo-t.c (renamed from unittest/examples/todo.t.c) | 0 | ||||
-rw-r--r-- | unittest/mysys/Makefile.am | 6 | ||||
-rw-r--r-- | unittest/mysys/base64-t.c (renamed from unittest/mysys/base64.t.c) | 0 | ||||
-rw-r--r-- | unittest/mysys/bitmap-t.c (renamed from unittest/mysys/bitmap.t.c) | 0 | ||||
-rw-r--r-- | unittest/mysys/my_atomic-t.c (renamed from mysys/test_atomic.c) | 42 | ||||
-rw-r--r-- | unittest/mytap/t/Makefile.am | 5 | ||||
-rw-r--r-- | unittest/mytap/t/basic-t.c (renamed from unittest/mytap/t/basic.t.c) | 0 | ||||
-rw-r--r-- | unittest/unit.pl | 2 |
22 files changed, 98 insertions, 215 deletions
diff --git a/.bzrignore b/.bzrignore index 27e8cb3c79d..b3bc5760f59 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1772,3 +1772,4 @@ zlib/*.ds? zlib/*.vcproj libmysqld/event_scheduler.cc mysys/test_atomic +*-t diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4 index a2f70071e2d..3ed64b5625b 100644 --- a/config/ac-macros/misc.m4 +++ b/config/ac-macros/misc.m4 @@ -155,84 +155,6 @@ fi ]) -#---START: Used in for client configure -AC_DEFUN([MYSQL_CHECK_ULONG], -[AC_MSG_CHECKING(for type ulong) -AC_CACHE_VAL(ac_cv_ulong, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - ulong foo; - foo++; - exit(0); -}], ac_cv_ulong=yes, ac_cv_ulong=no, ac_cv_ulong=no)]) -AC_MSG_RESULT($ac_cv_ulong) -if test "$ac_cv_ulong" = "yes" -then - AC_DEFINE([HAVE_ULONG], [1], [system headers define ulong]) -fi -]) - -AC_DEFUN([MYSQL_CHECK_UCHAR], -[AC_MSG_CHECKING(for type uchar) -AC_CACHE_VAL(ac_cv_uchar, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - uchar foo; - foo++; - exit(0); -}], ac_cv_uchar=yes, ac_cv_uchar=no, ac_cv_uchar=no)]) -AC_MSG_RESULT($ac_cv_uchar) -if test "$ac_cv_uchar" = "yes" -then - AC_DEFINE([HAVE_UCHAR], [1], [system headers define uchar]) -fi -]) - -AC_DEFUN([MYSQL_CHECK_UINT], -[AC_MSG_CHECKING(for type uint) -AC_CACHE_VAL(ac_cv_uint, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - uint foo; - foo++; - exit(0); -}], ac_cv_uint=yes, ac_cv_uint=no, ac_cv_uint=no)]) -AC_MSG_RESULT($ac_cv_uint) -if test "$ac_cv_uint" = "yes" -then - AC_DEFINE([HAVE_UINT], [1], [system headers define uint]) -fi -]) - - -AC_DEFUN([MYSQL_CHECK_IN_ADDR_T], -[AC_MSG_CHECKING(for type in_addr_t) -AC_CACHE_VAL(ac_cv_in_addr_t, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -int main(int argc, char **argv) -{ - in_addr_t foo; - exit(0); -}], ac_cv_in_addr_t=yes, ac_cv_in_addr_t=no, ac_cv_in_addr_t=no)]) -AC_MSG_RESULT($ac_cv_in_addr_t) -if test "$ac_cv_in_addr_t" = "yes" -then - AC_DEFINE([HAVE_IN_ADDR_T], [1], [system headers define in_addr_t]) -fi -]) - - AC_DEFUN([MYSQL_PTHREAD_YIELD], [AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg, [AC_TRY_LINK([#define _GNU_SOURCE @@ -272,25 +194,6 @@ fi #---END: -AC_DEFUN([MYSQL_CHECK_FP_EXCEPT], -[AC_MSG_CHECKING(for type fp_except) -AC_CACHE_VAL(ac_cv_fp_except, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -#include <ieeefp.h> -main() -{ - fp_except foo; - foo++; - exit(0); -}], ac_cv_fp_except=yes, ac_cv_fp_except=no, ac_cv_fp_except=no)]) -AC_MSG_RESULT($ac_cv_fp_except) -if test "$ac_cv_fp_except" = "yes" -then - AC_DEFINE([HAVE_FP_EXCEPT], [1], [fp_except from ieeefp.h]) -fi -]) - # From fileutils-3.14/aclocal.m4 # @defmac AC_PROG_CC_STDC diff --git a/configure.in b/configure.in index 1e332e390e1..be6f3c8eaec 100644 --- a/configure.in +++ b/configure.in @@ -829,38 +829,20 @@ fi # Later in this script LIBS will be augmented with a threads library. NON_THREADED_LIBS="$LIBS" -AC_MSG_CHECKING([for int8]) -case $SYSTEM_TYPE in - *netware) - AC_MSG_RESULT([no]) - ;; - *) -AC_TRY_RUN([ -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif - -#ifdef HAVE_SYS_TYPES_H +AC_CHECK_TYPES([int8, uint8, int16, uint16, int32, uint32, int64, uint64, + uchar, uint, ulong],[],[], [ #include <sys/types.h> -#endif - -int main() -{ - int8 i; - return 0; -} -], -[AC_DEFINE([HAVE_INT_8_16_32], [1], - [whether int8, int16 and int32 types exist]) -AC_MSG_RESULT([yes])], -[AC_MSG_RESULT([no])] -) - ;; -esac +]) +AC_CHECK_TYPES([in_addr_t], [], [], [ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +]) +AC_CHECK_TYPES([fp_except], [], [], [ +#include <sys/types.h> +#include <ieeefp.h> +]) # # Some system specific hacks @@ -1734,16 +1716,6 @@ MYSQL_FUNC_ALLOCA MYSQL_TIMESPEC_TS # Do we have the tzname variable MYSQL_TZNAME -# Do the system files define ulong -MYSQL_CHECK_ULONG -# Do the system files define uchar -MYSQL_CHECK_UCHAR -# Do the system files define uint -MYSQL_CHECK_UINT -# Check for fp_except in ieeefp.h -MYSQL_CHECK_FP_EXCEPT -# Check for IN_ADDR_T -MYSQL_CHECK_IN_ADDR_T # Do the c++ compiler have a bool type MYSQL_CXX_BOOL # Check some common bugs with gcc 2.8.# on sparc diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index b06d80d37e5..7576db54d69 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -19,6 +19,9 @@ cmpxchg8b, if necessary */ +/* fix -ansi errors while maintaining readability */ +#define asm __asm__ + #define make_atomic_add_body8 \ asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (a->val)) #define make_atomic_swap_body8 \ diff --git a/include/my_global.h b/include/my_global.h index 81fa5225c3b..f2ad3af0b6f 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -864,26 +864,36 @@ typedef void *gptr; /* Generic pointer */ #else typedef char *gptr; /* Generic pointer */ #endif -#ifndef HAVE_INT_8_16_32 -typedef signed char int8; /* Signed integer >= 8 bits */ -typedef short int16; /* Signed integer >= 16 bits */ -#endif #ifndef HAVE_UCHAR typedef unsigned char uchar; /* Short for unsigned char */ #endif -typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */ -typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */ +#ifndef HAVE_INT8 +typedef signed char int8; /* Signed integer >= 8 bits */ +#endif +#ifndef HAVE_UINT8 +typedef unsigned char uint8; /* Unsigned integer >= 8 bits */ +#endif +#ifndef HAVE_INT16 +typedef short int16; +#endif +#ifndef HAVE_UINT16 +typedef unsigned short uint16; +#endif #if SIZEOF_INT == 4 -#ifndef HAVE_INT_8_16_32 -typedef int int32; +#ifndef HAVE_INT32 +typedef int int32; +#endif +#ifndef HAVE_UINT32 +typedef unsigned int uint32; #endif -typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */ #elif SIZEOF_LONG == 4 -#ifndef HAVE_INT_8_16_32 -typedef long int32; +#ifndef HAVE_INT32 +typedef long int32; +#endif +#ifndef HAVE_UINT32 +typedef unsigned long uint32; #endif -typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */ #else #error "Neither int or long is of 4 bytes width" #endif @@ -900,8 +910,12 @@ typedef unsigned long ulonglong; /* ulong or unsigned long long */ typedef long longlong; #endif #endif +#ifndef HAVE_INT64 typedef longlong int64; +#endif +#ifndef HAVE_UINT64 typedef ulonglong uint64; +#endif #if defined(NO_CLIENT_LONG_LONG) typedef unsigned long my_ulonglong; diff --git a/include/my_sys.h b/include/my_sys.h index 5024505a821..4ea7cecf0a1 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -821,8 +821,9 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len); extern uint my_set_max_open_files(uint files); void my_free_open_file_info(void); -ulonglong my_getsystime(void); -my_bool my_gethwaddr(uchar *to); +extern ulonglong my_getsystime(void); +extern my_bool my_gethwaddr(uchar *to); +extern int my_getncpus(); #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 93d0e896874..2838427e9e0 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -63,7 +63,6 @@ libmysys_a_LIBADD = @THREAD_LOBJECTS@ # testhash_DEPENDENCIES= $(LIBRARIES) # test_charset_DEPENDENCIES= $(LIBRARIES) # charset2html_DEPENDENCIES= $(LIBRARIES) -noinst_PROGRAMS= test_atomic$(EXEEXT) DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \ diff --git a/unittest/Makefile.am b/unittest/Makefile.am index bfa9f40f8ce..dc778aada1c 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -1,27 +1,14 @@ SUBDIRS = mytap . mysys examples noinst_SCRIPTS = unit +#EXTRA_DIST = unit.pl -EXTRA_DIST = unit.pl +unittests = mytap mysys -DISTCLEANFILES = unit - -unittests = mysys examples - -.PHONY: all mytap mysys examples test - -test: unit all - @./unit run $(unittests) - -mytap: - cd mytap && $(MAKE) - -mysys: - cd mysys && $(MAKE) - -examples: - cd examples && $(MAKE) +test: unit + ./unit run $(unittests) unit: $(srcdir)/unit.pl cp $(srcdir)/unit.pl $@ - chmod +x $@ + chmod 700 $@ + diff --git a/unittest/README.txt b/unittest/README.txt index fd9641665c7..0d8bb9025d8 100644 --- a/unittest/README.txt +++ b/unittest/README.txt @@ -7,14 +7,14 @@ will be added over time. mytap Source for the MyTAP library mysys Tests for mysys components - bitmap.t.c Unit test for MY_BITMAP - base64.t.c Unit test for base64 encoding functions + bitmap-t.c Unit test for MY_BITMAP + base64-t.c Unit test for base64 encoding functions examples Example unit tests - simple.t.c Example of a standard TAP unit test - skip.t.c Example where some test points are skipped - skip_all.t.c Example of a test where the entire test is skipped - todo.t.c Example where test contain test points that are TODO - no_plan.t.c Example of a test with no plan (avoid this) + simple-t.c Example of a standard TAP unit test + skip-t.c Example where some test points are skipped + skip_all-t.c Example of a test where the entire test is skipped + todo-t.c Example where test contain test points that are TODO + no_plan-t.c Example of a test with no plan (avoid this) Executing unit tests @@ -28,9 +28,12 @@ To make and execute all unit tests in the directory: Adding unit tests ----------------- -Add a file with a name of the format "foo.t.c" to the appropriate +Add a file with a name of the format "foo-t.c" to the appropriate directory and add the following to the Makefile.am in that directory (where ... denotes stuff already there): - noinst_PROGRAMS = ... foo.t - foo_t_c_SOURCES = foo.t.c + noinst_PROGRAMS = ... foo-t + +Note, it's important to have "-t" at the end of the filename, otherwise the +test won't be executed by 'make test' ! + diff --git a/unittest/examples/Makefile.am b/unittest/examples/Makefile.am index 94a67927d12..f3c70b654a1 100644 --- a/unittest/examples/Makefile.am +++ b/unittest/examples/Makefile.am @@ -5,14 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap LDADD = -lmytap -noinst_PROGRAMS = simple.t skip.t todo.t skip_all.t no_plan.t +noinst_PROGRAMS = simple-t skip-t todo-t skip_all-t no_plan-t -simple_t_SOURCES = simple.t.c - -skip_t_SOURCES = skip.t.c - -todo_t_SOURCES = todo.t.c - -skip_all_t_SOURCES = skip_all.t.c - -no_plan_t_SOURCES = no_plan.t.c diff --git a/unittest/examples/no_plan.t.c b/unittest/examples/no_plan-t.c index 98e4d06def6..98e4d06def6 100644 --- a/unittest/examples/no_plan.t.c +++ b/unittest/examples/no_plan-t.c diff --git a/unittest/examples/simple.t.c b/unittest/examples/simple-t.c index 866af865327..866af865327 100644 --- a/unittest/examples/simple.t.c +++ b/unittest/examples/simple-t.c diff --git a/unittest/examples/skip.t.c b/unittest/examples/skip-t.c index ef717691700..ef717691700 100644 --- a/unittest/examples/skip.t.c +++ b/unittest/examples/skip-t.c diff --git a/unittest/examples/skip_all.t.c b/unittest/examples/skip_all-t.c index 19b8c1fddaf..19b8c1fddaf 100644 --- a/unittest/examples/skip_all.t.c +++ b/unittest/examples/skip_all-t.c diff --git a/unittest/examples/todo.t.c b/unittest/examples/todo-t.c index 82601bee41c..82601bee41c 100644 --- a/unittest/examples/todo.t.c +++ b/unittest/examples/todo-t.c diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am index 010a7845339..b1e0356bac6 100644 --- a/unittest/mysys/Makefile.am +++ b/unittest/mysys/Makefile.am @@ -7,9 +7,5 @@ AM_LDFLAGS += -L$(top_builddir)/strings -L$(top_builddir)/dbug LDADD = -lmytap -lmysys -ldbug -lmystrings -noinst_PROGRAMS = bitmap.t base64.t - -bitmap_t_SOURCES = bitmap.t.c - -base64_t_SOURCES = base64.t.c +noinst_PROGRAMS = bitmap-t base64-t my_atomic-t diff --git a/unittest/mysys/base64.t.c b/unittest/mysys/base64-t.c index 1b4f2eb2356..1b4f2eb2356 100644 --- a/unittest/mysys/base64.t.c +++ b/unittest/mysys/base64-t.c diff --git a/unittest/mysys/bitmap.t.c b/unittest/mysys/bitmap-t.c index d5683baff66..d5683baff66 100644 --- a/unittest/mysys/bitmap.t.c +++ b/unittest/mysys/bitmap-t.c diff --git a/mysys/test_atomic.c b/unittest/mysys/my_atomic-t.c index 21315bc13a4..8a3fe129b07 100644 --- a/mysys/test_atomic.c +++ b/unittest/mysys/my_atomic-t.c @@ -1,3 +1,21 @@ +/* Copyright (C) 2006 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <tap.h> + #include <my_global.h> #include <my_sys.h> #include <my_atomic.h> @@ -25,6 +43,7 @@ pthread_handler_t test_atomic_add_handler(void *arg) N--; if (!N) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); + return 0; } /* @@ -54,6 +73,7 @@ pthread_handler_t test_atomic_swap_handler(void *arg) N--; if (!N) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); + return 0; } /* @@ -75,6 +95,7 @@ pthread_handler_t test_atomic_cas_handler(void *arg) N--; if (!N) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); + return 0; } void test_atomic(const char *test, pthread_handler handler, int n, int m) @@ -86,7 +107,7 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m) my_atomic_store32(&b32, 0, &rwl); my_atomic_store32(&c32, 0, &rwl); - printf("Testing %s with %d threads, %d iterations... ", test, n, m); + diag("Testing %s with %d threads, %d iterations... ", test, n, m); for (N=n ; n ; n--) pthread_create(&t, &thr_attr, handler, &m); @@ -95,24 +116,19 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m) pthread_cond_wait(&cond, &mutex); pthread_mutex_unlock(&mutex); now=my_getsystime()-now; - printf("got %lu in %g secs\n", my_atomic_load32(&a32, &rwl), - ((double)now)/1e7); + ok(my_atomic_load32(&a32, &rwl) == 0, + "tested %s in %g secs", test, ((double)now)/1e7); } int main() { int err; -#ifdef _IONBF - setvbuf(stdout, 0, _IONBF, 0); -#endif - printf("N CPUs: %d\n", my_getncpus()); + diag("N CPUs: %d", my_getncpus()); + err= my_atomic_initialize(); - if ((err= my_atomic_initialize())) - { - printf("my_atomic_initialize() failed. Error=%d\n", err); - return 1; - } + plan(4); + ok(err == 0, "my_atomic_initialize() returned %d", err); pthread_attr_init(&thr_attr); pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); @@ -128,6 +144,6 @@ int main() pthread_cond_destroy(&cond); pthread_attr_destroy(&thr_attr); my_atomic_rwlock_destroy(&rwl); - return 0; + return exit_status(); } diff --git a/unittest/mytap/t/Makefile.am b/unittest/mytap/t/Makefile.am index 88c31cfeb7f..b685ae7dc1c 100644 --- a/unittest/mytap/t/Makefile.am +++ b/unittest/mytap/t/Makefile.am @@ -5,8 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap LDADD = -lmytap -noinst_PROGRAMS = basic.t +noinst_PROGRAMS = basic-t -basic_t_SOURCES = basic.t.c - -all: $(noinst_PROGRAMS) diff --git a/unittest/mytap/t/basic.t.c b/unittest/mytap/t/basic-t.c index bf4c1a9a664..bf4c1a9a664 100644 --- a/unittest/mytap/t/basic.t.c +++ b/unittest/mytap/t/basic-t.c diff --git a/unittest/unit.pl b/unittest/unit.pl index cae394cf9b6..3092a874192 100644 --- a/unittest/unit.pl +++ b/unittest/unit.pl @@ -59,7 +59,7 @@ sub _find_test_files (@) { my @files; find sub { $File::Find::prune = 1 if /^SCCS$/; - push(@files, $File::Find::name) if -x _ && /\.t\z/; + push(@files, $File::Find::name) if -x _ && /-t\z/; }, @dirs; return @files; } |