3790 Tor Didriksen 2012-05-07
Refactoring: cleanup server setup/teardown for large/server tests.
Merge all field tests into one executable (to save some time/space when linking)
added:
unittest/gunit/gunit_test_main_server.cc
modified:
unittest/gunit/CMakeLists.txt
unittest/gunit/copy_info-t.cc
unittest/gunit/create_field-t.cc
unittest/gunit/decimal-t.cc
unittest/gunit/field-t.cc
unittest/gunit/field_date-t.cc
unittest/gunit/field_datetime-t.cc
unittest/gunit/field_long-t.cc
unittest/gunit/field_newdecimal-t.cc
unittest/gunit/field_temporal_utils.h
unittest/gunit/field_timestamp-t.cc
unittest/gunit/get_diagnostics-t.cc
unittest/gunit/item-t.cc
unittest/gunit/item_func_now_local-t.cc
unittest/gunit/join_tab_sort-t.cc
unittest/gunit/my_decimal-t.cc
unittest/gunit/opt_range-t.cc
unittest/gunit/segfault-t.cc
unittest/gunit/sql_table-t.cc
unittest/gunit/test_utils.cc
unittest/gunit/test_utils.h
3789 Jorgen Loland 2012-05-07
Refactoring: change return type of Field::store(),
Item::save_in_field and friends from poorly defined int values
to enum.
@ mysql-test/extra/rpl_tests/rpl_extra_col_master.test
Incorrect type for default value
@ mysql-test/r/ctype_ucs.result
Added test for error message in different charset
@ mysql-test/r/type_bit.result
Test insert of no bits. Should be treated as 0.
@ mysql-test/t/ctype_ucs.test
Added test for error message in different charset
@ mysql-test/t/type_bit.test
Test insert of no bits. Should be treated as 0.
added:
unittest/gunit/field_date-t.cc
unittest/gunit/field_datetime-t.cc
unittest/gunit/field_long-t.cc
unittest/gunit/field_newdecimal-t.cc
unittest/gunit/field_temporal_utils.h
modified:
mysql-test/extra/rpl_tests/rpl_extra_col_master.test
mysql-test/r/ctype_ucs.result
mysql-test/r/type_bit.result
mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result
mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result
mysql-test/t/ctype_ucs.test
mysql-test/t/type_bit.test
sql-common/my_time.c
sql/field.cc
sql/field.h
sql/field_conv.cc
sql/item.cc
sql/item.h
sql/item_cmpfunc.cc
sql/item_func.cc
sql/item_func.h
sql/item_strfunc.h
sql/item_timefunc.cc
sql/item_timefunc.h
sql/opt_range.cc
sql/sql_base.cc
sql/sql_select.h
sql/unireg.cc
unittest/gunit/CMakeLists.txt
unittest/gunit/fake_table.h
unittest/gunit/field-t.cc
unittest/gunit/item-t.cc
=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/CMakeLists.txt 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -195,9 +195,14 @@ INCLUDE_DIRECTORIES(
)
# main-wrapper library (with tap-compatible option).
-ADD_LIBRARY(gunit STATIC
+ADD_LIBRARY(gunit_small STATIC
gunit_test_main.cc tap_event_listener.cc thread_utils.cc)
-TARGET_LINK_LIBRARIES(gunit mysys mytap dbug strings ${GTEST_LIBRARIES})
+ADD_LIBRARY(gunit_large STATIC
+ gunit_test_main_server.cc test_utils.cc tap_event_listener.cc thread_utils.cc)
+ADD_DEPENDENCIES(gunit_small GenError)
+ADD_DEPENDENCIES(gunit_large GenError)
+TARGET_LINK_LIBRARIES(gunit_small mysys mytap dbug strings ${GTEST_LIBRARIES})
+TARGET_LINK_LIBRARIES(gunit_large mysys mytap dbug strings ${GTEST_LIBRARIES})
MESSAGE(STATUS "GTEST_LIBRARIES:${GTEST_LIBRARIES}")
# Add some defines.
@@ -252,25 +257,20 @@ SET(SERVER_TESTS
create_field
delayable_insert_operation
field
- field_date
- field_datetime
- field_long
- field_newdecimal
- field_timestamp
+ get_diagnostics
item
item_func_now_local
+ join_tab_sort
my_decimal
opt_range
opt_trace
- sql_table
- get_diagnostics
segfault
- join_tab_sort
+ sql_table
)
FOREACH(test ${TESTS})
ADD_EXECUTABLE(${test}-t ${test}-t.cc)
- TARGET_LINK_LIBRARIES(${test}-t gunit sqlgunitlib strings dbug regex)
+ TARGET_LINK_LIBRARIES(${test}-t gunit_small sqlgunitlib strings dbug regex)
IF(APPLE AND GTEST_DYLIB_LOCATION)
ADD_CUSTOM_COMMAND(TARGET ${test}-t POST_BUILD
COMMAND install_name_tool -change
@@ -282,12 +282,13 @@ ENDFOREACH()
FOREACH(test ${SERVER_TESTS})
IF(WIN32)
- ADD_EXECUTABLE(${test}-t ${test}-t.cc test_utils.cc ../../sql/nt_servc.cc)
+ ADD_EXECUTABLE(${test}-t ${test}-t.cc ../../sql/nt_servc.cc)
ELSE()
- ADD_EXECUTABLE(${test}-t ${test}-t.cc test_utils.cc)
+ ADD_EXECUTABLE(${test}-t ${test}-t.cc)
ENDIF()
TARGET_LINK_LIBRARIES(${test}-t sql binlog rpl master slave sql)
- TARGET_LINK_LIBRARIES(${test}-t gunit sqlgunitlib strings dbug regex mysys)
+ TARGET_LINK_LIBRARIES(${test}-t gunit_large strings dbug regex mysys)
+ TARGET_LINK_LIBRARIES(${test}-t sql binlog rpl master slave sql)
IF(APPLE AND GTEST_DYLIB_LOCATION)
ADD_CUSTOM_COMMAND(TARGET ${test}-t POST_BUILD
COMMAND install_name_tool -change
=== modified file 'unittest/gunit/copy_info-t.cc'
--- a/unittest/gunit/copy_info-t.cc 2012-01-31 15:16:16 +0000
+++ b/unittest/gunit/copy_info-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -38,12 +38,7 @@ using my_testing::Mock_error_handler;
class CopyInfoTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
-
virtual void TearDown() { initializer.TearDown(); }
Server_initializer initializer;
=== modified file 'unittest/gunit/create_field-t.cc'
--- a/unittest/gunit/create_field-t.cc 2012-01-31 15:16:16 +0000
+++ b/unittest/gunit/create_field-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -30,12 +30,7 @@ using my_testing::Mock_error_handler;
class CreateFieldTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
-
virtual void TearDown() { initializer.TearDown(); }
Server_initializer initializer;
=== modified file 'unittest/gunit/decimal-t.cc'
--- a/unittest/gunit/decimal-t.cc 2012-04-27 11:57:38 +0000
+++ b/unittest/gunit/decimal-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
=== modified file 'unittest/gunit/field-t.cc'
--- a/unittest/gunit/field-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field-t.cc 2012-05-07 12:05:48 +0000
@@ -32,9 +32,6 @@ using my_testing::Mock_error_handler;
class FieldTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
virtual void TearDown() { initializer.TearDown(); }
@@ -409,3 +406,9 @@ TEST_F(FieldTest, CopyFieldSet)
}
+
+#include "field_date-t.cc"
+#include "field_datetime-t.cc"
+#include "field_long-t.cc"
+#include "field_newdecimal-t.cc"
+#include "field_timestamp-t.cc"
=== modified file 'unittest/gunit/field_date-t.cc'
--- a/unittest/gunit/field_date-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field_date-t.cc 2012-05-07 12:05:48 +0000
@@ -28,12 +28,9 @@ namespace {
using my_testing::Server_initializer;
using my_testing::Mock_error_handler;
-class FieldTest : public ::testing::Test
+class FieldDateTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
virtual void TearDown() { initializer.TearDown(); }
@@ -42,6 +39,28 @@ protected:
Server_initializer initializer;
Field_set *create_field_set(TYPELIB *tl);
+
+ // Store zero date using different combinations of SQL modes
+ static const int no_modes= 4;
+ static const sql_mode_t strict_modes[no_modes];
+
+ static const type_conversion_status nozero_expected_status[];
+};
+
+const sql_mode_t FieldDateTest::strict_modes[no_modes]=
+{
+ 0,
+ MODE_STRICT_TRANS_TABLES,
+ MODE_STRICT_ALL_TABLES,
+ MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES
+};
+
+const type_conversion_status FieldDateTest::nozero_expected_status[]=
+{
+ TYPE_NOTE_TIME_TRUNCATED,
+ TYPE_ERR_BAD_VALUE,
+ TYPE_ERR_BAD_VALUE,
+ TYPE_ERR_BAD_VALUE
};
@@ -74,7 +93,7 @@ public:
};
-TEST_F(FieldTest, StoreLegalStringValues)
+TEST_F(FieldDateTest, StoreLegalStringValues)
{
Mock_field_date field_date;
Fake_TABLE table(&field_date);
@@ -98,7 +117,7 @@ TEST_F(FieldTest, StoreLegalStringValues
}
}
-TEST_F(FieldTest, StoreIllegalStringValues)
+TEST_F(FieldDateTest, StoreIllegalStringValues)
{
Mock_field_date field_date;
Fake_TABLE table(&field_date);
@@ -145,16 +164,6 @@ TEST_F(FieldTest, StoreIllegalStringValu
}
-// Store zero date using different combinations of SQL modes
-static const int no_modes= 4;
-static const sql_mode_t strict_modes[no_modes]=
- {
- 0,
- MODE_STRICT_TRANS_TABLES,
- MODE_STRICT_ALL_TABLES,
- MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES
- };
-
/**
Strictness mode test 1:
@@ -163,7 +172,7 @@ static const sql_mode_t strict_modes[no_
(neither NO_ZERO_DATE or NO_ZERO_IN_DATE are set). There should be
no errors, warnings or notes.
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroRestrictions)
+TEST_F(FieldDateTest, StoreZeroDateSqlModeNoZeroRestrictions)
{
Mock_field_date field_date;
Fake_TABLE table(&field_date);
@@ -203,14 +212,6 @@ TEST_F(FieldTest, StoreZeroDateSqlMode_N
}
-static const type_conversion_status nozero_expected_status[]=
- {
- TYPE_NOTE_TIME_TRUNCATED,
- TYPE_ERR_BAD_VALUE,
- TYPE_ERR_BAD_VALUE,
- TYPE_ERR_BAD_VALUE
- };
-
/**
Strictness mode test 2:
@@ -218,7 +219,7 @@ static const type_conversion_status noze
should be no errors, warnings or notes unless the entire date is
zero: "0000-00-00"
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroDate)
+TEST_F(FieldDateTest, StoreZeroDateSqlModeNoZeroDate)
{
Mock_field_date field_date;
Fake_TABLE table(&field_date);
@@ -279,7 +280,7 @@ TEST_F(FieldTest, StoreZeroDateSqlMode_N
Try storing dates with zeroes when NO_ZERO_IN_DATE flag is set. There
should be no errors unless either month or day is zero.
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroInDate)
+TEST_F(FieldDateTest, StoreZeroDateSqlModeNoZeroInDate)
{
Mock_field_date field_date;
Fake_TABLE table(&field_date);
=== modified file 'unittest/gunit/field_datetime-t.cc'
--- a/unittest/gunit/field_datetime-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field_datetime-t.cc 2012-05-07 12:05:48 +0000
@@ -28,12 +28,9 @@ namespace {
using my_testing::Server_initializer;
using my_testing::Mock_error_handler;
-class FieldTest : public ::testing::Test
+class FieldDatetimeTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
virtual void TearDown() { initializer.TearDown(); }
@@ -75,7 +72,7 @@ public:
};
-TEST_F(FieldTest, StoreLegalStringValues)
+TEST_F(FieldDatetimeTest, StoreLegalStringValues)
{
char buff[MAX_FIELD_WIDTH];
String str(buff, sizeof(buff), &my_charset_bin);
@@ -105,7 +102,7 @@ TEST_F(FieldTest, StoreLegalStringValues
}
-TEST_F(FieldTest, StoreIllegalStringValues)
+TEST_F(FieldDatetimeTest, StoreIllegalStringValues)
{
Mock_field_datetime field_dt;
Fake_TABLE table(&field_dt);
@@ -188,7 +185,7 @@ static const sql_mode_t strict_modes[no_
(neither NO_ZERO_DATE or NO_ZERO_IN_DATE are set). There should be
no errors, warnings or notes.
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroRestrictions)
+TEST_F(FieldDatetimeTest, StoreZeroDateSqlModeNoZeroRestrictions)
{
Mock_field_datetime field_dt;
Fake_TABLE table(&field_dt);
@@ -249,7 +246,7 @@ static const type_conversion_status noze
should be no errors, warnings or notes unless the entire date is
zero: "0000-00-00"
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroDate)
+TEST_F(FieldDatetimeTest, StoreZeroDateSqlModeNoZeroDate)
{
Mock_field_datetime field_dt;
Fake_TABLE table(&field_dt);
@@ -310,7 +307,7 @@ TEST_F(FieldTest, StoreZeroDateSqlMode_N
Try storing dates with zeroes when NO_ZERO_IN_DATE flag is set. There
should be no errors unless either month or day is zero.
*/
-TEST_F(FieldTest, StoreZeroDateSqlMode_NoZeroInDate)
+TEST_F(FieldDatetimeTest, StoreZeroDateSqlModeNoZeroInDate)
{
Mock_field_datetime field_dt;
Fake_TABLE table(&field_dt);
=== modified file 'unittest/gunit/field_long-t.cc'
--- a/unittest/gunit/field_long-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field_long-t.cc 2012-05-07 12:05:48 +0000
@@ -27,12 +27,9 @@ namespace {
using my_testing::Server_initializer;
using my_testing::Mock_error_handler;
-class FieldTest : public ::testing::Test
+class FieldLongTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
virtual void TearDown() { initializer.TearDown(); }
@@ -102,7 +99,7 @@ void test_store_string(Field_long *field
}
-TEST_F(FieldTest, StoreLegalIntValues)
+TEST_F(FieldLongTest, StoreLegalIntValues)
{
Mock_field_long field_long;
Fake_TABLE table(&field_long);
@@ -142,7 +139,7 @@ TEST_F(FieldTest, StoreLegalIntValues)
}
// Values higher and lower than valid range for the Field_long
-TEST_F(FieldTest, StoreOutOfRangeIntValues)
+TEST_F(FieldLongTest, StoreOutOfRangeIntValues)
{
Mock_field_long field_long;
Fake_TABLE table(&field_long);
@@ -184,7 +181,7 @@ TEST_F(FieldTest, StoreOutOfRangeIntValu
}
-TEST_F(FieldTest, StoreLegalStringValues)
+TEST_F(FieldLongTest, StoreLegalStringValues)
{
Mock_field_long field_long;
@@ -226,7 +223,8 @@ TEST_F(FieldTest, StoreLegalStringValues
field_long.unsigned_flag= true;
{
SCOPED_TRACE("");
- test_store_string(&field_long, STRING_WITH_LEN(max_int_plus1), INT_MAX32+1,
+ test_store_string(&field_long, STRING_WITH_LEN(max_int_plus1),
+ INT_MAX32 + 1LL,
0, TYPE_OK);
}
{
@@ -237,7 +235,7 @@ TEST_F(FieldTest, StoreLegalStringValues
}
-TEST_F(FieldTest, StoreIllegalStringValues)
+TEST_F(FieldLongTest, StoreIllegalStringValues)
{
Mock_field_long field_long;
@@ -325,7 +323,7 @@ TEST_F(FieldTest, StoreIllegalStringValu
}
}
-TEST_F(FieldTest, StoreNullValue)
+TEST_F(FieldLongTest, StoreNullValue)
{
Mock_field_long field_long;
=== modified file 'unittest/gunit/field_newdecimal-t.cc'
--- a/unittest/gunit/field_newdecimal-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field_newdecimal-t.cc 2012-05-07 12:05:48 +0000
@@ -30,12 +30,9 @@ namespace {
using my_testing::Server_initializer;
using my_testing::Mock_error_handler;
-class FieldTest : public ::testing::Test
+class FieldNewDecimalTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
virtual void TearDown() { initializer.TearDown(); }
@@ -102,7 +99,7 @@ public:
};
-TEST_F(FieldTest, StoreLegalStringValues)
+TEST_F(FieldNewDecimalTest, StoreLegalStringValues)
{
// Alows storing this range [-999.999, 999.999]
Mock_field_new_decimal field_dec(3);
@@ -124,7 +121,7 @@ TEST_F(FieldTest, StoreLegalStringValues
}
-TEST_F(FieldTest, StoreIllegalStringValues)
+TEST_F(FieldNewDecimalTest, StoreIllegalStringValues)
{
// Alows storing this range [-999.999, 999.999]
Mock_field_new_decimal field_dec(3);
@@ -202,7 +199,7 @@ static void test_store_internal(Field_ne
function for Field_new_decimal. The function does not modify the
NULL value of the field so we don't test field.is_null()
*/
-TEST_F(FieldTest, storeInternalWithErrorCheck_LegalValues)
+TEST_F(FieldNewDecimalTest, storeInternalWithErrorCheckLegalValues)
{
// Alows storing this range [-99.9999, 99.9999]
Mock_field_new_decimal field_dec(4);
@@ -257,7 +254,7 @@ TEST_F(FieldTest, storeInternalWithError
/**
Test store_internal_with_error_check() - out of range valuse
*/
-TEST_F(FieldTest, storeInternalWithErrorCheck_OutOfRange)
+TEST_F(FieldNewDecimalTest, storeInternalWithErrorCheckOutOfRange)
{
// Alows storing this range [-99.9999, 99.9999]
Mock_field_new_decimal field_dec(4);
@@ -296,7 +293,7 @@ TEST_F(FieldTest, storeInternalWithError
input decimal value because E_DEC_OVERFLOW indicates that the decimal
conversion got a number that was too high/low.
*/
-TEST_F(FieldTest, storeInternalWithErrorCheck_EDecOverflow)
+TEST_F(FieldNewDecimalTest, storeInternalWithErrorCheckEDecOverflow)
{
// Alows storing this range [-99.9999, 99.9999]
Mock_field_new_decimal field_dec(4);
@@ -366,7 +363,7 @@ TEST_F(FieldTest, storeInternalWithError
automatically changed like in the E_DEC_OVERFLOW case tested
above.
*/
-TEST_F(FieldTest, storeInternalWithErrorCheck_EDecTrunkated)
+TEST_F(FieldNewDecimalTest, storeInternalWithErrorCheckEDecTrunkated)
{
// Alows storing this range [-99.9999, 99.9999]
Mock_field_new_decimal field_dec(4);
@@ -434,7 +431,7 @@ TEST_F(FieldTest, storeInternalWithError
Any E_DEC_* value other than E_DEC_OK, E_DEC_TRUNCATED and
E_DEC_OVERFLOW will be ignored.
*/
-TEST_F(FieldTest, storeInternalWithErrorCheck_RestOfParams)
+TEST_F(FieldNewDecimalTest, storeInternalWithErrorCheckRestOfParams)
{
// Alows storing this range [-99.9999, 99.9999]
Mock_field_new_decimal field_dec(4);
=== modified file 'unittest/gunit/field_temporal_utils.h'
--- a/unittest/gunit/field_temporal_utils.h 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/field_temporal_utils.h 2012-05-07 12:05:48 +0000
@@ -13,6 +13,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#ifndef FIELD_TEMPORAL_UTILS_INCLUDED
+#define FIELD_TEMPORAL_UTILS_INCLUDED
+
#include "field.h"
#include <gtest/gtest.h>
#include "test_utils.h"
@@ -71,3 +74,6 @@ void test_store_string(Field_temporal *f
};
+
+
+#endif // FIELD_TEMPORAL_UTILS_INCLUDED
=== modified file 'unittest/gunit/field_timestamp-t.cc'
--- a/unittest/gunit/field_timestamp-t.cc 2012-04-12 14:29:14 +0000
+++ b/unittest/gunit/field_timestamp-t.cc 2012-05-07 12:05:48 +0000
@@ -34,12 +34,7 @@ using my_testing::Mock_error_handler;
class FieldTimestampTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
-
virtual void TearDown() { initializer.TearDown(); }
THD *get_thd() { return initializer.thd(); }
=== modified file 'unittest/gunit/get_diagnostics-t.cc'
--- a/unittest/gunit/get_diagnostics-t.cc 2011-12-20 09:51:05 +0000
+++ b/unittest/gunit/get_diagnostics-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -30,25 +30,8 @@ using my_testing::Mock_error_handler;
class GetDiagnosticsTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- {
- Server_initializer::SetUpTestCase();
- }
-
- static void TearDownTestCase()
- {
- Server_initializer::TearDownTestCase();
- }
-
- virtual void SetUp()
- {
- initializer.SetUp();
- }
-
- virtual void TearDown()
- {
- initializer.TearDown();
- }
+ virtual void SetUp() { initializer.SetUp(); }
+ virtual void TearDown() { initializer.TearDown(); }
THD *thd() { return initializer.thd(); }
=== added file 'unittest/gunit/gunit_test_main_server.cc'
--- a/unittest/gunit/gunit_test_main_server.cc 1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/gunit_test_main_server.cc 2012-05-07 12:05:48 +0000
@@ -0,0 +1,73 @@
+/* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+
+ 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 */
+
+// First include (the generated) my_config.h, to get correct platform defines.
+#include "my_config.h"
+#include <gtest/gtest.h>
+
+#include "my_getopt.h"
+#include "test_utils.h"
+#include <stdlib.h>
+
+namespace {
+
+my_bool opt_use_tap= true;
+my_bool opt_help= false;
+
+struct my_option unittest_options[] =
+{
+ { "tap-output", 1, "TAP (default) or gunit output.",
+ &opt_use_tap, &opt_use_tap, NULL,
+ GET_BOOL, OPT_ARG,
+ opt_use_tap, 0, 1, 0,
+ 0, NULL
+ },
+ { "help", 2, "Help.",
+ &opt_help, &opt_help, NULL,
+ GET_BOOL, NO_ARG,
+ opt_help, 0, 1, 0,
+ 0, NULL
+ },
+ {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+
+extern "C" my_bool get_one_option(int, const struct my_option *, char *)
+{
+ return FALSE;
+}
+
+} // namespace
+
+
+extern void install_tap_listener();
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ MY_INIT(argv[0]);
+
+ if (handle_options(&argc, &argv, unittest_options, get_one_option))
+ return EXIT_FAILURE;
+ if (opt_use_tap)
+ install_tap_listener();
+ if (opt_help)
+ printf("\n\nTest options: [--[disable-]tap-output]\n");
+
+ my_testing::setup_server_for_unit_tests();
+ int ret= RUN_ALL_TESTS();
+ my_testing::teardown_server_for_unit_tests();
+ return ret;
+}
=== modified file 'unittest/gunit/item-t.cc'
--- a/unittest/gunit/item-t.cc 2012-05-07 08:29:18 +0000
+++ b/unittest/gunit/item-t.cc 2012-05-07 12:05:48 +0000
@@ -33,25 +33,8 @@ using my_testing::Mock_error_handler;
class ItemTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- {
- Server_initializer::SetUpTestCase();
- }
-
- static void TearDownTestCase()
- {
- Server_initializer::TearDownTestCase();
- }
-
- virtual void SetUp()
- {
- initializer.SetUp();
- }
-
- virtual void TearDown()
- {
- initializer.TearDown();
- }
+ virtual void SetUp() { initializer.SetUp(); }
+ virtual void TearDown() { initializer.TearDown(); }
THD *thd() { return initializer.thd(); }
=== modified file 'unittest/gunit/item_func_now_local-t.cc'
--- a/unittest/gunit/item_func_now_local-t.cc 2012-01-31 15:16:16 +0000
+++ b/unittest/gunit/item_func_now_local-t.cc 2012-05-07 12:05:48 +0000
@@ -1,10 +1,4 @@
-// I suggest putting these tests in item-t.cc
-// why? simply to save 50M of disk space.
-
-// TODO(didrik) create a dynamic version of libsql,
-// and link that into all SERVER_TESTS
-
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -19,8 +13,7 @@
along with this program; if not, write to the Free Software Foundation,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
-// First include (the generated) my_config.h, to get correct platform defines,
-// then gtest.h (before any other MySQL headers), to avoid min() macros etc ...
+// First include (the generated) my_config.h, to get correct platform defines.
#include "my_config.h"
#include <gtest/gtest.h>
@@ -47,11 +40,8 @@ const int CURRENT_TIMESTAMP_FRACTIONAL_S
class ItemFuncNowLocalTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
- virtual void SetUp() {
+ virtual void SetUp()
+ {
initializer.SetUp();
timeval now=
{
=== modified file 'unittest/gunit/join_tab_sort-t.cc'
--- a/unittest/gunit/join_tab_sort-t.cc 2012-02-23 13:54:03 +0000
+++ b/unittest/gunit/join_tab_sort-t.cc 2012-05-07 12:05:48 +0000
@@ -32,25 +32,8 @@ using my_testing::Mock_error_handler;
class JTSortTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- {
- Server_initializer::SetUpTestCase();
- }
-
- static void TearDownTestCase()
- {
- Server_initializer::TearDownTestCase();
- }
-
- virtual void SetUp()
- {
- initializer.SetUp();
- }
-
- virtual void TearDown()
- {
- initializer.TearDown();
- }
+ virtual void SetUp() { initializer.SetUp(); }
+ virtual void TearDown() { initializer.TearDown(); }
Server_initializer initializer;
};
=== modified file 'unittest/gunit/my_decimal-t.cc'
--- a/unittest/gunit/my_decimal-t.cc 2011-10-14 09:40:10 +0000
+++ b/unittest/gunit/my_decimal-t.cc 2012-05-07 12:05:48 +0000
@@ -28,25 +28,8 @@ using my_testing::Mock_error_handler;
class DecimalTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- {
- Server_initializer::SetUpTestCase();
- }
-
- static void TearDownTestCase()
- {
- Server_initializer::TearDownTestCase();
- }
-
- virtual void SetUp()
- {
- initializer.SetUp();
- }
-
- virtual void TearDown()
- {
- initializer.TearDown();
- }
+ virtual void SetUp() { initializer.SetUp(); }
+ virtual void TearDown() { initializer.TearDown(); }
THD *thd() { return initializer.thd(); }
=== modified file 'unittest/gunit/opt_range-t.cc'
--- a/unittest/gunit/opt_range-t.cc 2012-03-07 07:16:42 +0000
+++ b/unittest/gunit/opt_range-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -28,16 +28,6 @@ using my_testing::Server_initializer;
class SelArgTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- {
- Server_initializer::SetUpTestCase();
- }
-
- static void TearDownTestCase()
- {
- Server_initializer::TearDownTestCase();
- }
-
SelArgTest()
{
memset(&m_opt_param, 0, sizeof(m_opt_param));
=== modified file 'unittest/gunit/segfault-t.cc'
--- a/unittest/gunit/segfault-t.cc 2011-12-05 12:37:08 +0000
+++ b/unittest/gunit/segfault-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -29,20 +29,12 @@ using my_testing::Mock_error_handler;
class FatalSignalDeathTest : public ::testing::Test
{
protected:
- static void SetUpTestCase()
- { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase()
- { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp()
{
::testing::FLAGS_gtest_death_test_style = "threadsafe";
initializer.SetUp();
}
-
- virtual void TearDown()
- { initializer.TearDown(); }
+ virtual void TearDown() { initializer.TearDown(); }
Server_initializer initializer;
};
=== modified file 'unittest/gunit/sql_table-t.cc'
--- a/unittest/gunit/sql_table-t.cc 2012-01-31 15:16:16 +0000
+++ b/unittest/gunit/sql_table-t.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -37,12 +37,7 @@ using my_testing::Mock_error_handler;
class SqlTableTest : public ::testing::Test
{
protected:
- static void SetUpTestCase() { Server_initializer::SetUpTestCase(); }
-
- static void TearDownTestCase() { Server_initializer::TearDownTestCase(); }
-
virtual void SetUp() { initializer.SetUp(); }
-
virtual void TearDown() { initializer.TearDown(); }
THD *get_thd() { return initializer.thd(); }
=== modified file 'unittest/gunit/test_utils.cc'
--- a/unittest/gunit/test_utils.cc 2011-12-20 09:51:05 +0000
+++ b/unittest/gunit/test_utils.cc 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -31,12 +31,7 @@ extern "C" void test_error_handler_hook(
EXPECT_EQ(expected_error, err) << str;
}
-void Server_initializer::set_expected_error(uint val)
-{
- expected_error= val;
-}
-
-void Server_initializer::SetUpTestCase()
+void setup_server_for_unit_tests()
{
static char *my_name= strdup(my_progname);
char *argv[] = { my_name, 0 };
@@ -49,12 +44,17 @@ void Server_initializer::SetUpTestCase()
error_handler_hook= test_error_handler_hook;
}
-void Server_initializer::TearDownTestCase()
+void teardown_server_for_unit_tests()
{
delegates_destroy();
xid_cache_free();
}
+void Server_initializer::set_expected_error(uint val)
+{
+ expected_error= val;
+}
+
void Server_initializer::SetUp()
{
expected_error= 0;
=== modified file 'unittest/gunit/test_utils.h'
--- a/unittest/gunit/test_utils.h 2011-07-28 10:54:44 +0000
+++ b/unittest/gunit/test_utils.h 2012-05-07 12:05:48 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
@@ -22,6 +22,9 @@
namespace my_testing {
+void setup_server_for_unit_tests();
+void teardown_server_for_unit_tests();
+
/*
A class which wraps the necessary setup/teardown logic for
unit tests which depend on a working THD environment.
@@ -32,8 +35,6 @@ public:
Server_initializer() : m_thd(NULL) {}
// Invoke these from corresponding functions in test fixture classes.
- static void SetUpTestCase();
- static void TearDownTestCase();
void SetUp();
void TearDown();
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (tor.didriksen:3789 to 3790) | Tor Didriksen | 8 May |