test for write and read of shared memory in main.cpp
This commit is contained in:
parent
121ae391c0
commit
bf6546e3b8
@ -20,6 +20,7 @@ set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library")
|
|||||||
include_directories(${LIB_PATH}/include)
|
include_directories(${LIB_PATH}/include)
|
||||||
add_executable(SharedMemory ${SOURCES} ${HEADERS} main/main.cpp)
|
add_executable(SharedMemory ${SOURCES} ${HEADERS} main/main.cpp)
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(SharedMemory ${LIB_PATH}/lib/liblibrary.a)
|
target_link_libraries(SharedMemory ${LIB_PATH}/lib/liblibrary.a)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include "../src/SharedMemory.h"
|
#include "../src/SharedMemory.h"
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <SharedMemoryAccess.h>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@ -29,6 +31,23 @@ int main(int argc, char** argv)
|
|||||||
//Memory that is used now
|
//Memory that is used now
|
||||||
//outprint of all memory
|
//outprint of all memory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Test for write and read
|
||||||
|
if(eingabe == "write") {
|
||||||
|
//write a bitMap for example 2 (width) * 2 (high) * 3 (color) in Schared Memory
|
||||||
|
char bitMap[12] = {0};
|
||||||
|
for(int i = 0; i < sizeof(bitMap); i++)
|
||||||
|
bitMap[i] = 'y';
|
||||||
|
writeSharedMemory(bitMap, sizeof(bitMap),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(eingabe == "read") {
|
||||||
|
char content[12] = {0};
|
||||||
|
std::cout << "key "<< impl.sharedMemoryKey << std::endl;
|
||||||
|
getSharedMemory(content, sizeof(content), 1);
|
||||||
|
|
||||||
|
std::cout << content << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user