2010-06-10 13:15:35 +02:00
|
|
|
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
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
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
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
|
2013-03-19 15:53:48 +01:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
Library for providing TAP support for testing C and C++ was written
|
|
|
|
by Mats Kindahl <mats@mysql.com>.
|
|
|
|
*/
|
2006-04-04 18:16:15 +02:00
|
|
|
|
|
|
|
#include "tap.h"
|
|
|
|
|
2009-11-17 21:29:26 -07:00
|
|
|
#include "my_global.h"
|
2006-08-25 13:53:16 +02:00
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2006-08-25 13:53:16 +02:00
|
|
|
#include <signal.h>
|
2006-04-04 18:16:15 +02:00
|
|
|
|
2009-11-17 21:29:26 -07:00
|
|
|
/*
|
|
|
|
Visual Studio 2003 does not know vsnprintf but knows _vsnprintf.
|
2010-07-23 17:14:04 -03:00
|
|
|
We don't put this #define elsewhere because we prefer my_vsnprintf
|
|
|
|
everywhere instead, except when linking with libmysys is not
|
|
|
|
desirable - the case here.
|
2009-11-17 21:29:26 -07:00
|
|
|
*/
|
|
|
|
#if defined(_MSC_VER) && ( _MSC_VER == 1310 )
|
|
|
|
#define vsnprintf _vsnprintf
|
|
|
|
#endif
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
/**
|
|
|
|
@defgroup MyTAP_Internal MyTAP Internals
|
|
|
|
|
|
|
|
Internal functions and data structures for the MyTAP implementation.
|
|
|
|
*/
|
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
/**
|
|
|
|
Test data structure.
|
|
|
|
|
|
|
|
Data structure containing all information about the test suite.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@ingroup MyTAP_Internal
|
2006-04-04 18:16:15 +02:00
|
|
|
*/
|
2010-06-10 13:15:35 +02:00
|
|
|
static TEST_DATA g_test = { NO_PLAN, 0, 0, "" };
|
2006-04-04 18:16:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Output stream for test report message.
|
|
|
|
|
|
|
|
The macro is just a temporary solution.
|
2006-10-20 21:50:08 +02:00
|
|
|
|
|
|
|
@ingroup MyTAP_Internal
|
2006-04-04 18:16:15 +02:00
|
|
|
*/
|
|
|
|
#define tapout stdout
|
|
|
|
|
|
|
|
/**
|
2006-04-10 17:06:12 +02:00
|
|
|
Emit the beginning of a test line, that is: "(not) ok", test number,
|
|
|
|
and description.
|
|
|
|
|
|
|
|
To emit the directive, use the emit_dir() function
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@ingroup MyTAP_Internal
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
@see emit_dir
|
2006-04-04 18:16:15 +02:00
|
|
|
|
|
|
|
@param pass 'true' if test passed, 'false' otherwise
|
|
|
|
@param fmt Description of test in printf() format.
|
|
|
|
@param ap Vararg list for the description string above.
|
|
|
|
*/
|
2006-04-10 17:06:12 +02:00
|
|
|
static void
|
2006-10-20 21:50:08 +02:00
|
|
|
vemit_tap(int pass, char const *fmt, va_list ap)
|
2006-04-04 18:16:15 +02:00
|
|
|
{
|
|
|
|
fprintf(tapout, "%sok %d%s",
|
|
|
|
pass ? "" : "not ",
|
|
|
|
++g_test.last,
|
|
|
|
(fmt && *fmt) ? " - " : "");
|
|
|
|
if (fmt && *fmt)
|
|
|
|
vfprintf(tapout, fmt, ap);
|
2010-06-10 13:15:35 +02:00
|
|
|
fflush(tapout);
|
2006-04-04 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-10 17:06:12 +02:00
|
|
|
/**
|
|
|
|
Emit a TAP directive.
|
|
|
|
|
2006-08-25 13:53:16 +02:00
|
|
|
TAP directives are comments after that have the form:
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
@code
|
|
|
|
ok 1 # skip reason for skipping
|
|
|
|
not ok 2 # todo some text explaining what remains
|
|
|
|
@endcode
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@ingroup MyTAP_Internal
|
|
|
|
|
2006-04-10 17:06:12 +02:00
|
|
|
@param dir Directive as a string
|
2006-10-20 21:50:08 +02:00
|
|
|
@param why Explanation string
|
2006-04-10 17:06:12 +02:00
|
|
|
*/
|
|
|
|
static void
|
2006-10-20 21:50:08 +02:00
|
|
|
emit_dir(const char *dir, const char *why)
|
2006-04-04 18:16:15 +02:00
|
|
|
{
|
2006-10-20 21:50:08 +02:00
|
|
|
fprintf(tapout, " # %s %s", dir, why);
|
2010-06-10 13:15:35 +02:00
|
|
|
fflush(tapout);
|
2006-04-04 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-10 17:06:12 +02:00
|
|
|
/**
|
|
|
|
Emit a newline to the TAP output stream.
|
2006-10-20 21:50:08 +02:00
|
|
|
|
|
|
|
@ingroup MyTAP_Internal
|
2006-04-10 17:06:12 +02:00
|
|
|
*/
|
|
|
|
static void
|
2006-04-04 18:16:15 +02:00
|
|
|
emit_endl()
|
|
|
|
{
|
|
|
|
fprintf(tapout, "\n");
|
2010-06-10 13:15:35 +02:00
|
|
|
fflush(tapout);
|
2006-04-04 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
2006-08-25 13:53:16 +02:00
|
|
|
static void
|
|
|
|
handle_core_signal(int signo)
|
|
|
|
{
|
|
|
|
BAIL_OUT("Signal %d thrown", signo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BAIL_OUT(char const *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
fprintf(tapout, "Bail out! ");
|
|
|
|
vfprintf(tapout, fmt, ap);
|
|
|
|
emit_endl();
|
|
|
|
va_end(ap);
|
|
|
|
exit(255);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
void
|
|
|
|
diag(char const *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
fprintf(tapout, "# ");
|
|
|
|
vfprintf(tapout, fmt, ap);
|
2006-08-25 13:53:16 +02:00
|
|
|
emit_endl();
|
2006-04-04 18:16:15 +02:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2006-08-25 13:53:16 +02:00
|
|
|
typedef struct signal_entry {
|
|
|
|
int signo;
|
|
|
|
void (*handler)(int);
|
|
|
|
} signal_entry;
|
|
|
|
|
|
|
|
static signal_entry install_signal[]= {
|
|
|
|
{ SIGQUIT, handle_core_signal },
|
|
|
|
{ SIGILL, handle_core_signal },
|
|
|
|
{ SIGABRT, handle_core_signal },
|
|
|
|
{ SIGFPE, handle_core_signal },
|
2009-11-17 21:29:26 -07:00
|
|
|
{ SIGSEGV, handle_core_signal }
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
#ifdef SIGBUS
|
2009-11-17 21:29:26 -07:00
|
|
|
, { SIGBUS, handle_core_signal }
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
#endif
|
2006-10-12 22:42:43 +02:00
|
|
|
#ifdef SIGXCPU
|
|
|
|
, { SIGXCPU, handle_core_signal }
|
|
|
|
#endif
|
|
|
|
#ifdef SIGXCPU
|
|
|
|
, { SIGXFSZ, handle_core_signal }
|
|
|
|
#endif
|
|
|
|
#ifdef SIGXCPU
|
|
|
|
, { SIGSYS, handle_core_signal }
|
|
|
|
#endif
|
|
|
|
#ifdef SIGXCPU
|
|
|
|
, { SIGTRAP, handle_core_signal }
|
|
|
|
#endif
|
2006-08-25 13:53:16 +02:00
|
|
|
};
|
2006-04-04 18:16:15 +02:00
|
|
|
|
2009-11-17 21:29:26 -07:00
|
|
|
int skip_big_tests= 1;
|
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
void
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
plan(int count)
|
2006-04-04 18:16:15 +02:00
|
|
|
{
|
2009-11-17 21:29:26 -07:00
|
|
|
char *config= getenv("MYTAP_CONFIG");
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (config)
|
|
|
|
skip_big_tests= strcmp(config, "big");
|
|
|
|
|
|
|
|
setvbuf(tapout, 0, _IONBF, 0); /* provide output at once */
|
2006-08-25 13:53:16 +02:00
|
|
|
/*
|
|
|
|
Install signal handler
|
|
|
|
*/
|
2009-11-17 21:29:26 -07:00
|
|
|
|
2006-08-25 13:53:16 +02:00
|
|
|
for (i= 0; i < sizeof(install_signal)/sizeof(*install_signal); ++i)
|
|
|
|
signal(install_signal[i].signo, install_signal[i].handler);
|
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
g_test.plan= count;
|
|
|
|
switch (count)
|
|
|
|
{
|
|
|
|
case NO_PLAN:
|
|
|
|
break;
|
|
|
|
default:
|
2006-04-10 17:06:12 +02:00
|
|
|
if (count > 0)
|
2010-06-10 13:15:35 +02:00
|
|
|
{
|
2006-04-04 18:16:15 +02:00
|
|
|
fprintf(tapout, "1..%d\n", count);
|
2010-06-10 13:15:35 +02:00
|
|
|
fflush(tapout);
|
|
|
|
}
|
2006-04-04 18:16:15 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
skip_all(char const *reason, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, reason);
|
|
|
|
fprintf(tapout, "1..0 # skip ");
|
|
|
|
vfprintf(tapout, reason, ap);
|
2010-06-10 13:15:35 +02:00
|
|
|
fflush(tapout);
|
2006-04-04 18:16:15 +02:00
|
|
|
va_end(ap);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
ok(int pass, char const *fmt, ...)
|
2006-04-04 18:16:15 +02:00
|
|
|
{
|
2006-04-13 13:01:57 -07:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
2006-04-04 18:16:15 +02:00
|
|
|
if (!pass && *g_test.todo == '\0')
|
|
|
|
++g_test.failed;
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
vemit_tap(pass, fmt, ap);
|
2006-04-04 18:16:15 +02:00
|
|
|
va_end(ap);
|
|
|
|
if (*g_test.todo != '\0')
|
2006-04-10 17:06:12 +02:00
|
|
|
emit_dir("todo", g_test.todo);
|
2006-04-04 18:16:15 +02:00
|
|
|
emit_endl();
|
|
|
|
}
|
|
|
|
|
2010-10-20 11:40:04 -02:00
|
|
|
void
|
|
|
|
ok1(int const pass)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
memset(&ap, 0, sizeof(ap));
|
|
|
|
|
|
|
|
if (!pass && *g_test.todo == '\0')
|
|
|
|
++g_test.failed;
|
|
|
|
|
|
|
|
vemit_tap(pass, NULL, ap);
|
|
|
|
|
|
|
|
if (*g_test.todo != '\0')
|
|
|
|
emit_dir("todo", g_test.todo);
|
|
|
|
|
|
|
|
emit_endl();
|
|
|
|
}
|
2006-04-04 18:16:15 +02:00
|
|
|
|
|
|
|
void
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
skip(int how_many, char const *fmt, ...)
|
2006-04-04 18:16:15 +02:00
|
|
|
{
|
|
|
|
char reason[80];
|
|
|
|
if (fmt && *fmt)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsnprintf(reason, sizeof(reason), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
reason[0] = '\0';
|
|
|
|
|
|
|
|
while (how_many-- > 0)
|
|
|
|
{
|
|
|
|
va_list ap;
|
2006-11-27 01:47:38 +02:00
|
|
|
memset((char*) &ap, 0, sizeof(ap)); /* Keep compiler happy */
|
2006-10-20 21:50:08 +02:00
|
|
|
vemit_tap(1, NULL, ap);
|
2006-04-10 17:06:12 +02:00
|
|
|
emit_dir("skip", reason);
|
2006-04-04 18:16:15 +02:00
|
|
|
emit_endl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
todo_start(char const *message, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, message);
|
|
|
|
vsnprintf(g_test.todo, sizeof(g_test.todo), message, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
todo_end()
|
|
|
|
{
|
|
|
|
*g_test.todo = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
int exit_status() {
|
|
|
|
/*
|
|
|
|
If there were no plan, we write one last instead.
|
|
|
|
*/
|
|
|
|
if (g_test.plan == NO_PLAN)
|
|
|
|
plan(g_test.last);
|
|
|
|
|
|
|
|
if (g_test.plan != g_test.last)
|
|
|
|
{
|
2006-06-17 16:20:39 +02:00
|
|
|
diag("%d tests planned but%s %d executed",
|
|
|
|
g_test.plan, (g_test.plan > g_test.last ? " only" : ""), g_test.last);
|
2006-04-04 18:16:15 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_test.failed > 0)
|
|
|
|
{
|
|
|
|
diag("Failed %d tests!", g_test.failed);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-04-10 17:06:12 +02:00
|
|
|
/**
|
|
|
|
@mainpage Testing C and C++ using MyTAP
|
|
|
|
|
|
|
|
@section IntroSec Introduction
|
|
|
|
|
|
|
|
Unit tests are used to test individual components of a system. In
|
|
|
|
contrast, functional tests usually test the entire system. The
|
|
|
|
rationale is that each component should be correct if the system is
|
|
|
|
to be correct. Unit tests are usually small pieces of code that
|
|
|
|
tests an individual function, class, a module, or other unit of the
|
|
|
|
code.
|
|
|
|
|
|
|
|
Observe that a correctly functioning system can be built from
|
|
|
|
"faulty" components. The problem with this approach is that as the
|
|
|
|
system evolves, the bugs surface in unexpected ways, making
|
|
|
|
maintenance harder.
|
|
|
|
|
|
|
|
The advantages of using unit tests to test components of the system
|
|
|
|
are several:
|
|
|
|
|
|
|
|
- The unit tests can make a more thorough testing than the
|
|
|
|
functional tests by testing correctness even for pathological use
|
|
|
|
(which shouldn't be present in the system). This increases the
|
|
|
|
overall robustness of the system and makes maintenance easier.
|
|
|
|
|
|
|
|
- It is easier and faster to find problems with a malfunctioning
|
|
|
|
component than to find problems in a malfunctioning system. This
|
|
|
|
shortens the compile-run-edit cycle and therefore improves the
|
|
|
|
overall performance of development.
|
|
|
|
|
|
|
|
- The component has to support at least two uses: in the system and
|
|
|
|
in a unit test. This leads to more generic and stable interfaces
|
|
|
|
and in addition promotes the development of reusable components.
|
|
|
|
|
|
|
|
For example, the following are typical functional tests:
|
|
|
|
- Does transactions work according to specifications?
|
|
|
|
- Can we connect a client to the server and execute statements?
|
|
|
|
|
|
|
|
In contrast, the following are typical unit tests:
|
|
|
|
|
|
|
|
- Can the 'String' class handle a specified list of character sets?
|
|
|
|
- Does all operations for 'my_bitmap' produce the correct result?
|
|
|
|
- Does all the NIST test vectors for the AES implementation encrypt
|
|
|
|
correctly?
|
|
|
|
|
|
|
|
|
|
|
|
@section UnitTest Writing unit tests
|
|
|
|
|
|
|
|
The purpose of writing unit tests is to use them to drive component
|
2006-10-20 21:50:08 +02:00
|
|
|
development towards a solution that passes the tests. This means that the
|
2006-04-10 17:06:12 +02:00
|
|
|
unit tests has to be as complete as possible, testing at least:
|
|
|
|
|
|
|
|
- Normal input
|
|
|
|
- Borderline cases
|
|
|
|
- Faulty input
|
|
|
|
- Error handling
|
|
|
|
- Bad environment
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@subsection NormalSubSec Normal input
|
|
|
|
|
|
|
|
This is to test that the component have the expected behaviour.
|
|
|
|
This is just plain simple: test that it works. For example, test
|
|
|
|
that you can unpack what you packed, adding gives the sum, pincing
|
|
|
|
the duck makes it quack.
|
|
|
|
|
|
|
|
This is what everybody does when they write tests.
|
|
|
|
|
|
|
|
|
|
|
|
@subsection BorderlineTests Borderline cases
|
|
|
|
|
|
|
|
If you have a size anywhere for your component, does it work for
|
|
|
|
size 1? Size 0? Sizes close to <code>UINT_MAX</code>?
|
|
|
|
|
|
|
|
It might not be sensible to have a size 0, so in this case it is
|
|
|
|
not a borderline case, but rather a faulty input (see @ref
|
|
|
|
FaultyInputTests).
|
|
|
|
|
|
|
|
|
|
|
|
@subsection FaultyInputTests Faulty input
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
Does your bitmap handle 0 bits size? Well, it might not be designed
|
|
|
|
for it, but is should <em>not</em> crash the application, but
|
|
|
|
rather produce an error. This is called defensive programming.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
Unfortunately, adding checks for values that should just not be
|
|
|
|
entered at all is not always practical: the checks cost cycles and
|
|
|
|
might cost more than it's worth. For example, some functions are
|
|
|
|
designed so that you may not give it a null pointer. In those
|
|
|
|
cases it's not sensible to pass it <code>NULL</code> just to see it
|
|
|
|
crash.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
Since every experienced programmer add an <code>assert()</code> to
|
|
|
|
ensure that you get a proper failure for the debug builds when a
|
|
|
|
null pointer passed (you add asserts too, right?), you will in this
|
|
|
|
case instead have a controlled (early) crash in the debug build.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@subsection ErrorHandlingTests Error handling
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
This is testing that the errors your component is designed to give
|
|
|
|
actually are produced. For example, testing that trying to open a
|
|
|
|
non-existing file produces a sensible error code.
|
|
|
|
|
|
|
|
|
|
|
|
@subsection BadEnvironmentTests Environment
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
Sometimes, modules has to behave well even when the environment
|
2006-10-20 21:50:08 +02:00
|
|
|
fails to work correctly. Typical examples are when the computer is
|
|
|
|
out of dynamic memory or when the disk is full. You can emulate
|
|
|
|
this by replacing, e.g., <code>malloc()</code> with your own
|
|
|
|
version that will work for a while, but then fail. Some things are
|
|
|
|
worth to keep in mind here:
|
|
|
|
|
|
|
|
- Make sure to make the function fail deterministically, so that
|
|
|
|
you really can repeat the test.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
- Make sure that it doesn't just fail immediately. The unit might
|
|
|
|
have checks for the first case, but might actually fail some time
|
|
|
|
in the near future.
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
|
|
|
|
@section UnitTest How to structure a unit test
|
2006-04-10 17:06:12 +02:00
|
|
|
|
|
|
|
In this section we will give some advice on how to structure the
|
2006-10-20 21:50:08 +02:00
|
|
|
unit tests to make the development run smoothly. The basic
|
|
|
|
structure of a test is:
|
|
|
|
|
|
|
|
- Plan
|
|
|
|
- Test
|
|
|
|
- Report
|
|
|
|
|
|
|
|
|
|
|
|
@subsection TestPlanning Plan the test
|
|
|
|
|
|
|
|
Planning the test means telling how many tests there are. In the
|
|
|
|
event that one of the tests causes a crash, it is then possible to
|
|
|
|
see that there are fewer tests than expected, and print a proper
|
|
|
|
error message.
|
|
|
|
|
|
|
|
To plan a test, use the @c plan() function in the following manner:
|
|
|
|
|
|
|
|
@code
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
plan(5);
|
|
|
|
.
|
|
|
|
.
|
|
|
|
.
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
If you don't call the @c plan() function, the number of tests
|
|
|
|
executed will be printed at the end. This is intended to be used
|
|
|
|
while developing the unit and you are constantly adding tests. It
|
|
|
|
is not indented to be used after the unit has been released.
|
|
|
|
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
@subsection TestRunning Execute the test
|
|
|
|
|
|
|
|
To report the status of a test, the @c ok() function is used in the
|
|
|
|
following manner:
|
|
|
|
|
|
|
|
@code
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
plan(5);
|
|
|
|
ok(ducks == paddling_ducks,
|
|
|
|
"%d ducks did not paddle", ducks - paddling_ducks);
|
|
|
|
.
|
|
|
|
.
|
|
|
|
.
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
This will print a test result line on the standard output in TAP
|
|
|
|
format, which allows TAP handling frameworks (like Test::Harness)
|
|
|
|
to parse the status of the test.
|
|
|
|
|
|
|
|
@subsection TestReport Report the result of the test
|
|
|
|
|
|
|
|
At the end, a complete test report should be written, with some
|
|
|
|
statistics. If the test returns EXIT_SUCCESS, all tests were
|
|
|
|
successfull, otherwise at least one test failed.
|
|
|
|
|
|
|
|
To get a TAP complient output and exit status, report the exit
|
|
|
|
status in the following manner:
|
|
|
|
|
|
|
|
@code
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
plan(5);
|
|
|
|
ok(ducks == paddling_ducks,
|
|
|
|
"%d ducks did not paddle", ducks - paddling_ducks);
|
|
|
|
.
|
|
|
|
.
|
|
|
|
.
|
|
|
|
return exit_status();
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@section DontDoThis Ways to not do unit testing
|
|
|
|
|
|
|
|
In this section, we'll go through some quite common ways to write
|
|
|
|
tests that are <em>not</em> a good idea.
|
|
|
|
|
|
|
|
@subsection BreadthFirstTests Doing breadth-first testing
|
|
|
|
|
|
|
|
If you're writing a library with several functions, don't test all
|
|
|
|
functions using size 1, then all functions using size 2, etc. If a
|
|
|
|
test for size 42 fails, you have no easy way of tracking down why
|
|
|
|
it failed.
|
|
|
|
|
|
|
|
It is better to concentrate on getting one function to work at a
|
|
|
|
time, which means that you test each function for all sizes that
|
|
|
|
you think is reasonable. Then you continue with the next function,
|
|
|
|
doing the same. This is usually also the way that a library is
|
|
|
|
developed (one function at a time) so stick to testing that is
|
|
|
|
appropriate for now the unit is developed.
|
|
|
|
|
|
|
|
@subsection JustToBeSafeTest Writing unnecessarily large tests
|
|
|
|
|
|
|
|
Don't write tests that use parameters in the range 1-1024 unless
|
|
|
|
you have a very good reason to belive that the component will
|
|
|
|
succeed for 562 but fail for 564 (the numbers picked are just
|
|
|
|
examples).
|
|
|
|
|
|
|
|
It is very common to write extensive tests "just to be safe."
|
|
|
|
Having a test suite with a lot of values might give you a warm
|
|
|
|
fuzzy feeling, but it doesn't really help you find the bugs. Good
|
|
|
|
tests fail; seriously, if you write a test that you expect to
|
|
|
|
succeed, you don't need to write it. If you think that it
|
|
|
|
<em>might</em> fail, <em>then</em> you should write it.
|
|
|
|
|
|
|
|
Don't take this as an excuse to avoid writing any tests at all
|
|
|
|
"since I make no mistakes" (when it comes to this, there are two
|
|
|
|
kinds of people: those who admit they make mistakes, and those who
|
|
|
|
don't); rather, this means that there is no reason to test that
|
|
|
|
using a buffer with size 100 works when you have a test for buffer
|
|
|
|
size 96.
|
|
|
|
|
|
|
|
The drawback is that the test suite takes longer to run, for little
|
|
|
|
or no benefit. It is acceptable to do a exhaustive test if it
|
|
|
|
doesn't take too long to run and it is quite common to do an
|
|
|
|
exhaustive test of a function for a small set of values.
|
|
|
|
Use your judgment to decide what is excessive: your milage may
|
|
|
|
vary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
@example simple.t.c
|
|
|
|
|
|
|
|
This is an simple example of how to write a test using the
|
|
|
|
library. The output of this program is:
|
|
|
|
|
|
|
|
@code
|
|
|
|
1..1
|
|
|
|
# Testing basic functions
|
|
|
|
ok 1 - Testing gcs()
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The basic structure is: plan the number of test points using the
|
|
|
|
plan() function, perform the test and write out the result of each
|
|
|
|
test point using the ok() function, print out a diagnostics message
|
|
|
|
using diag(), and report the result of the test by calling the
|
|
|
|
exit_status() function. Observe that this test does excessive
|
|
|
|
testing (see @ref JustToBeSafeTest), but the test point doesn't
|
|
|
|
take very long time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
@example todo.t.c
|
|
|
|
|
|
|
|
This example demonstrates how to use the <code>todo_start()</code>
|
|
|
|
and <code>todo_end()</code> function to mark a sequence of tests to
|
|
|
|
be done. Observe that the tests are assumed to fail: if any test
|
|
|
|
succeeds, it is considered a "bonus".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
@example skip.t.c
|
|
|
|
|
|
|
|
This is an example of how the <code>SKIP_BLOCK_IF</code> can be
|
|
|
|
used to skip a predetermined number of tests. Observe that the
|
|
|
|
macro actually skips the following statement, but it's not sensible
|
|
|
|
to use anything than a block.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
@example skip_all.t.c
|
2006-04-10 17:06:12 +02:00
|
|
|
|
2006-10-20 21:50:08 +02:00
|
|
|
Sometimes, you skip an entire test because it's testing a feature
|
|
|
|
that doesn't exist on the system that you're testing. To skip an
|
|
|
|
entire test, use the <code>skip_all()</code> function according to
|
|
|
|
this example.
|
2006-04-10 17:06:12 +02:00
|
|
|
*/
|