Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a50f1641
Commit
a50f1641
authored
Dec 28, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-maria
into janus.mylan:/usr/home/serg/Abk/mysql-maria
parents
4140f76f
77cc781d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
460 additions
and
21 deletions
+460
-21
storage/maria/ma_loghandler.c
storage/maria/ma_loghandler.c
+13
-8
storage/maria/ma_loghandler.h
storage/maria/ma_loghandler.h
+3
-2
storage/maria/unittest/ma_test_all-t
storage/maria/unittest/ma_test_all-t
+424
-0
storage/maria/unittest/ma_test_loghandler-t.c
storage/maria/unittest/ma_test_loghandler-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_multigroup-t.c
storage/maria/unittest/ma_test_loghandler_multigroup-t.c
+2
-2
storage/maria/unittest/ma_test_loghandler_multithread-t.c
storage/maria/unittest/ma_test_loghandler_multithread-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_noflush-t.c
storage/maria/unittest/ma_test_loghandler_noflush-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_nologs-t.c
storage/maria/unittest/ma_test_loghandler_nologs-t.c
+4
-2
storage/maria/unittest/ma_test_loghandler_pagecache-t.c
storage/maria/unittest/ma_test_loghandler_pagecache-t.c
+2
-1
storage/maria/unittest/ma_test_loghandler_purge-t.c
storage/maria/unittest/ma_test_loghandler_purge-t.c
+2
-1
No files found.
storage/maria/ma_loghandler.c
View file @
a50f1641
...
@@ -2807,13 +2807,15 @@ static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link)
...
@@ -2807,13 +2807,15 @@ static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link)
@param last_page_ok Result of the check whether last page OK.
@param last_page_ok Result of the check whether last page OK.
(for now only we check only that file length
(for now only we check only that file length
divisible on page length).
divisible on page length).
@param no_errors suppress messages about non-critical errors
@retval 0 OK
@retval 0 OK
@retval 1 Error
@retval 1 Error
*/
*/
static
my_bool
translog_get_last_page_addr
(
TRANSLOG_ADDRESS
*
addr
,
static
my_bool
translog_get_last_page_addr
(
TRANSLOG_ADDRESS
*
addr
,
my_bool
*
last_page_ok
)
my_bool
*
last_page_ok
,
my_bool
no_errors
)
{
{
MY_STAT
stat_buff
,
*
local_stat
;
MY_STAT
stat_buff
,
*
local_stat
;
char
path
[
FN_REFLEN
];
char
path
[
FN_REFLEN
];
...
@@ -2822,7 +2824,8 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
...
@@ -2822,7 +2824,8 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
DBUG_ENTER
(
"translog_get_last_page_addr"
);
DBUG_ENTER
(
"translog_get_last_page_addr"
);
if
(
!
(
local_stat
=
my_stat
(
translog_filename_by_fileno
(
file_no
,
path
),
if
(
!
(
local_stat
=
my_stat
(
translog_filename_by_fileno
(
file_no
,
path
),
&
stat_buff
,
MYF
(
MY_WME
))))
&
stat_buff
,
(
no_errors
?
MYF
(
0
)
:
MYF
(
MY_WME
)))))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
DBUG_PRINT
(
"info"
,
(
"File size: %lu"
,
(
ulong
)
local_stat
->
st_size
));
DBUG_PRINT
(
"info"
,
(
"File size: %lu"
,
(
ulong
)
local_stat
->
st_size
));
if
(
local_stat
->
st_size
>
TRANSLOG_PAGE_SIZE
)
if
(
local_stat
->
st_size
>
TRANSLOG_PAGE_SIZE
)
...
@@ -3049,6 +3052,7 @@ my_bool translog_is_log_files()
...
@@ -3049,6 +3052,7 @@ my_bool translog_is_log_files()
TRANSLOG_RECORD_CRC)
TRANSLOG_RECORD_CRC)
@param read_only Put transaction log in read-only mode
@param read_only Put transaction log in read-only mode
@param init_table_func function to initialize record descriptors table
@param init_table_func function to initialize record descriptors table
@param no_errors suppress messages about non-critical errors
@todo
@todo
Free used resources in case of error.
Free used resources in case of error.
...
@@ -3062,7 +3066,8 @@ my_bool translog_init_with_table(const char *directory,
...
@@ -3062,7 +3066,8 @@ my_bool translog_init_with_table(const char *directory,
uint32
server_version
,
uint32
server_version
,
uint32
server_id
,
PAGECACHE
*
pagecache
,
uint32
server_id
,
PAGECACHE
*
pagecache
,
uint
flags
,
my_bool
readonly
,
uint
flags
,
my_bool
readonly
,
void
(
*
init_table_func
)())
void
(
*
init_table_func
)(),
my_bool
no_errors
)
{
{
int
i
;
int
i
;
int
old_log_was_recovered
=
0
,
logs_found
=
0
;
int
old_log_was_recovered
=
0
,
logs_found
=
0
;
...
@@ -3217,7 +3222,7 @@ my_bool translog_init_with_table(const char *directory,
...
@@ -3217,7 +3222,7 @@ my_bool translog_init_with_table(const char *directory,
}
}
/* Set horizon to the beginning of the last file first */
/* Set horizon to the beginning of the last file first */
log_descriptor
.
horizon
=
last_page
=
MAKE_LSN
(
last_logno
,
0
);
log_descriptor
.
horizon
=
last_page
=
MAKE_LSN
(
last_logno
,
0
);
if
(
translog_get_last_page_addr
(
&
last_page
,
&
pageok
))
if
(
translog_get_last_page_addr
(
&
last_page
,
&
pageok
,
no_errors
))
{
{
if
(
!
translog_is_log_files
())
if
(
!
translog_is_log_files
())
{
{
...
@@ -3238,7 +3243,7 @@ my_bool translog_init_with_table(const char *directory,
...
@@ -3238,7 +3243,7 @@ my_bool translog_init_with_table(const char *directory,
else
else
{
{
last_page
-=
LSN_ONE_FILE
;
last_page
-=
LSN_ONE_FILE
;
if
(
translog_get_last_page_addr
(
&
last_page
,
&
pageok
))
if
(
translog_get_last_page_addr
(
&
last_page
,
&
pageok
,
0
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
}
}
...
@@ -3317,7 +3322,7 @@ my_bool translog_init_with_table(const char *directory,
...
@@ -3317,7 +3322,7 @@ my_bool translog_init_with_table(const char *directory,
{
{
TRANSLOG_ADDRESS
current_file_last_page
;
TRANSLOG_ADDRESS
current_file_last_page
;
current_file_last_page
=
current_page
;
current_file_last_page
=
current_page
;
if
(
translog_get_last_page_addr
(
&
current_file_last_page
,
&
pageok
))
if
(
translog_get_last_page_addr
(
&
current_file_last_page
,
&
pageok
,
0
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
if
(
!
pageok
)
if
(
!
pageok
)
{
{
...
@@ -3593,7 +3598,7 @@ my_bool translog_init_with_table(const char *directory,
...
@@ -3593,7 +3598,7 @@ my_bool translog_init_with_table(const char *directory,
}
}
file_no
--
;
file_no
--
;
page_addr
=
MAKE_LSN
(
file_no
,
TRANSLOG_PAGE_SIZE
);
page_addr
=
MAKE_LSN
(
file_no
,
TRANSLOG_PAGE_SIZE
);
translog_get_last_page_addr
(
&
page_addr
,
&
last_page_ok
);
translog_get_last_page_addr
(
&
page_addr
,
&
last_page_ok
,
0
);
/* page should be OK as it is not the last file */
/* page should be OK as it is not the last file */
DBUG_ASSERT
(
last_page_ok
);
DBUG_ASSERT
(
last_page_ok
);
}
}
...
@@ -5842,7 +5847,7 @@ static my_bool translog_scanner_set_last_page(TRANSLOG_SCANNER_DATA *scanner)
...
@@ -5842,7 +5847,7 @@ static my_bool translog_scanner_set_last_page(TRANSLOG_SCANNER_DATA *scanner)
return
(
0
);
return
(
0
);
}
}
scanner
->
last_file_page
=
scanner
->
page_addr
;
scanner
->
last_file_page
=
scanner
->
page_addr
;
return
(
translog_get_last_page_addr
(
&
scanner
->
last_file_page
,
&
page_ok
));
return
(
translog_get_last_page_addr
(
&
scanner
->
last_file_page
,
&
page_ok
,
0
));
}
}
...
...
storage/maria/ma_loghandler.h
View file @
a50f1641
...
@@ -257,7 +257,7 @@ C_MODE_START
...
@@ -257,7 +257,7 @@ C_MODE_START
extern
void
translog_example_table_init
();
extern
void
translog_example_table_init
();
extern
void
translog_table_init
();
extern
void
translog_table_init
();
#define translog_init(D,M,V,I,C,F,R) \
#define translog_init(D,M,V,I,C,F,R) \
translog_init_with_table(D,M,V,I,C,F,R,&translog_table_init)
translog_init_with_table(D,M,V,I,C,F,R,&translog_table_init
,0
)
extern
my_bool
translog_init_with_table
(
const
char
*
directory
,
extern
my_bool
translog_init_with_table
(
const
char
*
directory
,
uint32
log_file_max_size
,
uint32
log_file_max_size
,
uint32
server_version
,
uint32
server_version
,
...
@@ -265,7 +265,8 @@ extern my_bool translog_init_with_table(const char *directory,
...
@@ -265,7 +265,8 @@ extern my_bool translog_init_with_table(const char *directory,
PAGECACHE
*
pagecache
,
PAGECACHE
*
pagecache
,
uint
flags
,
uint
flags
,
my_bool
readonly
,
my_bool
readonly
,
void
(
*
init_table_func
)());
void
(
*
init_table_func
)(),
my_bool
no_error
);
extern
my_bool
extern
my_bool
translog_write_record
(
LSN
*
lsn
,
enum
translog_record_type
type
,
TRN
*
trn
,
translog_write_record
(
LSN
*
lsn
,
enum
translog_record_type
type
,
TRN
*
trn
,
...
...
storage/maria/unittest/ma_test_all-t
0 → 100755
View file @
a50f1641
#!/usr/bin/perl -w
#
# Run various unit tests.
#
my
$maria_path
=
$ENV
{'
maria_path
'};
run_tests
();
####
#### Initialise variables, clean temporary files and run the tests
####
sub
run_tests
{
my
$valgrind_opt
=
"
valgrind --alignment=8 --leak-check=yes
";
my
$silent_opt
=
"
-s
";
my
$suffix
=
"";
my
$nr_tests
=
0
;
#
# initialisations and previous run clean-ups
#
$maria_path
=
"
.
"
if
(
!
defined
(
$maria_path
)
||
!
length
(
$maria_path
));
unlink
<*.
TMD
maria_log
*>
;
# Delete temporary files
#
# IMPORTANT: If you modify this file, please read this:
#
# Count total number of tests. Make sure that the functions return
# number of unit tests correctly, e.g. calls to ok(). The last argument
# for each function is a flag counter and will return the number of
# unit tests in each. Please see comments on function ok() at the end.
#
# If you modify any functions or add any new ones, please make sure the
# unit tests are appropriately detected here. A wrong count will
# make the unit test fail during 'make test'. $nr_tests must be right.
#
$nr_tests
+=
run_check_tests
(
0
,
0
,
0
,
0
,
1
)
*
4
;
#
$nr_tests
+=
run_repair_tests
(
0
,
0
,
0
,
0
,
1
)
*
4
;
# called 4 times
$nr_tests
+=
run_pack_tests
(
0
,
0
,
0
,
0
,
1
)
*
4
;
#
$nr_tests
+=
run_tests_on_warnings_and_errors
(
0
,
0
,
0
,
1
);
$nr_tests
+=
run_ma_test_recovery
(
0
,
1
);
$nr_tests
+=
run_tests_on_clrs
(
0
,
1
);
#
# Run tests
#
print
"
1..
$nr_tests
\n
";
print
"
Running tests with dynamic row format
\n
";
run_check_tests
(
$suffix
,
$silent_opt
,
"",
0
,
0
);
run_repair_tests
(
$suffix
,
$silent_opt
,
"",
0
,
0
);
run_pack_tests
(
$suffix
,
$silent_opt
,
"",
0
,
0
);
print
"
Running tests with static row format
\n
";
run_check_tests
(
$suffix
,
$silent_opt
,
"
-S
",
0
,
0
);
run_repair_tests
(
$suffix
,
$silent_opt
,
"
-S
",
0
,
0
);
run_pack_tests
(
$suffix
,
$silent_opt
,
"
-S
",
0
,
0
);
print
"
Running tests with block row format
\n
";
run_check_tests
(
$suffix
,
$silent_opt
,
"
-M
",
0
,
0
);
run_repair_tests
(
$suffix
,
$silent_opt
,
"
-M
",
0
,
0
);
run_pack_tests
(
$suffix
,
$silent_opt
,
"
-M
",
0
,
0
);
print
"
Running tests with block row format and transactions
\n
";
run_check_tests
(
$suffix
,
$silent_opt
,
"
-M -T
",
0
,
0
);
run_repair_tests
(
$suffix
,
$silent_opt
,
"
-M -T
",
0
,
0
);
run_pack_tests
(
$suffix
,
$silent_opt
,
"
-M -T
",
0
,
0
);
run_tests_on_warnings_and_errors
(
$suffix
,
$silent_opt
,
0
,
0
);
run_ma_test_recovery
(
0
,
0
);
run_tests_on_clrs
(
0
,
0
);
return
;
}
####
#### regular tests
####
sub
run_check_tests
{
my
(
$suffix
,
$silent
,
$row_type
,
$verbose
,
$count
)
=
@_
;
my
(
$i
,
$nr_tests
);
my
@ma_test1_opt
=
(
["","
-se
"],
["
-N
","
-se
"],
["
-P --checksum
","
-se
"],
["
-P -N
","
-se
"],
["
-B -N -R2
","
-sm
"],
["
-a -k 480 --unique
","
-sm
"],
["
-a -N -R1
","
-sm
"],
["
-p
","
-sm
"],
["
-p -N --unique
","
-sm
"],
["
-p -N --key_length=127 --checksum
","
-sm
"],
["
-p -N --key_length=128
","
-sm
"],
["
-p --key_length=480
","
-sm
"],
["
-a -B
","
-sm
"],
["
-a -B --key_length=64 --unique
","
-sm
"],
["
-a -B -k 480 --checksum
","
-sm
"],
["
-a -B -k 480 -N --unique --checksum
","
-sm
"],
["
-a -m
","
-sm
"],
["
-a -m -P --unique --checksum
","
-sm
"],
["
-a -m -P --key_length=480 --key_cache
","
-sm
"],
["
-m -p
","
-sm
"],
["
-w --unique
","
-sm
"],
["
-a -w --key_length=64 --checksum
","
-sm
"],
["
-a -w -N --key_length=480
","
-sm
"],
["
-a -w --key_length=480 --checksum
","
-sm
"],
["
-a -b -N
","
-sm
"],
["
-a -b --key_length=480
","
-sm
"],
["
-p -B --key_length=480
","
-sm
"],
["
--checksum --unique
","
-se
"],
["
--unique
","
-se
"],
["
--key_multiple -N -S
","
-sm
"],
["
--key_multiple -a -p --key_length=480
","
-sm
"],
["
--key_multiple -a -B --key_length=480
","
-sm
"],
["
--key_multiple -P -S
","
-sm
"]
);
my
@ma_test2_opt
=
(
["
-L -K -W -P
","
-sm
"],
["
-L -K -W -P -A
","
-sm
"],
["
-L -K -P -R3 -m50 -b1000000
","
-sm
"],
["
-L -B
","
-sm
"],
["
-D -B -c
","
-sm
"],
["
-m10000 -e4096 -K
","
-sm
"],
["
-m10000 -e8192 -K
","
-sm
"],
["
-m10000 -e16384 -E16384 -K -L
","
-sm
"],
["
-c -b65000
","
-se
"]
);
if
(
$count
)
{
$nr_tests
=
2
;
# Number of tests outside loops
for
(
$i
=
0
;
defined
(
$ma_test1_opt
[
$i
]);
$i
++
)
{
$nr_tests
+=
2
;
}
for
(
$i
=
0
;
defined
(
$ma_test2_opt
[
$i
]);
$i
++
)
{
$nr_tests
+=
2
;
}
return
$nr_tests
;
}
for
(
$i
=
0
;
defined
(
$ma_test1_opt
[
$i
]);
$i
++
)
{
unlink
<
maria_log_control
maria_log
.*>
;
ok
("
$maria_path
/ma_test1
$suffix
$silent
$ma_test1_opt
[
$i
][0]
$row_type
",
$verbose
,
$i
+
1
);
ok
("
$maria_path
/maria_chk
$suffix
$ma_test1_opt
[
$i
][1] test1
",
$verbose
,
$i
+
1
);
}
#
# These tests are outside the loops. Make sure to include them in
# nr_tests manually
#
ok
("
$maria_path
/maria_pack
$suffix
--force -s test1
",
$verbose
,
0
);
ok
("
$maria_path
/maria_chk
$suffix
-ess test1
",
$verbose
,
0
);
for
(
$i
=
0
;
defined
(
$ma_test2_opt
[
$i
]);
$i
++
)
{
unlink
<
maria_log_control
maria_log
.*>
;
ok
("
$maria_path
/ma_test2
$suffix
$silent
$ma_test2_opt
[
$i
][0]
$row_type
",
$verbose
,
$i
+
1
);
ok
("
$maria_path
/maria_chk
$suffix
$ma_test2_opt
[
$i
][1] test2
",
$verbose
,
$i
+
1
);
}
unlink
<
rm
-
f
maria_log_control
maria_log
.*>
;
return
0
;
}
####
#### repair tests
####
sub
run_repair_tests
()
{
my
(
$suffix
,
$silent
,
$row_type
,
$verbose
,
$count
)
=
@_
;
my
(
$i
,
$nr_tests
);
my
@t1
=
("
$maria_path
/ma_test1
$suffix
$silent
--checksum
$row_type
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
--silent -re --transaction-log test1
",
"
$maria_path
/maria_chk
$suffix
-rs test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-rqs test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-rs --correct-checksum test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-rqs --correct-checksum test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-ros --correct-checksum test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-rqos --correct-checksum test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/ma_test2
$suffix
$silent
-c -d1
$row_type
",
"
$maria_path
/maria_chk
$suffix
-s --parallel-recover test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
",
"
$maria_path
/maria_chk
$suffix
-s --parallel-recover --quick test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
",
"
$maria_path
/ma_test2
$suffix
$silent
-c
$row_type
",
"
$maria_path
/maria_chk
$suffix
-se test2
",
"
$maria_path
/maria_chk
$suffix
-sr test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
"
);
if
(
$count
)
{
$nr_tests
=
0
;
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
$nr_tests
++
;
}
return
$nr_tests
;
}
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
ok
(
$t1
[
$i
],
$verbose
,
$i
+
1
);
}
return
0
;
}
####
#### pack tests
####
sub
run_pack_tests
()
{
my
(
$suffix
,
$silent
,
$row_type
,
$verbose
,
$count
)
=
@_
;
my
(
$i
,
$nr_tests
);
my
@t1
=
("
$maria_path
/ma_test1
$suffix
$silent
--checksum
$row_type
",
"
$maria_path
/maria_pack
$suffix
--force -s test1
",
"
$maria_path
/maria_chk
$suffix
-ess test1
",
"
$maria_path
/maria_chk
$suffix
-rqs test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/maria_chk
$suffix
-rs test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/maria_chk
$suffix
-rus test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/ma_test1
$suffix
$silent
--checksum
$row_type
",
"
$maria_path
/maria_pack
$suffix
--force -s test1
",
"
$maria_path
/maria_chk
$suffix
-rus --safe-recover test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/ma_test1
$suffix
$silent
--checksum -S
$row_type
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_chk
$suffix
-ros test1
",
"
$maria_path
/maria_chk
$suffix
-rqs test1
",
"
$maria_path
/maria_chk
$suffix
-se test1
",
"
$maria_path
/maria_pack
$suffix
--force -s test1
",
"
$maria_path
/maria_chk
$suffix
-rqs test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/maria_chk
$suffix
-rus test1
",
"
$maria_path
/maria_chk
$suffix
-es test1
",
"
$maria_path
/ma_test2
$suffix
$silent
-c -d1
$row_type
",
"
$maria_path
/maria_chk
$suffix
-s --parallel-recover test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
",
"
$maria_path
/maria_chk
$suffix
-s --unpack --parallel-recover test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
",
"
$maria_path
/maria_pack
$suffix
--force -s test1
",
"
$maria_path
/maria_chk
$suffix
-s --unpack --parallel-recover test2
",
"
$maria_path
/maria_chk
$suffix
-se test2
"
);
if
(
$count
)
{
$nr_tests
=
0
;
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
$nr_tests
++
;
}
return
$nr_tests
;
}
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
ok
(
$t1
[
$i
],
$verbose
,
$i
+
1
);
}
return
0
;
}
####
#### Tests that gives warnings or errors
####
sub
run_tests_on_warnings_and_errors
{
my
(
$suffix
,
$silent
,
$verbose
,
$count
)
=
@_
;
my
(
$com
);
return
9
if
(
$count
);
# Number of tests in this function, e.g. calls to ok()
ok
("
$maria_path
/ma_test2
$suffix
$silent
-L -K -W -P -S -R1 -m500
",
$verbose
,
0
);
ok
("
$maria_path
/maria_chk
$suffix
-sm test2
",
$verbose
,
0
);
print
"
ma_test2
$suffix
$silent
-L -K -R1 -m2000 ; Should give error 135
\n
";
# In the following a failure is a success and success is a failure
$com
=
"
$maria_path
/ma_test2
$suffix
$silent
-L -K -R1 -m2000
";
$com
.=
"
>ma_test2_message.txt 2>&1 && false
";
ok
(
$com
,
$verbose
,
0
,
1
);
ok
("
cat ma_test2_message.txt
",
$verbose
,
0
);
ok
("
grep
\"
Error: 135
\"
ma_test2_message.txt > /dev/null
",
$verbose
,
0
);
print
"
$maria_path
/maria_chk
$suffix
-sm test2 will warn that
\n
";
print
"
'Datafile is almost full'
\n
";
ok
("
$maria_path
/maria_chk
$suffix
-sm test2 >ma_test2_message.txt 2>&1
",
$verbose
,
0
);
ok
("
cat ma_test2_message.txt
",
$verbose
,
0
);
ok
("
grep
\"
warning: Datafile is almost full
\"
ma_test2_message.txt>/dev/null
",
$verbose
,
0
);
unlink
<
rm
-
f
ma_test2_message
.
txt
>
;
ok
("
$maria_path
/maria_chk
$suffix
-ssm test2
",
$verbose
,
0
);
return
0
;
}
####
#### Test that removing tables and applying the log leads to identical tables
####
sub
run_ma_test_recovery
{
my
(
$verbose
,
$count
)
=
@_
;
return
1
if
(
$count
);
# Number of tests in this function
ok
("
$maria_path
/ma_test_recovery
",
$verbose
,
0
);
return
0
;
}
####
#### Tests on CLR's
####
sub
run_tests_on_clrs
{
my
(
$verbose
,
$count
)
=
@_
;
my
(
$i
,
$nr_tests
);
my
@t1
=
("
$maria_path
/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -u1
",
"
cp maria_log_control tmp
",
"
$maria_path
/maria_read_log -a -s
",
"
$maria_path
/maria_chk -s -e test2
",
"
cp tmp/maria_log_control .
",
"
rm test2.MA?
",
"
$maria_path
/maria_read_log -a -s
",
"
$maria_path
/maria_chk -s -e test2
"
);
my
@t2
=
("
$maria_path
/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -u1
",
"
$maria_path
/maria_read_log -a -s
",
"
$maria_path
/maria_chk -s -e test2
",
"
rm test2.MA?
",
"
$maria_path
/maria_read_log -a -s
",
"
$maria_path
/maria_chk -e -s test2
"
);
if
(
$count
)
{
$nr_tests
=
0
;
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
$nr_tests
++
;
}
for
(
$i
=
0
;
defined
(
$t2
[
$i
]);
$i
++
)
{
$nr_tests
++
;
}
return
$nr_tests
;
}
unlink
<
maria_log
.*
maria_log_control
>
;
for
(
$i
=
0
;
defined
(
$t1
[
$i
]);
$i
++
)
{
ok
(
$t1
[
$i
],
$verbose
,
$i
+
1
);
}
unlink
<
maria_log
.*
maria_log_control
>
;
for
(
$i
=
0
;
defined
(
$t2
[
$i
]);
$i
++
)
{
ok
(
$t2
[
$i
],
$verbose
,
$i
+
1
);
}
return
0
;
}
#
# Print "ok" on success and "not ok" on error
#
# Note: Every time this function is called it will be counted
# as a unit test.
#
# Args: $com: The actual command run. Will be printed on a failure
# $verbose: Be more verbose.
# $iteration: Number of iterations in a loop when the error
# occurred. If not in loop, this should be blank
# (e.g. send zero).
# $expected_error: Optional; put here expected error code. Test
# will pass with this result only.
#
# Return value: Will return 1 on success and 0 on an error
#
sub
ok
{
my
(
$com
,
$verbose
,
$iteration
,
$expected_error
)
=
@_
;
my
(
$msg
,
$output
,
$err
);
$expected_error
=
0
if
(
!
defined
(
$expected_error
));
if
(
$verbose
)
{
print
"
Running: '
$com
'
\n
";
}
$output
=
`
$com
2>&1
`;
$err
=
$?
>>
8
;
if
(
$verbose
)
{
print
"
$output
\n
";
}
if
(
$err
==
$expected_error
)
{
print
"
ok
\n
";
return
1
;
}
print
"
not ok
\n
";
$msg
=
"
\n
Failed test '
$com
'
";
if
(
$iteration
)
{
$msg
.=
"
(loop iteration
$iteration
.)
";
}
$msg
.=
"
at line
";
$msg
.=
(
caller
)[
2
];
$msg
.=
"
(errcode:
$err
)
\n
";
if
(
$expected_error
)
{
$msg
.=
"
Was expecting errcode:
$expected_error
\n
";
}
warn
$msg
;
return
0
;
}
storage/maria/unittest/ma_test_loghandler-t.c
View file @
a50f1641
...
@@ -177,7 +177,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -177,7 +177,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
View file @
a50f1641
...
@@ -67,7 +67,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -67,7 +67,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
View file @
a50f1641
...
@@ -61,7 +61,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -61,7 +61,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_multigroup-t.c
View file @
a50f1641
...
@@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
0
,
0
,
&
translog_example_table_init
))
0
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
@@ -350,7 +350,7 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -350,7 +350,7 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
0
,
READONLY
,
&
translog_example_table_init
))
0
,
READONLY
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"pass2: Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"pass2: Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_multithread-t.c
View file @
a50f1641
...
@@ -284,7 +284,8 @@ int main(int argc __attribute__((unused)),
...
@@ -284,7 +284,8 @@ int main(int argc __attribute__((unused)),
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_noflush-t.c
View file @
a50f1641
...
@@ -69,7 +69,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -69,7 +69,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_nologs-t.c
View file @
a50f1641
...
@@ -64,7 +64,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -64,7 +64,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
@@ -137,7 +138,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -137,7 +138,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
1
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_pagecache-t.c
View file @
a50f1641
...
@@ -94,7 +94,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -94,7 +94,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
storage/maria/unittest/ma_test_loghandler_purge-t.c
View file @
a50f1641
...
@@ -64,7 +64,8 @@ int main(int argc __attribute__((unused)), char *argv[])
...
@@ -64,7 +64,8 @@ int main(int argc __attribute__((unused)), char *argv[])
exit
(
1
);
exit
(
1
);
}
}
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
if
(
translog_init_with_table
(
"."
,
LOG_FILE_SIZE
,
50112
,
0
,
&
pagecache
,
LOG_FLAGS
,
0
,
&
translog_example_table_init
))
LOG_FLAGS
,
0
,
&
translog_example_table_init
,
0
))
{
{
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
fprintf
(
stderr
,
"Can't init loghandler (%d)
\n
"
,
errno
);
exit
(
1
);
exit
(
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment