diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fb9dd4..cbeb15d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: Prepare run: | sudo apt-get update - sudo apt-get install -y libssl-dev libcurl4-openssl-dev uncrustify + sudo apt-get install -y libssl-dev libcurl4-openssl-dev uncrustify valgrind - name: Prepare libwebsockets run: | git clone https://libwebsockets.org/repo/libwebsockets --depth 1 --branch v4.2-stable @@ -65,3 +65,9 @@ jobs: kubectl describe node cd examples/ LD_LIBRARY_PATH=$GITHUB_WORKSPACE/kubernetes/build/:/usr/local/lib make test + - name: Valgrind memory check for examples + run: | + kubectl cluster-info --context kind-chart-testing + kubectl describe node + cd examples/ + LD_LIBRARY_PATH=$GITHUB_WORKSPACE/kubernetes/build/:/usr/local/lib make memcheck diff --git a/examples/Makefile b/examples/Makefile index f129cec..e20db88 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -35,4 +35,15 @@ test: cd generic; make test cd multi_thread; make test; sleep 10 kubectl describe po test-pod-8 - cd exec_pod; make test \ No newline at end of file + cd exec_pod; make test + +memcheck: + cd create_pod; make memcheck; sleep 10 + cd list_pod; make memcheck + cd delete_pod; make memcheck + cd list_secret; make memcheck + cd configmap; make memcheck + cd generic; make memcheck + cd multi_thread; make memcheck; sleep 10 + kubectl describe po test-pod-8 + cd exec_pod; make memcheck \ No newline at end of file diff --git a/examples/configmap/Makefile b/examples/configmap/Makefile index 6dfac4c..058ff36 100644 --- a/examples/configmap/Makefile +++ b/examples/configmap/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=configmap_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + test: ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm ./$(BIN) diff --git a/examples/create_pod/Makefile b/examples/create_pod/Makefile index a9efb20..5930e83 100644 --- a/examples/create_pod/Makefile +++ b/examples/create_pod/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=create_pod_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + test: ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm ./$(BIN) diff --git a/examples/delete_pod/Makefile b/examples/delete_pod/Makefile index cf35e8b..347ec91 100644 --- a/examples/delete_pod/Makefile +++ b/examples/delete_pod/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=delete_pod_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + test: ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm ./$(BIN) diff --git a/examples/exec_pod/Makefile b/examples/exec_pod/Makefile index e8f8f2c..0d82482 100644 --- a/examples/exec_pod/Makefile +++ b/examples/exec_pod/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=exec_pod_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + test: ./$(BIN) only-run-case-1 + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) only-run-case-1 + +clean: + rm ./$(BIN) diff --git a/examples/generic/Makefile b/examples/generic/Makefile index f1296c9..ee3f689 100644 --- a/examples/generic/Makefile +++ b/examples/generic/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=generic_bin +.PHONY : all clean test memcheck all: - gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) + test: - ./$(BIN) \ No newline at end of file + ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm ./$(BIN) \ No newline at end of file diff --git a/examples/list_pod/Makefile b/examples/list_pod/Makefile index 9445012..6bea062 100644 --- a/examples/list_pod/Makefile +++ b/examples/list_pod/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lyaml -lwebsockets -lkubernetes -L/usr/local/lib CFLAGS:=-g BIN:=list_pod_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + test: ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm ./$(BIN) diff --git a/examples/list_secret/Makefile b/examples/list_secret/Makefile index d3ffae9..149d3de 100644 --- a/examples/list_secret/Makefile +++ b/examples/list_secret/Makefile @@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib CFLAGS:=-g BIN:=list_secret_bin +.PHONY : all clean test memcheck all: gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN) -clean: - rm ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + test: ./$(BIN) + +clean: + rm ./$(BIN) diff --git a/examples/multi_thread/Makefile b/examples/multi_thread/Makefile index d2bbd99..53a61af 100644 --- a/examples/multi_thread/Makefile +++ b/examples/multi_thread/Makefile @@ -5,14 +5,18 @@ CFLAGS:=-g BIN:= multi_thread_bin OBJECTS:=main.o watch_pod.o create_pod.o +.PHONY : all clean test memcheck all: $(OBJECTS) $(CC) -o $(BIN) $(OBJECTS) $(LIBS) $(OBJECTS): %.o: %.c $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ -.PHONY : clean test -clean: - rm $(BIN) $(OBJECTS) test: - ./$(BIN) \ No newline at end of file + ./$(BIN) + +memcheck: + valgrind --tool=memcheck --leak-check=full ./$(BIN) + +clean: + rm $(BIN) $(OBJECTS) \ No newline at end of file