libtcti-socket: Refactor InitSockets function.

The previous implementation of this function created and connected the
two sockets for communication with the simulator. It seems pretty
logical to have the function do this for only one socket but call it
twice. This saves us a bit of code gets us better re-use. Testing is
also easier (fewer code paths) and we add a unit test for this module &
function.

Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
diff --git a/Makefile-test.am b/Makefile-test.am
index 6abe701..b8627fe 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -45,6 +45,7 @@
     test/unit/CommonPreparePrologue \
     test/unit/CopyCommandHeader \
     test/unit/GetNumHandles \
+    test/unit/socket \
     test/unit/tcti-device \
     test/unit/tcti-socket \
     test/unit/util \
@@ -128,6 +129,11 @@
 test_unit_tcti_socket_SOURCES = tcti/platformcommand.c tcti/tcti_socket.c \
     tcti/sockets.c tcti/sockets.h test/unit/tcti-socket.c
 
+test_unit_socket_CFLAGS  = $(CMOCKA_CFLAGS) $(AM_CFLAGS)
+test_unit_socket_LDADD   = $(CMOCKA_LIBS) $(libutil)
+test_unit_socket_LDFLAGS = -Wl,--wrap=connect,--wrap=socket
+test_unit_socket_SOURCES = test/unit/socket.c tcti/sockets.c tcti/sockets.h
+
 test_unit_CommonPreparePrologue_CFLAGS = $(CMOCKA_CFLAGS) $(AM_CFLAGS)
 test_unit_CommonPreparePrologue_LDFLAGS = -Wl,--unresolved-symbols=ignore-all
 test_unit_CommonPreparePrologue_LDADD = $(CMOCKA_LIBS) $(libsapi)