Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
36750ede
Commit
36750ede
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Validate results of events
parent
f3596c50
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/core/end2end/fuzzers/api_fuzzer.c
+56
-25
56 additions, 25 deletions
test/core/end2end/fuzzers/api_fuzzer.c
with
56 additions
and
25 deletions
test/core/end2end/fuzzers/api_fuzzer.c
+
56
−
25
View file @
36750ede
...
@@ -252,12 +252,45 @@ static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
...
@@ -252,12 +252,45 @@ static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// test driver
// test driver
typedef
enum
{
typedef
struct
validator
{
SERVER_SHUTDOWN
,
void
(
*
validate
)(
void
*
arg
,
bool
success
);
CHANNEL_WATCH
,
void
*
arg
;
}
tag_name
;
}
validator
;
static
validator
*
create_validator
(
void
(
*
validate
)(
void
*
arg
,
bool
success
),
void
*
arg
)
{
validator
*
v
=
gpr_malloc
(
sizeof
(
*
v
));
v
->
validate
=
validate
;
v
->
arg
=
arg
;
return
v
;
}
static
void
assert_success_and_decrement
(
void
*
counter
,
bool
success
)
{
GPR_ASSERT
(
success
);
--*
(
int
*
)
counter
;
}
static
void
*
tag
(
tag_name
name
)
{
return
(
void
*
)(
uintptr_t
)
name
;
}
typedef
struct
connectivity_watch
{
int
*
counter
;
gpr_timespec
deadline
;
}
connectivity_watch
;
static
connectivity_watch
*
make_connectivity_watch
(
gpr_timespec
s
,
int
*
counter
)
{
connectivity_watch
*
o
=
gpr_malloc
(
sizeof
(
*
o
));
o
->
deadline
=
s
;
o
->
counter
=
counter
;
return
o
;
}
static
void
validate_connectivity_watch
(
void
*
p
,
bool
success
)
{
connectivity_watch
*
w
=
p
;
if
(
!
success
)
{
GPR_ASSERT
(
gpr_time_cmp
(
gpr_now
(
w
->
deadline
.
clock_type
),
w
->
deadline
)
>=
0
);
}
--*
w
->
counter
;
gpr_free
(
w
);
}
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
grpc_test_only_set_metadata_hash_seed
(
0
);
grpc_test_only_set_metadata_hash_seed
(
0
);
...
@@ -286,7 +319,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
...
@@ -286,7 +319,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
}
if
(
g_server
!=
NULL
)
{
if
(
g_server
!=
NULL
)
{
if
(
!
server_shutdown
)
{
if
(
!
server_shutdown
)
{
grpc_server_shutdown_and_notify
(
g_server
,
cq
,
tag
(
SERVER_SHUTDOWN
));
grpc_server_shutdown_and_notify
(
g_server
,
cq
,
create_validator
(
assert_success_and_decrement
,
&
pending_server_shutdowns
));
server_shutdown
=
true
;
server_shutdown
=
true
;
pending_server_shutdowns
++
;
pending_server_shutdowns
++
;
}
else
if
(
pending_server_shutdowns
==
0
)
{
}
else
if
(
pending_server_shutdowns
==
0
)
{
...
@@ -308,20 +343,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
...
@@ -308,20 +343,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_event
ev
=
grpc_completion_queue_next
(
grpc_event
ev
=
grpc_completion_queue_next
(
cq
,
gpr_inf_past
(
GPR_CLOCK_REALTIME
),
NULL
);
cq
,
gpr_inf_past
(
GPR_CLOCK_REALTIME
),
NULL
);
switch
(
ev
.
type
)
{
switch
(
ev
.
type
)
{
case
GRPC_OP_COMPLETE
:
case
GRPC_OP_COMPLETE
:
{
switch
((
tag_name
)(
uintptr_t
)
ev
.
tag
)
{
validator
*
v
=
ev
.
tag
;
case
SERVER_SHUTDOWN
:
v
->
validate
(
v
->
arg
,
ev
.
success
);
GPR_ASSERT
(
pending_server_shutdowns
);
gpr_free
(
v
);
pending_server_shutdowns
--
;
break
;
case
CHANNEL_WATCH
:
GPR_ASSERT
(
pending_channel_watches
>
0
);
pending_channel_watches
--
;
break
;
default:
GPR_ASSERT
(
false
);
}
break
;
break
;
}
case
GRPC_QUEUE_TIMEOUT
:
case
GRPC_QUEUE_TIMEOUT
:
break
;
break
;
case
GRPC_QUEUE_SHUTDOWN
:
case
GRPC_QUEUE_SHUTDOWN
:
...
@@ -375,7 +402,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
...
@@ -375,7 +402,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// begin server shutdown
// begin server shutdown
case
5
:
{
case
5
:
{
if
(
g_server
!=
NULL
)
{
if
(
g_server
!=
NULL
)
{
grpc_server_shutdown_and_notify
(
g_server
,
cq
,
tag
(
SERVER_SHUTDOWN
));
grpc_server_shutdown_and_notify
(
g_server
,
cq
,
create_validator
(
assert_success_and_decrement
,
&
pending_server_shutdowns
));
pending_server_shutdowns
++
;
pending_server_shutdowns
++
;
server_shutdown
=
true
;
server_shutdown
=
true
;
}
}
...
@@ -411,12 +440,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
...
@@ -411,12 +440,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_connectivity_state
st
=
grpc_connectivity_state
st
=
grpc_channel_check_connectivity_state
(
g_channel
,
0
);
grpc_channel_check_connectivity_state
(
g_channel
,
0
);
if
(
st
!=
GRPC_CHANNEL_FATAL_FAILURE
)
{
if
(
st
!=
GRPC_CHANNEL_FATAL_FAILURE
)
{
gpr_timespec
deadline
=
gpr_time_add
(
gpr_now
(
GPR_CLOCK_REALTIME
),
gpr_time_from_micros
(
read_uint32
(
&
inp
),
GPR_TIMESPAN
));
grpc_channel_watch_connectivity_state
(
grpc_channel_watch_connectivity_state
(
g_channel
,
st
,
g_channel
,
st
,
deadline
,
cq
,
gpr_time_add
(
create_validator
(
validate_connectivity_watch
,
gpr_now
(
GPR_CLOCK_REALTIME
),
make_connectivity_watch
(
gpr_time_from_micros
(
read_uint32
(
&
inp
),
GPR_TIMESPAN
)),
cq
,
deadline
,
&
pending_channel_watches
)));
tag
(
CHANNEL_WATCH
));
pending_channel_watches
++
;
pending_channel_watches
++
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment