Initial commit
This commit is contained in:
19
Test/UnitTests/CMakeLists.txt
Normal file
19
Test/UnitTests/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(marte_dev_tests)
|
||||
|
||||
include_directories(
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L0Types
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L1Portability
|
||||
# ... more ...
|
||||
../../Source
|
||||
../../Headers
|
||||
)
|
||||
|
||||
file(GLOB SOURCES "*.cpp")
|
||||
|
||||
add_executable(UnitTests ${SOURCES})
|
||||
|
||||
target_link_libraries(UnitTests
|
||||
marte_dev
|
||||
${MARTe2_DIR}/Build/${TARGET}/Core/libMARTe2.so
|
||||
)
|
||||
35
Test/UnitTests/main.cpp
Normal file
35
Test/UnitTests/main.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "DebugCore.h"
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
void TestRingBuffer() {
|
||||
printf("Testing TraceRingBuffer...\n");
|
||||
TraceRingBuffer rb;
|
||||
assert(rb.Init(1024));
|
||||
|
||||
uint32 id = 42;
|
||||
uint32 val = 12345678;
|
||||
uint32 size = 4;
|
||||
|
||||
assert(rb.Push(id, &val, size));
|
||||
assert(rb.Count() > 0);
|
||||
|
||||
uint32 poppedId = 0;
|
||||
uint32 poppedVal = 0;
|
||||
uint32 poppedSize = 0;
|
||||
|
||||
assert(rb.Pop(poppedId, &poppedVal, poppedSize, 4));
|
||||
assert(poppedId == 42);
|
||||
assert(poppedVal == 12345678);
|
||||
assert(poppedSize == 4);
|
||||
|
||||
printf("TraceRingBuffer test passed.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
printf("Running MARTe2 Component Tests...\n");
|
||||
TestRingBuffer();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user