Skip to content

Commit

Permalink
Add valgrind memory check for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ityuhui committed Aug 12, 2022
1 parent 8f8874e commit 3fe8c8b
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 22 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
13 changes: 12 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
10 changes: 8 additions & 2 deletions examples/configmap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions examples/create_pod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions examples/delete_pod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions examples/exec_pod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 10 additions & 4 deletions examples/generic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
./$(BIN)

memcheck:
valgrind --tool=memcheck --leak-check=full ./$(BIN)

clean:
rm ./$(BIN)
10 changes: 8 additions & 2 deletions examples/list_pod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions examples/list_secret/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 8 additions & 4 deletions examples/multi_thread/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
./$(BIN)

memcheck:
valgrind --tool=memcheck --leak-check=full ./$(BIN)

clean:
rm $(BIN) $(OBJECTS)

0 comments on commit 3fe8c8b

Please sign in to comment.