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
45b85c4b
Commit
45b85c4b
authored
Jun 15, 2014
by
John Esmet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor this test to be more agreeable with clang
parent
32005e36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
33 deletions
+28
-33
ft/tests/fifo-test.cc
ft/tests/fifo-test.cc
+28
-33
No files found.
ft/tests/fifo-test.cc
View file @
45b85c4b
...
...
@@ -100,38 +100,36 @@ test_create (void) {
msg_buffer
.
destroy
();
}
static
char
*
buildkey
(
size_t
len
)
{
char
*
XMALLOC_N
(
len
,
k
);
memset
(
k
,
0
,
len
);
return
k
;
}
static
char
*
buildval
(
size_t
len
)
{
char
*
XMALLOC_N
(
len
,
v
);
memset
(
v
,
~
len
,
len
);
return
v
;
}
static
void
test_enqueue
(
int
n
)
{
int
r
;
message_buffer
msg_buffer
;
MSN
startmsn
=
ZERO_MSN
;
message_buffer
msg_buffer
;
msg_buffer
.
create
();
char
*
thekey
=
0
;
int
thekeylen
;
char
*
theval
=
0
;
int
thevallen
;
// this was a function but icc cant handle it
#define buildkey(len) { \
thekeylen = len+1; \
XREALLOC_N(thekeylen, thekey); \
memset(thekey, len, thekeylen); \
}
#define buildval(len) { \
thevallen = len+2; \
XREALLOC_N(thevallen, theval); \
memset(theval, ~len, thevallen); \
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
buildkey
(
i
);
buildval
(
i
);
int
thekeylen
=
i
+
1
;
int
thevallen
=
i
+
2
;
char
*
thekey
=
buildkey
(
thekeylen
);
char
*
theval
=
buildval
(
thevallen
);
XIDS
xids
;
if
(
i
==
0
)
if
(
i
==
0
)
{
xids
=
xids_get_root_xids
();
else
{
r
=
xids_create_child
(
xids_get_root_xids
(),
&
xids
,
(
TXNID
)
i
);
assert
(
r
==
0
);
}
else
{
int
r
=
xids_create_child
(
xids_get_root_xids
(),
&
xids
,
(
TXNID
)
i
);
assert
_zero
(
r
);
}
MSN
msn
=
next_dummymsn
();
if
(
startmsn
.
msn
==
ZERO_MSN
.
msn
)
...
...
@@ -143,6 +141,8 @@ test_enqueue(int n) {
};
msg_buffer
.
enqueue
(
&
msg
,
true
,
nullptr
);
xids_destroy
(
&
xids
);
toku_free
(
thekey
);
toku_free
(
theval
);
}
struct
checkit_fn
{
...
...
@@ -153,12 +153,10 @@ test_enqueue(int n) {
:
startmsn
(
smsn
),
verbose
(
v
),
i
(
0
)
{
}
int
operator
()(
FT_MSG
msg
,
bool
UU
(
is_fresh
))
{
char
*
thekey
=
nullptr
;
int
thekeylen
=
0
;
char
*
theval
=
nullptr
;
int
thevallen
=
0
;
buildkey
(
i
);
buildval
(
i
);
int
thekeylen
=
i
+
1
;
int
thevallen
=
i
+
2
;
char
*
thekey
=
buildkey
(
thekeylen
);
char
*
theval
=
buildval
(
thevallen
);
MSN
msn
=
msg
->
msn
;
enum
ft_msg_type
type
=
ft_msg_get_type
(
msg
);
...
...
@@ -168,18 +166,15 @@ test_enqueue(int n) {
assert
((
int
)
ft_msg_get_vallen
(
msg
)
==
thevallen
);
assert
(
memcmp
(
ft_msg_get_val
(
msg
),
theval
,
ft_msg_get_vallen
(
msg
))
==
0
);
assert
(
i
%
256
==
(
int
)
type
);
assert
((
TXNID
)
i
==
xids_get_innermost_xid
(
ft_msg_get_xids
(
msg
)));
i
+=
1
;
toku_free
(
thekey
);
toku_free
(
theval
);
i
+=
1
;
return
0
;
}
}
checkit
(
startmsn
,
verbose
);
msg_buffer
.
iterate
(
checkit
);
assert
(
checkit
.
i
==
n
);
if
(
thekey
)
toku_free
(
thekey
);
if
(
theval
)
toku_free
(
theval
);
msg_buffer
.
destroy
();
}
...
...
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