Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
5a63446bd4
32
.ci/clang-tidy.sh
Normal file
32
.ci/clang-tidy.sh
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Doing clang-tidy..."
|
||||||
|
bool=false
|
||||||
|
# explicitly set IFS to contain only a line feed
|
||||||
|
IFS='
|
||||||
|
'
|
||||||
|
filelist="$(find . -not \( -path './client/cpptoml/*' -prune \) -type f ! -name "$(printf "*\n*")")"
|
||||||
|
for file in $filelist; do
|
||||||
|
if echo "$file" | grep -q -E ".*\.cpp$" ; then
|
||||||
|
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
|
||||||
|
clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)"
|
||||||
|
for tidy_line in $clang_tidy_lib_check; do
|
||||||
|
echo "$tidy_line" | grep -q -v -E "^Error while processing*"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
bool=true
|
||||||
|
fi
|
||||||
|
echo "$tidy_line" | grep -q -v -E ".* error: .*"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
bool=true
|
||||||
|
fi
|
||||||
|
echo "$tidy_line"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if $bool; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "No clang-tidy errors found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
68
.gitlab-ci.yml
Normal file
68
.gitlab-ci.yml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
image: samueldebruyn/debian-git:latest
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- style
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
|
||||||
|
|
||||||
|
clang_tidy:
|
||||||
|
image: jhasse/clang-tidy
|
||||||
|
stage: style
|
||||||
|
tags:
|
||||||
|
- docker-ci
|
||||||
|
script:
|
||||||
|
- sh .ci/clang-tidy.sh;
|
||||||
|
|
||||||
|
make_test:
|
||||||
|
stage: test
|
||||||
|
tags:
|
||||||
|
- docker-ci
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y g++ make cmake clang-tidy
|
||||||
|
- mkdir current
|
||||||
|
- ls | grep -v current | xargs mv -t current
|
||||||
|
- git clone https://github.com/catchorg/Catch2.git
|
||||||
|
- cd Catch2
|
||||||
|
- cmake -Bbuild -H. -DBUILD_TESTING=OFF
|
||||||
|
- cmake --build build/ --target install
|
||||||
|
- cd ..
|
||||||
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git
|
||||||
|
- mkdir library/build
|
||||||
|
- cd library/build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
||||||
|
- cd ../../current
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
||||||
|
- make test
|
||||||
|
|
||||||
|
cmake_build:
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker-ci
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y g++ make cmake clang-tidy
|
||||||
|
- mkdir current
|
||||||
|
- ls | grep -v current | xargs mv -t current
|
||||||
|
- git clone https://github.com/catchorg/Catch2.git
|
||||||
|
- cd Catch2
|
||||||
|
- cmake -Bbuild -H. -DBUILD_TESTING=OFF
|
||||||
|
- cmake --build build/ --target install
|
||||||
|
- cd ..
|
||||||
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git
|
||||||
|
- mkdir library/build
|
||||||
|
- cd library/build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
||||||
|
- cd ../../current
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
@ -1,19 +1,34 @@
|
|||||||
#include "../src/SharedMemory.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include "../src/SharedMemory.h"
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
sharedMemoryInit();
|
initSharedMemory();
|
||||||
struct sigaction sigIntHandler;
|
struct sigaction sigIntHandler;
|
||||||
sigIntHandler.sa_handler = deleteSharedMemory;
|
sigIntHandler.sa_handler = deleteSharedMemory;
|
||||||
sigemptyset(&sigIntHandler.sa_mask);
|
sigemptyset(&sigIntHandler.sa_mask);
|
||||||
sigIntHandler.sa_flags = 0;
|
sigIntHandler.sa_flags = 0;
|
||||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||||
sleep(3); // TODO: warte auf eingabe
|
|
||||||
std::atexit(deleteSharedMemory);
|
std::atexit(deleteSharedMemory);
|
||||||
|
std::string eingabe = "";
|
||||||
|
while(eingabe != "exit") {
|
||||||
|
std::cout << "cmd# ";
|
||||||
|
std::cin >> eingabe;
|
||||||
|
//if verschieden information ausgaben
|
||||||
|
if(eingabe == "info")
|
||||||
|
{
|
||||||
|
std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl;
|
||||||
|
std::cout << "memory ID: " << shmget(impl.sharedMemoryKey, 0, 0) << std::endl;
|
||||||
|
std::cout << "Max memory Size: " << Max_Memory_Size << std::endl;
|
||||||
|
std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl;
|
||||||
|
//Memory that is used now
|
||||||
|
//outprint of all memory
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,44 +1,81 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sys/ipc.h>
|
|
||||||
#include <sys/shm.h>
|
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define Max_Memory_Size 8000
|
|
||||||
|
|
||||||
int memoryAccessKey = 12345;
|
key_t changedKey()
|
||||||
int memID;
|
{
|
||||||
|
int newKey;
|
||||||
|
std::cout << "Type in a new Key for the Shared Memory Segment" << std::endl;
|
||||||
|
std::cout << "new Key#";
|
||||||
|
std::cin >> newKey;
|
||||||
|
std::cout <<"New Key is -> " << newKey << std::endl;
|
||||||
|
return key_t(newKey);
|
||||||
|
}
|
||||||
|
|
||||||
void sharedMemoryInit() {
|
std::string getAnswerFromUser()
|
||||||
if ((memID = shmget(memoryAccessKey, Max_Memory_Size, IPC_CREAT | IPC_EXCL | 0666)) < 0) {
|
{
|
||||||
std::cerr << "Shared memory with Key: " << memoryAccessKey
|
std::cout <<"answer# ";
|
||||||
<< " already exists. Delete by Hand before starting vKFM" << std::endl;
|
std::string answer;
|
||||||
exit(0);
|
std::cin >> answer;
|
||||||
|
if(answer.compare("y") == 0 || answer.compare("n") == 0|| answer.compare("override") == 0) {
|
||||||
|
return answer;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Shared memory with Key: " << memoryAccessKey << " allocated" << std::endl;
|
std::cout << "wrong input: pls answer with (y) for yes, (n) for no, or (override)\n";
|
||||||
|
getAnswerFromUser();
|
||||||
}
|
}
|
||||||
|
return "-0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initSharedMemory(void) {
|
||||||
|
if(impl.sharedMemoryKey != key_t(0)) {
|
||||||
|
if (shmget(impl.sharedMemoryKey, Max_Memory_Size, IPC_CREAT | IPC_EXCL | 0666) < 0)
|
||||||
|
{
|
||||||
|
std::cout << "Shared Memory with Key: " << impl.sharedMemoryKey << " is already in use\n"
|
||||||
|
<<"You can change the Key( type -> y or n ), or you can override the shared memory Segment(type -> override)\n";
|
||||||
|
std::string answer = getAnswerFromUser();
|
||||||
|
if(answer.compare("y") == 0)
|
||||||
|
{
|
||||||
|
std::cout << "Please type in a new Key:\n";
|
||||||
|
std::cout << "#";
|
||||||
|
std::cin >> impl.sharedMemoryKey;
|
||||||
|
std::cout << "new Try with Key:c " << impl.sharedMemoryKey << std::endl;
|
||||||
|
initSharedMemory();
|
||||||
|
} else if(answer.compare("n") == 0) {
|
||||||
|
std::cout << "This will end shared memory" <<std::endl;
|
||||||
|
exit(0);
|
||||||
|
} else if(answer.compare("override") == 0) {
|
||||||
|
deleteSharedMemory();
|
||||||
|
initSharedMemory();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "Shared Memory is (Re-) allocated with Key: " << impl.sharedMemoryKey << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr <<"key -> " << impl.sharedMemoryKey << " is not allowed here " << std::endl;
|
||||||
|
impl.sharedMemoryKey = changedKey();
|
||||||
|
initSharedMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void deleteSharedMemory(int s)
|
void deleteSharedMemory(int s)
|
||||||
{
|
{
|
||||||
if (shmctl(memID, IPC_RMID, NULL) < 0 )
|
std::cerr << "programm ended with Code: " << s << std::endl;
|
||||||
|
if (shmctl(shmget(impl.sharedMemoryKey, 0, 0), IPC_RMID, 0) < 0 )
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs " << std::endl;
|
std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs, then delete with ipcrm -m $memID " << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "shared Memory deleted" << std::endl;
|
std::cout << "shared Memory deleted" << std::endl;
|
||||||
}
|
}
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteSharedMemory(void)
|
void deleteSharedMemory(void)
|
||||||
{
|
{
|
||||||
if (shmctl(memID, IPC_RMID, NULL) < 0 )
|
if (shmctl(shmget(impl.sharedMemoryKey, 0, 0), IPC_RMID, 0) < 0 )
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs " << std::endl;
|
std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs " << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "shared Memory deleted" << std::endl;
|
std::cout << "shared Memory deleted" << std::endl;
|
||||||
}
|
}
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#ifndef SHARED_MEMORY_H
|
#ifndef SHARED_MEMORY_H
|
||||||
#define SHARED_MEMORY_H
|
#define SHARED_MEMORY_H
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
//ID-Speicherbereich
|
//ID-Speicherbereich
|
||||||
//Größe des Speicherbereichs hier 8MB (8000)
|
//Größe des Speicherbereichs hier 8MB (8000)
|
||||||
#define shmMaxSize 8000
|
#define shmMaxSize 8000
|
||||||
|
|
||||||
//Shared-Memory-Segment erstellen oder öffnen – shmget()
|
//Shared-Memory-Segment erstellen oder öffnen – shmget()
|
||||||
void sharedMemoryInit();
|
#define Max_Memory_Size 8000
|
||||||
void deleteSharedMemory(int s);
|
void deleteSharedMemory(int s);
|
||||||
void deleteSharedMemory(void);
|
void deleteSharedMemory(void);
|
||||||
|
void initSharedMemory(void);
|
||||||
#endif //SHARED_MEMORY_H
|
#endif //SHARED_MEMORY_H
|
||||||
|
Loading…
Reference in New Issue
Block a user