Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Valgrind memory check for examples #133

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 18 additions & 3 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,27 @@ clean:
cd configmap; make clean

test:
cd create_pod; make test; sleep 10
cd create_pod; make test;
kubectl wait --for=condition=ready --all pod -n default --timeout=60s
cd list_pod; make test
cd delete_pod; make test
cd list_secret; make test
cd configmap; make test
cd generic; make test
cd multi_thread; make test; sleep 10
cd multi_thread; make test;
kubectl wait --for=condition=ready pod/test-pod-8 -n default --timeout=60s
kubectl describe po test-pod-8
cd exec_pod; make test
cd exec_pod; make test

memcheck:
cd create_pod; make memcheck;
kubectl wait --for=condition=ready --all pod -n default --timeout=60s
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;
kubectl wait --for=condition=ready pod/test-pod-8 -n default --timeout=60s
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)