Skip to content

Commit 4e38e72

Browse files
authored
Merge pull request #133 from ityuhui/yh-memory-test-0812
Add the Valgrind memory check for examples
2 parents 8f8874e + fd7fbe5 commit 4e38e72

File tree

10 files changed

+91
-24
lines changed

10 files changed

+91
-24
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Prepare
1616
run: |
1717
sudo apt-get update
18-
sudo apt-get install -y libssl-dev libcurl4-openssl-dev uncrustify
18+
sudo apt-get install -y libssl-dev libcurl4-openssl-dev uncrustify valgrind
1919
- name: Prepare libwebsockets
2020
run: |
2121
git clone https://libwebsockets.org/repo/libwebsockets --depth 1 --branch v4.2-stable
@@ -65,3 +65,9 @@ jobs:
6565
kubectl describe node
6666
cd examples/
6767
LD_LIBRARY_PATH=$GITHUB_WORKSPACE/kubernetes/build/:/usr/local/lib make test
68+
- name: Valgrind memory check for examples
69+
run: |
70+
kubectl cluster-info --context kind-chart-testing
71+
kubectl describe node
72+
cd examples/
73+
LD_LIBRARY_PATH=$GITHUB_WORKSPACE/kubernetes/build/:/usr/local/lib make memcheck

examples/Makefile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,27 @@ clean:
2727
cd configmap; make clean
2828

2929
test:
30-
cd create_pod; make test; sleep 10
30+
cd create_pod; make test;
31+
kubectl wait --for=condition=ready --all pod -n default --timeout=60s
3132
cd list_pod; make test
3233
cd delete_pod; make test
3334
cd list_secret; make test
3435
cd configmap; make test
3536
cd generic; make test
36-
cd multi_thread; make test; sleep 10
37+
cd multi_thread; make test;
38+
kubectl wait --for=condition=ready pod/test-pod-8 -n default --timeout=60s
3739
kubectl describe po test-pod-8
38-
cd exec_pod; make test
40+
cd exec_pod; make test
41+
42+
memcheck:
43+
cd create_pod; make memcheck;
44+
kubectl wait --for=condition=ready --all pod -n default --timeout=60s
45+
cd list_pod; make memcheck
46+
cd delete_pod; make memcheck
47+
cd list_secret; make memcheck
48+
cd configmap; make memcheck
49+
cd generic; make memcheck
50+
cd multi_thread; make memcheck;
51+
kubectl wait --for=condition=ready pod/test-pod-8 -n default --timeout=60s
52+
kubectl describe po test-pod-8
53+
cd exec_pod; make memcheck

examples/configmap/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=configmap_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
1010
test:
1111
./$(BIN)
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/create_pod/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=create_pod_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
1010
test:
1111
./$(BIN)
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/delete_pod/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=delete_pod_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
1010
test:
1111
./$(BIN)
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/exec_pod/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=exec_pod_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
1010
test:
1111
./$(BIN) only-run-case-1
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN) only-run-case-1
15+
16+
clean:
17+
rm ./$(BIN)

examples/generic/Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=generic_bin
55

6+
.PHONY : all clean test memcheck
67
all:
7-
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
8+
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
9+
1010
test:
11-
./$(BIN)
11+
./$(BIN)
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/list_pod/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lyaml -lwebsockets -lkubernetes -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=list_pod_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
1010
test:
1111
./$(BIN)
12+
13+
memcheck:
14+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/list_secret/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ LIBS:=-L../../kubernetes/build -lkubernetes -lyaml -lwebsockets -L/usr/local/lib
33
CFLAGS:=-g
44
BIN:=list_secret_bin
55

6+
.PHONY : all clean test memcheck
67
all:
78
gcc main.c $(CFLAGS) $(INCLUDE) $(LIBS) -o $(BIN)
8-
clean:
9-
rm ./$(BIN)
9+
10+
memcheck:
11+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
12+
1013
test:
1114
./$(BIN)
15+
16+
clean:
17+
rm ./$(BIN)

examples/multi_thread/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ CFLAGS:=-g
55
BIN:= multi_thread_bin
66
OBJECTS:=main.o watch_pod.o create_pod.o
77

8+
.PHONY : all clean test memcheck
89
all: $(OBJECTS)
910
$(CC) -o $(BIN) $(OBJECTS) $(LIBS)
1011

1112
$(OBJECTS): %.o: %.c
1213
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
1314

14-
.PHONY : clean test
15-
clean:
16-
rm $(BIN) $(OBJECTS)
1715
test:
18-
./$(BIN)
16+
./$(BIN)
17+
18+
memcheck:
19+
valgrind --tool=memcheck --leak-check=full ./$(BIN)
20+
21+
clean:
22+
rm $(BIN) $(OBJECTS)

0 commit comments

Comments
 (0)