diff --git a/Makefile b/Makefile index 0162277..524d6a9 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,6 @@ default: cp src/libkeepalive.so libkeepalive.so strip -s libkeepalive.so -test: default - make -C test/ runtest - clean: make -C src/ clean make -C test/ clean diff --git a/src/Makefile b/src/Makefile index 19e3785..b8b0188 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,10 +7,10 @@ # # (C) Fabio Busatto -CC := gcc -CFLAGS += -fPIC -ansi -pedantic -Wall -LDFLAGS += -shared -Wl,-soname,libkeepalive.so -LDLIBS += -ldl +CC=gcc +CFLAGS=-fPIC -ansi -pedantic -Wall +LDFLAGS=-shared -Wl,-soname,libkeepalive.so +LDLIBS=-ldl default: libkeepalive.so diff --git a/src/libkeepalive.c b/src/libkeepalive.c index 06b66ca..a08bd98 100644 --- a/src/libkeepalive.c +++ b/src/libkeepalive.c @@ -1,4 +1,3 @@ -/* vim: set ts=2 sw=2 et: */ /* _ _ _ _ _ _ | (_) |__ | | _____ ___ _ __ __ _| (_)_ _____ diff --git a/test/Makefile b/test/Makefile index 6a279a0..2a0f6e2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,15 +7,9 @@ # # (C) Fabio Busatto -CC := gcc +CC=gcc default: test -TENV = LD_PRELOAD=../libkeepalive.so SELFTEST=on -runtest: - ${TENV} KEEPALIVE=off ./test - ${TENV} KEEPCNT=13 KEEPIDLE=23 KEEPINTVL=42 ./test - ${TENV} KEEPCNT=42 KEEPIDLE=13 KEEPINTVL=23 ./test - clean: rm -f test diff --git a/test/test.c b/test/test.c index 7eaaaed..756d7ae 100644 --- a/test/test.c +++ b/test/test.c @@ -1,4 +1,3 @@ -/* vim: set ts=2 sw=2 et: */ /* _ _ _ _ _ _ | (_) |__ | | _____ ___ _ __ __ _| (_)_ _____ @@ -32,23 +31,14 @@ */ #define _GNU_SOURCE -#include #include #include -#include #include #include #include #include #include -#define assert(x) do { \ - if (!(x)) { \ - printf("%s:%d: assertion '" #x "' failed!\n", __FILE__, __LINE__); \ - exit(EXIT_FAILURE); \ - } \ -} while (0) - int main(void); int main() @@ -56,11 +46,6 @@ int main() int s; int optval; socklen_t optlen = sizeof(optval); - const char *env; - bool selftest = false; - - env = getenv("SELFTEST"); - selftest = env && !strcasecmp(env, "on"); if((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { perror("socket()"); @@ -72,12 +57,7 @@ int main() close(s); exit(EXIT_FAILURE); } - if (selftest) { - env = getenv("KEEPALIVE"); - assert((env && !strcasecmp(env, "off")) ^ optval); - } else { - printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); - } + printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); if(optval) { #ifdef TCP_KEEPCNT @@ -86,43 +66,28 @@ int main() close(s); exit(EXIT_FAILURE); } - if (selftest) { - env = getenv("KEEPCNT"); - assert(!env || atoi(env) == optval); - } else { - printf("TCP_KEEPCNT = %d\n", optval); - } + printf("TCP_KEEPCNT = %d\n", optval); #endif - + #ifdef TCP_KEEPIDLE if(getsockopt(s, SOL_TCP, TCP_KEEPIDLE, &optval, &optlen) < 0) { perror("getsockopt()"); close(s); exit(EXIT_FAILURE); } - if (selftest) { - env = getenv("KEEPIDLE"); - assert(!env || atoi(env) == optval); - } else { - printf("TCP_KEEPIDLE = %d\n", optval); - } + printf("TCP_KEEPIDLE = %d\n", optval); #endif - + #ifdef TCP_KEEPINTVL if(getsockopt(s, SOL_TCP, TCP_KEEPINTVL, &optval, &optlen) < 0) { perror("getsockopt()"); close(s); exit(EXIT_FAILURE); } - if (selftest) { - env = getenv("KEEPINTVL"); - assert(!env || atoi(env) == optval); - } else { - printf("TCP_KEEPINTVL = %d\n", optval); - } + printf("TCP_KEEPINTVL = %d\n", optval); #endif } - + close(s); exit(EXIT_SUCCESS);