mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Make current loglevel and current log callback global to the library. Attaching them to the nsock pool doesn't bring any benefit and prevents from logging activity in code sections that don't have access to a pool (such as proxy chain specification parsing). Updated external calls and nsock tests accordingly.
53 lines
1.0 KiB
C
53 lines
1.0 KiB
C
/*
|
|
* Nsock regression test suite
|
|
* Same license as nmap -- see http://nmap.org/book/man-legal.html
|
|
*/
|
|
|
|
#include "test-common.h"
|
|
|
|
|
|
struct basic_test_data {
|
|
nsock_pool nsp;
|
|
};
|
|
|
|
static int basic_setup(void **tdata) {
|
|
struct basic_test_data *btd;
|
|
|
|
btd = calloc(1, sizeof(struct basic_test_data));
|
|
if (btd == NULL)
|
|
return -ENOMEM;
|
|
|
|
btd->nsp = nsock_pool_new(NULL);
|
|
|
|
*tdata = btd;
|
|
return 0;
|
|
}
|
|
|
|
static int basic_teardown(void *tdata) {
|
|
struct basic_test_data *btd = (struct basic_test_data *)tdata;
|
|
|
|
if (tdata) {
|
|
nsock_pool_delete(btd->nsp);
|
|
free(tdata);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int basic_udata(void *tdata) {
|
|
struct basic_test_data *btd = (struct basic_test_data *)tdata;
|
|
|
|
AssertEqual(nsock_pool_get_udata(btd->nsp), NULL);
|
|
nsock_pool_set_udata(btd->nsp, btd);
|
|
AssertEqual(nsock_pool_get_udata(btd->nsp), btd);
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
const struct test_case TestPoolUserData = {
|
|
.t_name = "nsock pool user data",
|
|
.t_setup = basic_setup,
|
|
.t_run = basic_udata,
|
|
.t_teardown = basic_teardown
|
|
};
|