mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 13:41:29 +00:00
New nsock regression test: TestConnectFailure.
Trigger a ENETUNREACH error on connect() and check if properly reported. As of now the test fails, the error isn't delivered.
This commit is contained in:
@@ -80,6 +80,21 @@ static int connect_tcp(void *tdata) {
|
|||||||
return ctd->connect_result;
|
return ctd->connect_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int connect_tcp_failure(void *tdata) {
|
||||||
|
struct connect_test_data *ctd = (struct connect_test_data *)tdata;
|
||||||
|
struct sockaddr_in peer;
|
||||||
|
|
||||||
|
memset(&peer, 0, sizeof(peer));
|
||||||
|
peer.sin_family = AF_INET;
|
||||||
|
inet_aton("192.0.2.1", &peer.sin_addr); /* Unreachable by RFC5737 */
|
||||||
|
|
||||||
|
nsock_connect_tcp(ctd->nsp, ctd->nsi, connect_handler, 4000, NULL,
|
||||||
|
(struct sockaddr *)&peer, sizeof(peer), PORT_TCP);
|
||||||
|
|
||||||
|
nsock_loop(ctd->nsp, 4000);
|
||||||
|
return ctd->connect_result == -ENETUNREACH ? 0 : ctd->connect_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const struct test_case TestConnectTCP = {
|
const struct test_case TestConnectTCP = {
|
||||||
.t_name = "simple tcp connection",
|
.t_name = "simple tcp connection",
|
||||||
@@ -87,3 +102,10 @@ const struct test_case TestConnectTCP = {
|
|||||||
.t_run = connect_tcp,
|
.t_run = connect_tcp,
|
||||||
.t_teardown = connect_teardown
|
.t_teardown = connect_teardown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct test_case TestConnectFailure = {
|
||||||
|
.t_name = "tcp connection failure case",
|
||||||
|
.t_setup = connect_setup,
|
||||||
|
.t_run = connect_tcp_failure,
|
||||||
|
.t_teardown = connect_teardown
|
||||||
|
};
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ extern const struct test_case TestTimer;
|
|||||||
extern const struct test_case TestLogLevels;
|
extern const struct test_case TestLogLevels;
|
||||||
extern const struct test_case TestErrLevels;
|
extern const struct test_case TestErrLevels;
|
||||||
extern const struct test_case TestConnectTCP;
|
extern const struct test_case TestConnectTCP;
|
||||||
|
extern const struct test_case TestConnectFailure;
|
||||||
extern const struct test_case TestGHLists;
|
extern const struct test_case TestGHLists;
|
||||||
extern const struct test_case TestGHHeaps;
|
extern const struct test_case TestGHHeaps;
|
||||||
extern const struct test_case TestHeapOrdering;
|
extern const struct test_case TestHeapOrdering;
|
||||||
@@ -48,6 +49,7 @@ static const struct test_case *TestCases[] = {
|
|||||||
&TestErrLevels,
|
&TestErrLevels,
|
||||||
/* ---- connect.c */
|
/* ---- connect.c */
|
||||||
&TestConnectTCP,
|
&TestConnectTCP,
|
||||||
|
&TestConnectFailure,
|
||||||
/* ---- ghlists.c */
|
/* ---- ghlists.c */
|
||||||
&TestGHLists,
|
&TestGHLists,
|
||||||
/* ---- ghheaps.c */
|
/* ---- ghheaps.c */
|
||||||
|
|||||||
Reference in New Issue
Block a user