Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
cde25a8b
Commit
cde25a8b
authored
12 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Removed embedded test
parent
1b7f0361
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unit_test.c
+23
-8
23 additions, 8 deletions
test/unit_test.c
with
23 additions
and
8 deletions
test/unit_test.c
+
23
−
8
View file @
cde25a8b
...
@@ -539,24 +539,39 @@ static void test_request_replies(void) {
...
@@ -539,24 +539,39 @@ static void test_request_replies(void) {
mg_stop
(
ctx
);
mg_stop
(
ctx
);
}
}
static
int
user_data_callback
(
struct
mg_connection
*
conn
)
{
static
int
api_callback
(
struct
mg_connection
*
conn
)
{
ASSERT
(
mg_get_request_info
(
conn
)
->
user_data
==
(
void
*
)
123
);
struct
mg_request_info
*
ri
=
mg_get_request_info
(
conn
);
mg_printf
(
conn
,
"HTTP/1.0 200 OK
\r\n\r\n
hi"
);
char
post_data
[
100
]
=
""
;
ASSERT
(
ri
->
user_data
==
(
void
*
)
123
);
ASSERT
(
ri
->
num_headers
==
2
);
ASSERT
(
strcmp
(
mg_get_header
(
conn
,
"host"
),
"blah.com"
)
==
0
);
ASSERT
(
mg_read
(
conn
,
post_data
,
sizeof
(
post_data
))
==
3
);
ASSERT
(
memcmp
(
post_data
,
"b=1"
,
3
)
==
0
);
ASSERT
(
ri
->
query_string
!=
NULL
);
ASSERT
(
ri
->
remote_ip
>
0
);
ASSERT
(
ri
->
remote_port
>
0
);
ASSERT
(
strcmp
(
ri
->
http_version
,
"1.0"
)
==
0
);
mg_printf
(
conn
,
"HTTP/1.0 200 OK
\r\n\r\n
"
);
return
1
;
return
1
;
}
}
static
void
test_
user_data
(
void
)
{
static
void
test_
api_calls
(
void
)
{
char
ebuf
[
100
];
char
ebuf
[
100
];
struct
mg_callbacks
callbacks
;
struct
mg_callbacks
callbacks
;
struct
mg_connection
*
conn
;
struct
mg_connection
*
conn
;
struct
mg_context
*
ctx
;
struct
mg_context
*
ctx
;
static
const
char
*
request
=
"POST /?a=%20&b=&c=xx HTTP/1.0
\r\n
"
"Host: blah.com
\n
"
// More spaces before
"content-length: 3
\r\n
"
// Lower case header name
"
\r\n
b=123456"
;
// Content size > content-length, test for mg_read()
memset
(
&
callbacks
,
0
,
sizeof
(
callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
callbacks
));
callbacks
.
begin_request
=
user_data
_callback
;
callbacks
.
begin_request
=
api
_callback
;
ASSERT
((
ctx
=
mg_start
(
&
callbacks
,
(
void
*
)
123
,
OPTIONS
))
!=
NULL
);
ASSERT
((
ctx
=
mg_start
(
&
callbacks
,
(
void
*
)
123
,
OPTIONS
))
!=
NULL
);
ASSERT
((
conn
=
mg_download
(
"localhost"
,
atoi
(
HTTPS_PORT
),
1
,
ASSERT
((
conn
=
mg_download
(
"localhost"
,
atoi
(
HTTPS_PORT
),
1
,
ebuf
,
sizeof
(
ebuf
),
ebuf
,
sizeof
(
ebuf
),
"%s"
,
request
))
!=
NULL
);
"%s"
,
"GET / HTTP/1.0
\r\n\r\n
"
))
!=
NULL
);
mg_close_connection
(
conn
);
mg_close_connection
(
conn
);
mg_stop
(
ctx
);
mg_stop
(
ctx
);
}
}
...
@@ -576,7 +591,7 @@ int __cdecl main(void) {
...
@@ -576,7 +591,7 @@ int __cdecl main(void) {
test_skip_quoted
();
test_skip_quoted
();
test_mg_upload
();
test_mg_upload
();
test_request_replies
();
test_request_replies
();
test_
user_data
();
test_
api_calls
();
#ifdef USE_LUA
#ifdef USE_LUA
test_lua
();
test_lua
();
#endif
#endif
...
...
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