I am writing a test unit for function named pkg_getclient ().
It is, basically, a function that listens indefinetly for a client.
Here is the implementation : http://slexy.org/view/s21RBuOUOu (pasted there to keep question text size reasonable )
Here is an example of a client - server test : http://slexy.org/view/s2fS5hBkgI
This is the current status of my unit test :
int test_pkg_getclient (char* portname) {
int netfd;
struct pkg_conn *result;
netfd = pkg_permserver(portname, "tcp", 0, 0);
/* validate_port(port); */
printf("TESTING PKG_GETCLIENT...\n");
result = pkg_getclient(netfd,callbacks, NULL, 0);
printf("TESTING VALID FILE DESCRIPTOR\n");
if (result == PKC_ERROR) {printf ("\t[ FAILED ]\n");
} else { printf ("\t[ PASSED ]\n");
}
return 0;
}
int main (int argc, char* argv[]) {
test_pkg_getclient(argv[1]);
printf("%d",argc);
return 0;
}
I need to break the pkg_getclient() blocking call. It needs to be portable to Windows aswell, not only unix-based systems. I cannot modify the pkg_getclient() function. The blocking function is inside getclient().
Is there any way to use signal handling to break the blocking call? Or is there any other way around this ?