Commit 83b4e0a6 authored by Greg Williams's avatar Greg Williams
Browse files

Fixed double close on file handle in unity_helper.h.

Make test socket configurable in test.
parent 8eaaec9f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
*
*/

#include "unity.h"
#include "unity_helper.h"
#include "kinetic_logger.h"

@@ -60,5 +59,3 @@ void test_KineticLogger_Log_should_write_log_message_to_file(void)
    TEST_ASSERT_EQUAL_FILE_CONTENT(TEST_LOG_FILE, content, length);
}

+5 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

static char Msg[1024];
static int FileDesc;
static int KineticTestPort = 8999;

void setUp(void)
{
@@ -48,11 +49,13 @@ void test_KineticSocket_KINETIC_PORT_should_be_8213(void)

void test_KineticSocket_Connect_should_create_a_socket_connection(void)
{
    KineticLogger_Log_Expect("Connecting to localhost:8999");
    char msg[128];
    sprintf(msg, "Connecting to localhost:%d", KineticTestPort);
    KineticLogger_Log_Expect(msg);
    KineticLogger_Log_Expect("Trying to connect to host");
    KineticLogger_Log_Expect("Connected to host!");

    int FileDesc = KineticSocket_Connect("localhost", 8999, true);
    int FileDesc = KineticSocket_Connect("localhost", KineticTestPort, true);

    TEST_ASSERT_MESSAGE(FileDesc >= 0, "File descriptor invalid");
}
+3 −3
Original line number Diff line number Diff line
@@ -91,14 +91,14 @@ if (expected != actual) { \
    TEST_ASSERT_NOT_NULL_MESSAGE(f, "Failed to open file for reading: " #fname ); \
    for (actualLen = 0; actualLen < len; actualLen++) { \
        c = fgetc(f); \
        if (c == EOF) { printf("EOF found! EOF: 0x%02X", (int)c); break; } \
        if (c == EOF) { perror("EOF found!"); break; } \
        buff[actualLen] = c; } \
    buff[actualLen] = '\0'; /* Append NULL terminator */ \
    TEST_ASSERT_NOT_EQUAL_MESSAGE(EOF, c, err); \
    if (actualLen != len) { \
        TEST_ASSERT_NOT_EQUAL_MESSAGE(EOF, c, err); } \
    TEST_ASSERT_EQUAL_SIZET_MESSAGE(len, actualLen, "File read error (truncated?)!"); \
    TEST_ASSERT_EQUAL_STRING_MESSAGE(content, buff, "File contents did not match!"); \
    TEST_ASSERT_EQUAL_MESSAGE(0, fclose(f), "Failed closing file: " #fname ); \
    fclose(f); \
}