diff options
author | unknown <vvaintroub/Wlad@vaio.> | 2008-01-10 13:21:53 +0100 |
---|---|---|
committer | unknown <vvaintroub/Wlad@vaio.> | 2008-01-10 13:21:53 +0100 |
commit | 0ac297963e369b10b618810854ee21fda1333f8f (patch) | |
tree | 9bd52862a62e97454cd29e245d4e68d9a9175211 /unittest | |
parent | 1ed4395f1b334c93a892fc2926f9aab32e0b5e83 (diff) | |
download | mariadb-git-0ac297963e369b10b618810854ee21fda1333f8f.tar.gz |
Windows fixes
-new option WITH_MARIA_STORAGE_ENGINE for config.js
-correct build errors
-build test executables
-downport changes for atomic functions from 5.2
-remove LOCK_uuid_generator from C++ files to avoid linker errors
-new function my_uuid2str()
BitKeeper/deleted/.del-x86-msvc.h:
Delete: include/atomic/x86-msvc.h
CMakeLists.txt:
Windows fixes:
-New option WITH_MARIA_STORAGE_ENGINE
-Add unit tests
include/Makefile.am:
replace x86-msvc.h with generic-msvc.h
include/config-win.h:
my_chmod() support
include/my_atomic.h:
Downport my_atomic from 5.2 tree
include/my_bit.h:
Correct unresolved symbol errors on Windows
include/my_pthread.h:
pthread_mutex_unlock now returns 0 (was void previously)
defined PTHREAD_STACK_MIN
include/my_sys.h:
New function my_uuid2str()
define MY_UUID_STRING_LENGTH
include/atomic/nolock.h:
Downport my_atomic from 5.2 tree
libmysqld/CMakeLists.txt:
New option WITH_MARIA_STORAGE_ENGINE
mysys/CMakeLists.txt:
Add missing files
mysys/lf_dynarray.c:
Fix compiler errors on Windows
mysys/my_getncpus.c:
Windows port
mysys/my_uuid.c:
Windows fixes: there is no random() on Windows, use ANSI rand()
New function my_uuid2str()
mysys/my_winthread.c:
Downport from 5.2 tree
-Call my_thread_end() before pthread_exit()
-Avoid crash if pthread_create is called with NULL attributes
sql/CMakeLists.txt:
Link mysqld with Maria storage engine
sql/item_func.cc:
Remove LOCK_uuid_generator from C++ to avoid linker errors.
Use dedicated mutex for short uuids
sql/item_strfunc.cc:
Use my_uuid() and my_uuid2str() functions from mysys.
sql/item_strfunc.h:
Define MY_UUID_STRING_LENGTH in my_sys.h
sql/mysql_priv.h:
LOCK_uuid_generator must be declared as extern "C"
sql/mysqld.cc:
Init and destroy LOCK_uuid_short mutex
storage/maria/CMakeLists.txt:
-Use the same source files as in Makefile.am
-Build test binaries
storage/maria/ha_maria.cc:
snprintf->my_snprintf
storage/maria/lockman.c:
Fix compiler error on Windows
storage/maria/ma_check.c:
Fix compiler error on Windows
storage/maria/ma_loghandler.c:
Fix compile errors
my_open()/my_sync() do not work for directories on Windows
storage/maria/ma_recovery.c:
Fix compile error on Windows
storage/maria/ma_test2.c:
Rename variable to avoid naming conflict with Microsoft C runtime
function
storage/maria/ma_test3.c:
Fix build errors on Windows
storage/maria/tablockman.c:
Fix build errors on Windows
storage/maria/unittest/Makefile.am:
Add CMakeLists.txt
storage/maria/unittest/ma_pagecache_consist.c:
Fix build errors on Windows
remove loop from get_len()
storage/maria/unittest/ma_pagecache_single.c:
Fix build errors on Windows
storage/maria/unittest/ma_test_loghandler-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
-remove loop in get_len()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
-remove loop in get_len()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Fix build errors on Windows
storage/maria/unittest/test_file.c:
Correct the code to get file size on Windows.
stat() information can be outdated and thus cannot be trusted.
On Vista,stat() returns file size=0 until the file is closed at the
first time.
storage/myisam/CMakeLists.txt:
Fix compiler errors on Windows
Build test executables
storage/myisam/mi_test2.c:
Rename variable to avoid naming conflict with Microsoft C runtime
function
storage/myisam/mi_test3.c:
Fix build errors on Windows
strings/CMakeLists.txt:
Add missing file
unittest/unit.pl:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mysys/Makefile.am:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mysys/my_atomic-t.c:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mytap/Makefile.am:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mytap/tap.c:
Windows:
downport unittest changes from 5.2 bk tree
win/configure.js:
Add WITH_MARIA_STORAGE_ENGINE configure option
unittest/mytap/CMakeLists.txt:
Add missing file
unittest/mysys/CMakeLists.txt:
Add missing file
storage/maria/unittest/CMakeLists.txt:
Add missing file
BitKeeper/etc/ignore:
Added comments maria-win.patch to the ignore list
include/atomic/generic-msvc.h:
Implement atomic operations with MSVC intrinsics
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/mysys/CMakeLists.txt | 28 | ||||
-rw-r--r-- | unittest/mysys/Makefile.am | 2 | ||||
-rw-r--r-- | unittest/mysys/my_atomic-t.c | 86 | ||||
-rw-r--r-- | unittest/mytap/CMakeLists.txt | 20 | ||||
-rw-r--r-- | unittest/mytap/Makefile.am | 2 | ||||
-rw-r--r-- | unittest/mytap/tap.c | 21 | ||||
-rw-r--r-- | unittest/unit.pl | 4 |
7 files changed, 134 insertions, 29 deletions
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt new file mode 100644 index 00000000000..56ebe6e1055 --- /dev/null +++ b/unittest/mysys/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2007 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; version 2 of the License. +# +# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/unittest/mytap) +ADD_EXECUTABLE(bitmap-t bitmap-t.c) +TARGET_LINK_LIBRARIES(bitmap-t mytap mysys dbug strings wsock32) + +ADD_EXECUTABLE(base64-t base64-t.c) +TARGET_LINK_LIBRARIES(base64-t mytap mysys dbug strings wsock32) + +ADD_EXECUTABLE(my_atomic-t my_atomic-t.c) +TARGET_LINK_LIBRARIES(my_atomic-t mytap mysys dbug strings wsock32) diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am index 36ee285201e..96a775a58a9 100644 --- a/unittest/mysys/Makefile.am +++ b/unittest/mysys/Makefile.am @@ -23,5 +23,7 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/strings/libmystrings.a +EXTRA_DIST = CMakeLists.txt + # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index a24cbae272a..a5fa4c1bfe8 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -31,8 +31,10 @@ volatile int32 c32, N; my_atomic_rwlock_t rwl; LF_ALLOCATOR lf_allocator; LF_HASH lf_hash; - -pthread_attr_t attr; +pthread_attr_t thr_attr; +pthread_mutex_t mutex; +pthread_cond_t cond; +uint running_threads; size_t stacksize= 0; #define STACK_SIZE (((int)stacksize-2048)*STACK_DIRECTION) @@ -52,6 +54,9 @@ pthread_handler_t test_atomic_add_handler(void *arg) my_atomic_add32(&a32, -x); my_atomic_rwlock_wrunlock(&rwl); } + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } @@ -66,9 +71,15 @@ pthread_handler_t test_atomic_add_handler(void *arg) pthread_handler_t test_atomic_fas_handler(void *arg) { int m= *(int *)arg; - uint32 x= my_atomic_add32(&b32, 1); + int32 x; + my_atomic_rwlock_wrlock(&rwl); + x= my_atomic_add32(&b32, 1); + my_atomic_rwlock_wrunlock(&rwl); + + my_atomic_rwlock_wrlock(&rwl); my_atomic_add32(&a32, x); + my_atomic_rwlock_wrunlock(&rwl); for (; m ; m--) { @@ -88,6 +99,9 @@ pthread_handler_t test_atomic_fas_handler(void *arg) my_atomic_add32(&a32, -x); my_atomic_rwlock_wrunlock(&rwl); + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } @@ -117,9 +131,13 @@ pthread_handler_t test_atomic_cas_handler(void *arg) my_atomic_rwlock_wrunlock(&rwl); } while (!ok) ; } + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } + /* pin allocator - alloc and release an element in a loop */ @@ -137,6 +155,9 @@ pthread_handler_t test_lf_pinbox(void *arg) pins= lf_pinbox_get_pins(&lf_allocator.pinbox, &m + STACK_SIZE); } lf_pinbox_put_pins(pins); + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } @@ -181,6 +202,9 @@ pthread_handler_t test_lf_alloc(void *arg) #endif } my_atomic_rwlock_wrunlock(&rwl); + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } @@ -228,44 +252,40 @@ pthread_handler_t test_lf_hash(void *arg) a32|= lf_hash.count; } my_atomic_rwlock_wrunlock(&rwl); + pthread_mutex_lock(&mutex); + if (!--running_threads) pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); return 0; } + void test_atomic(const char *test, pthread_handler handler, int n, int m) { - pthread_t *threads; + pthread_t t; ulonglong now= my_getsystime(); - int i; a32= 0; b32= 0; c32= 0; - threads= (pthread_t *)my_malloc(sizeof(void *)*n, MYF(0)); - if (!threads) - { - diag("Out of memory"); - abort(); - } - diag("Testing %s with %d threads, %d iterations... ", test, n, m); - N= n; - for (i= 0 ; i < n ; i++) + for (running_threads= n ; n ; n--) { - if (pthread_create(threads+i, 0, handler, &m) != 0) + if (pthread_create(&t, &thr_attr, handler, &m) != 0) { diag("Could not create thread"); abort(); } } - for (i= 0 ; i < n ; i++) - pthread_join(threads[i], 0); + pthread_mutex_lock(&mutex); + while (running_threads) + pthread_cond_wait(&cond, &mutex); + pthread_mutex_unlock(&mutex); + now= my_getsystime()-now; ok(a32 == 0, "tested %s in %g secs (%d)", test, ((double)now)/1e7, a32); - my_free((void *)threads, MYF(0)); } - int main() { int err; @@ -277,23 +297,34 @@ int main() plan(7); ok(err == 0, "my_atomic_initialize() returned %d", err); + pthread_mutex_init(&mutex, 0); + pthread_cond_init(&cond, 0); my_atomic_rwlock_init(&rwl); lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used)); lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0, &my_charset_bin); - - pthread_attr_init(&attr); + pthread_attr_init(&thr_attr); + pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE - pthread_attr_getstacksize(&attr, &stacksize); + pthread_attr_getstacksize(&thr_attr, &stacksize); if (stacksize == 0) #endif - stacksize= PTHREAD_STACK_MIN; + stacksize = PTHREAD_STACK_MIN; + #ifdef MY_ATOMIC_MODE_RWLOCKS +#ifdef HPUX11 /* showed to be very slow (scheduler-related) */ +#define CYCLES 300 +#else #define CYCLES 3000 +#endif +#else +#ifdef HPUX11 +#define CYCLES 30000 #else #define CYCLES 300000 #endif +#endif #define THREADS 100 test_atomic("my_atomic_add32", test_atomic_add_handler, THREADS,CYCLES); @@ -305,6 +336,15 @@ int main() lf_hash_destroy(&lf_hash); lf_alloc_destroy(&lf_allocator); + + /* + workaround until we know why it crashes randomly on some machine + (BUG#22320). + */ + sleep(2); + pthread_mutex_destroy(&mutex); + pthread_cond_destroy(&cond); + pthread_attr_destroy(&thr_attr); my_atomic_rwlock_destroy(&rwl); my_end(0); return exit_status(); diff --git a/unittest/mytap/CMakeLists.txt b/unittest/mytap/CMakeLists.txt new file mode 100644 index 00000000000..2c0893226fa --- /dev/null +++ b/unittest/mytap/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (C) 2007 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; version 2 of the License. +# +# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +ADD_LIBRARY(mytap tap.c) diff --git a/unittest/mytap/Makefile.am b/unittest/mytap/Makefile.am index c02bcd3b49d..8feefb134bb 100644 --- a/unittest/mytap/Makefile.am +++ b/unittest/mytap/Makefile.am @@ -20,6 +20,8 @@ noinst_HEADERS = tap.h libmytap_a_SOURCES = tap.c +EXTRA_DIST = CMakeLists.txt + SUBDIRS = . t # Don't update the files from bitkeeper diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c index f9396adbd69..bda234ad71d 100644 --- a/unittest/mytap/tap.c +++ b/unittest/mytap/tap.c @@ -19,7 +19,7 @@ #include "tap.h" -#include "my_config.h" +#include "my_global.h" #include <stdlib.h> #include <stdarg.h> @@ -27,6 +27,16 @@ #include <string.h> #include <signal.h> +/* + Visual Studio 2003 does not know vsnprintf but knows _vsnprintf. + We don't put this #define in config-win.h because we prefer + my_vsnprintf everywhere instead, except when linking with libmysys + is not desirable - the case here. +*/ +#if defined(_MSC_VER) && ( _MSC_VER == 1310 ) +#define vsnprintf _vsnprintf +#endif + /** @defgroup MyTAP_Internal MyTAP Internals @@ -150,8 +160,10 @@ static signal_entry install_signal[]= { { SIGILL, handle_core_signal }, { SIGABRT, handle_core_signal }, { SIGFPE, handle_core_signal }, - { SIGSEGV, handle_core_signal }, - { SIGBUS, handle_core_signal } + { SIGSEGV, handle_core_signal } +#ifdef SIGBUS + , { SIGBUS, handle_core_signal } +#endif #ifdef SIGXCPU , { SIGXCPU, handle_core_signal } #endif @@ -172,6 +184,7 @@ void plan(int const count) { char *config= getenv("MYTAP_CONFIG"); + size_t i; if (config) skip_big_tests= strcmp(config, "big"); @@ -180,7 +193,7 @@ plan(int const count) /* Install signal handler */ - size_t i; + for (i= 0; i < sizeof(install_signal)/sizeof(*install_signal); ++i) signal(install_signal[i].signo, install_signal[i].handler); diff --git a/unittest/unit.pl b/unittest/unit.pl index b83132581f9..0b2a26446f0 100644 --- a/unittest/unit.pl +++ b/unittest/unit.pl @@ -66,7 +66,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/ || /-t\.exe\z/); }, @dirs; return @files; } @@ -102,7 +102,7 @@ sub run_cmd (@) { if (@files > 0) { # Removing the first './' from the file names foreach (@files) { s!^\./!! } - $ENV{'HARNESS_PERL_SWITCHES'} .= q" -e 'exec @ARGV'"; + $ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"'; runtests @files; } } |