Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c2e55460
Unverified
Commit
c2e55460
authored
Sep 28, 2020
by
WuYunlong
Committed by
GitHub
Sep 28, 2020
Browse files
Normalize sds test mechanism together with some compile warnings. (#7854)
parent
8aa083bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Makefile
View file @
c2e55460
...
...
@@ -362,10 +362,6 @@ lcov:
@
geninfo
-o
redis.info .
@
genhtml
--legend
-o
lcov-html redis.info
test-sds
:
sds.c sds.h
$(REDIS_CC)
sds.c zmalloc.c
-DSDS_TEST_MAIN
$(FINAL_LIBS)
-o
/tmp/sds_test
/tmp/sds_test
.PHONY
:
lcov
bench
:
$(REDIS_BENCHMARK_NAME)
...
...
src/sds.c
View file @
c2e55460
...
...
@@ -1121,13 +1121,16 @@ void *sds_malloc(size_t size) { return s_malloc(size); }
void
*
sds_realloc
(
void
*
ptr
,
size_t
size
)
{
return
s_realloc
(
ptr
,
size
);
}
void
sds_free
(
void
*
ptr
)
{
s_free
(
ptr
);
}
#if
def
ined(SDS_TEST_MAIN)
#ifdef
REDIS_TEST
#include <stdio.h>
#include "testhelp.h"
#include "limits.h"
#define UNUSED(x) (void)(x)
int
sdsTest
(
void
)
{
int
sdsTest
(
int
argc
,
char
**
argv
)
{
UNUSED
(
argc
);
UNUSED
(
argv
);
{
sds
x
=
sdsnew
(
"foo"
),
y
;
...
...
@@ -1254,7 +1257,8 @@ int sdsTest(void) {
{
unsigned
int
oldfree
;
char
*
p
;
int
step
=
10
,
j
,
i
;
int
i
;
size_t
step
=
10
,
j
;
sdsfree
(
x
);
sdsfree
(
y
);
...
...
@@ -1264,7 +1268,7 @@ int sdsTest(void) {
/* Run the test a few times in order to hit the first two
* SDS header types. */
for
(
i
=
0
;
i
<
10
;
i
++
)
{
in
t
oldlen
=
sdslen
(
x
);
size_
t
oldlen
=
sdslen
(
x
);
x
=
sdsMakeRoomFor
(
x
,
step
);
int
type
=
x
[
-
1
]
&
SDS_TYPE_MASK
;
...
...
@@ -1272,6 +1276,7 @@ int sdsTest(void) {
if
(
type
!=
SDS_TYPE_5
)
{
test_cond
(
"sdsMakeRoomFor() free"
,
sdsavail
(
x
)
>=
step
);
oldfree
=
sdsavail
(
x
);
UNUSED
(
oldfree
);
}
p
=
x
+
oldlen
;
for
(
j
=
0
;
j
<
step
;
j
++
)
{
...
...
@@ -1290,9 +1295,3 @@ int sdsTest(void) {
return
0
;
}
#endif
#ifdef SDS_TEST_MAIN
int
main
(
void
)
{
return
sdsTest
();
}
#endif
src/server.c
View file @
c2e55460
...
...
@@ -5247,6 +5247,8 @@ int main(int argc, char **argv) {
return
crc64Test
(
argc
,
argv
);
}
else
if
(
!
strcasecmp
(
argv
[
2
],
"zmalloc"
))
{
return
zmalloc_test
(
argc
,
argv
);
}
else
if
(
!
strcasecmp
(
argv
[
2
],
"sds"
))
{
return
sdsTest
(
argc
,
argv
);
}
return
-
1
;
/* test not found */
...
...
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