Beispiel #1
0
void IO_Write(ioAddress offset, ioData data)
{

  Mock.IO_Write_CallCount++;
  if (Mock.IO_Write_CallCount > Mock.IO_Write_CallsExpected)
  {
    TEST_FAIL("Function 'IO_Write' called more times than expected");
  }

  if (Mock.IO_Write_Expected_offset != Mock.IO_Write_Expected_offset_Tail)
  {
    ioAddress* p_expected = Mock.IO_Write_Expected_offset;
    Mock.IO_Write_Expected_offset++;
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE((void*)p_expected, (void*)&(offset), sizeof(ioAddress), "Function 'IO_Write' called with unexpected value for argument 'offset'.");

  }

  if (Mock.IO_Write_Expected_data != Mock.IO_Write_Expected_data_Tail)
  {
    ioData* p_expected = Mock.IO_Write_Expected_data;
    Mock.IO_Write_Expected_data++;
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE((void*)p_expected, (void*)&(data), sizeof(ioData), "Function 'IO_Write' called with unexpected value for argument 'data'.");

  }
}
Beispiel #2
0
void
test_channel_local_addr_get_set_unset(void) {
    lagopus_result_t ret;
    struct channel *channel;
    struct addrunion addr  = {0,{{0}}};
    struct addrunion addr1 = {0,{{0}}};

    channel = s_create_data_channel();
    addrunion_ipv4_set(&addr, "127.0.0.1");
    ret = channel_local_addr_set(channel, &addr);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_local_addr_set() error.");

    ret = channel_local_addr_get(channel, &addr1);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_local_addr_get() error.");
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE(&addr, &addr1, sizeof(addr),
                                     "channel_local_addr_get() addr error");

    ret = channel_local_addr_unset(channel);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_local_addr_unset() error.");

    ret = channel_local_addr_get(channel, &addr1);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_local_addr_get() error.");
    addrunion_ipv4_set(&addr, "0.0.0.0");
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE(&addr, &addr1, sizeof(addr),
                                     "channel_local_addr_get() addr  error");

    session_destroy(channel_session_get(channel));
    free(channel);
}
Beispiel #3
0
ioData IO_Read(ioAddress offset)
{
  Mock.IO_Read_CallCount++;
  if (Mock.IO_Read_CallCount > Mock.IO_Read_CallsExpected)
  {
    TEST_FAIL("Function 'IO_Read' called more times than expected");
  }

  if (Mock.IO_Read_Expected_offset != Mock.IO_Read_Expected_offset_Tail)
  {
    ioAddress* p_expected = Mock.IO_Read_Expected_offset;
    Mock.IO_Read_Expected_offset++;
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE(
        (void*)p_expected, (void*)&(offset), sizeof(ioAddress),
        "Function 'IO_Read' called with unexpected value for argument 'offset'.");
  }

  if (Mock.IO_Read_Return != Mock.IO_Read_Return_Tail)
  {
    ioData toReturn = *Mock.IO_Read_Return;
    Mock.IO_Read_Return++;
    return toReturn;
  }
  else
  {
    return *(Mock.IO_Read_Return_Tail - 1);
  }
}
Beispiel #4
0
void
test_channel_alloc_default_value(void) {
    uint16_t port;
    lagopus_result_t ret;
    struct channel *channel;
    enum channel_protocol protocol;
    struct addrunion addr  = {0,{{0}}};
    struct addrunion addr1 = {0,{{0}}};

    TEST_ASSERT_EQUAL_MEMORY_MESSAGE(&addr, &addr1, sizeof(addr),
                                     "channel_addr_get() addr error");
    channel = s_create_data_channel();
    addrunion_ipv4_set(&addr1, "127.0.0.1");

    ret = channel_port_get(channel, &port);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "channel_port_get() error.");
    TEST_ASSERT_EQUAL_MESSAGE(6633, port, "channel_port_get() port error");

    ret = channel_local_port_get(channel, &port);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_local_port_get() error.");
    TEST_ASSERT_EQUAL_MESSAGE(0, port, "channel_local_port_get() port error");

    ret = channel_protocol_get(channel, &protocol);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_protocol_get() error.");
    TEST_ASSERT_EQUAL_MESSAGE(PROTOCOL_TCP, protocol,
                              "channel_protocol_get() proto error");

    ret = channel_addr_get(channel, &addr);
    TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                              "channel_addr_get() error.");
    TEST_ASSERT_EQUAL_MEMORY_MESSAGE(&addr1, &addr, sizeof(addr),
                                     "channel_addr_get() addr error");

    session_destroy(channel_session_get(channel));
    free(channel);
}