Commit af625951 authored by Andreas Schmidt's avatar Andreas Schmidt

Tests now compile. Starting to develop test suite.

parent 650af3c2
......@@ -5,13 +5,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package (Threads)
enable_testing()
add_subdirectory(prrt)
find_package (Threads)
add_library(PRRT defines.h prrt/socket.c prrt/block.c prrt/block.h prrt/packet.c prrt/packet.h prrt/processes/feedback_receiver.c prrt/processes/feedback_receiver.h prrt/processes/data_transmitter.c prrt/processes/data_transmitter.h prrt/coding_params.c prrt/coding_params.h prrt/vdmcode/block_code.c prrt/vdmcode/block_code.h prrt/coding_params.c prrt/coding_params.h prrt/collections/in_buffer.c prrt/collections/in_buffer.h prrt/stores/forward_packet_table.c prrt/stores/forward_packet_table.h)
add_library(UTIL defines.h util/common.c util/common.h util/list.c util/list.h)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(prrt)
add_subdirectory(util)
add_subdirectory(tests)
add_executable(sender sender.c)
......
cmake_minimum_required (VERSION 2.8.11)
project (libprrt)
add_library(PRRT ../defines.h socket.c block.c block.h packet.c packet.h processes/feedback_receiver.c processes/feedback_receiver.h processes/data_transmitter.c processes/data_transmitter.h coding_params.c coding_params.h vdmcode/block_code.c vdmcode/block_code.h coding_params.c coding_params.h collections/in_buffer.c collections/in_buffer.h stores/forward_packet_table.c stores/forward_packet_table.h)
\ No newline at end of file
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include "../defines.h"
#include "socket.h"
#include "processes/feedback_receiver.h"
#include "processes/data_transmitter.h"
#include "packet.h"
int PrrtSocket_create(PrrtSocket *sock_ptr, const uint16_t port, const uint8_t is_sender) {
sock_ptr->seqno_source = 1;
......
#ifndef PRRT_SOCKET_H
#define PRRT_SOCKET_H
#include <arpa/inet.h>
#include <assert.h>
#include <netdb.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include "../defines.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "packet.h"
#include "../util/list.h"
#include "processes/feedback_receiver.h"
#include "processes/data_transmitter.h"
#include "stores/forward_packet_table.h"
#include <pthread.h>
#include "../defines.h"
#include "../util/list.h"
typedef struct {
const char* host_name;
......
#include <string.h>
#include <stdio.h>
#include "forward_packet_table.h"
#include "../../defines.h"
#include "../packet.h"
void move_start(PrrtForwardPacketTable *fpt_ptr) {
uint16_t seqno = fpt_ptr->start;
......@@ -28,6 +23,10 @@ int PrrtForwardPacketTable_create(PrrtForwardPacketTable *fpt_prt) {
memset(fpt_prt->data, 0, sizeof(fpt_prt->data));
}
int PrrtForwardPacketTable_destroy(PrrtForwardPacketTable* fpt_prt) {
}
int PrrtForwardPacketTable_test_set_is_number_relevant(PrrtForwardPacketTable *fpt_ptr, uint16_t seqno) {
uint16_t stop = (uint16_t) (SEQNO_SPACE / 2 + fpt_ptr->start);
......@@ -51,4 +50,4 @@ int PrrtForwardPacketTable_test_set_is_number_relevant(PrrtForwardPacketTable *f
return res;
}
}
}
\ No newline at end of file
......@@ -2,6 +2,11 @@
#define PRRT_FORWARD_PACKET_TABLE_H
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "../../defines.h"
#include "../packet.h"
#define FORWARD_PACKET_TABLE_LENGTH 2048 // sequence number space is 2**16 and we have 32 bit so: 2048
#define MAX_FORWARD_ENTRY_VALUE 4294967296 // 2**32
......
cmake_minimum_required(VERSION 2.8)
project(prrt_tests)
add_subdirectory(lib/gtest-1.7.0)
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(runPRRTTests forward_packet_table_tests.cpp)
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
target_link_libraries(runPRRTTests gtest gtest_main PRRT)
\ No newline at end of file
add_executable(prrtTests forward_packet_table_tests.cpp)
target_link_libraries(prrtTests LINK_PUBLIC PRRT UTIL gtest gtest_main)
\ No newline at end of file
#include <gtest/gtest.h>
#include "../prrt/stores/forward_packet_table.h"
TEST(ForwardPacketTable, ForwardPacketTable_Create) {
extern "C" {
#include "prrt/stores/forward_packet_table.h"
}
class ForwardPacketTableTest : public ::testing::Test {
protected:
virtual void SetUp() {
forwardPacketTable = (PrrtForwardPacketTable *) malloc(sizeof(PrrtForwardPacketTable));
PrrtForwardPacketTable_create(forwardPacketTable);
}
PrrtForwardPacketTable* forwardPacketTable;
};
TEST_F(ForwardPacketTableTest, Destroy) {
PrrtForwardPacketTable* forwardPacketTable = (PrrtForwardPacketTable *) malloc(sizeof(PrrtForwardPacketTable));
PrrtForwardPacketTable_create(forwardPacketTable);
PrrtForwardPacketTable_destroy(forwardPacketTable);
}
TEST_F(ForwardPacketTableTest, SimpleTestAndSet) {
int seqno = 1;
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, seqno));
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, seqno));
}
TEST_F(ForwardPacketTableTest, SimpleMoveStart) {
}
\ No newline at end of file
add_library(UTIL ../defines.h common.c common.h list.c list.h)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment