Skip to content

Commit be20784

Browse files
committed
Add valgrind
1 parent ecb5342 commit be20784

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/workflows/kvssink.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
gstreamer1.0-tools \
4141
libcurl4-openssl-dev libgstreamer1.0-dev \
4242
libgstreamer-plugins-base1.0-dev liblog4cplus-dev \
43-
libssl-dev pkg-config
43+
libssl-dev pkg-config valgrind
4444
4545
- name: Setup build directory
4646
run: |
@@ -66,3 +66,18 @@ jobs:
6666
run: |
6767
export GST_PLUGIN_PATH=`pwd`
6868
GST_DEBUG=4 ./tst/gstkvsplugintest
69+
70+
- name: Run the unit tests with valgrind
71+
working-directory: ./build
72+
run: |
73+
export GST_PLUGIN_PATH=`pwd`
74+
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes \
75+
--verbose --log-file=valgrind-out.txt ./tst/gstkvsplugintest
76+
77+
if grep -q "All heap blocks were freed -- no leaks are possible" valgrind-out.txt; then
78+
echo "No memory leaks detected"
79+
else
80+
echo "Memory leaks detected. Review the valgrind output:"
81+
cat valgrind-out.txt
82+
exit 1
83+
fi

tst/gstreamer/gstkvstest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,14 @@ GST_START_TEST(check_properties_are_passed_correctly)
212212

213213
g_object_get(G_OBJECT (pElement), "stream-name", &str_val, NULL);
214214
assert_equals_string(TEST_STREAM_NAME.c_str(), str_val);
215+
g_free(str_val);
215216
g_object_get(G_OBJECT (pElement), "retention-period", &uint_val, NULL);
216217
assert_equals_uint64(TEST_RETENTION_PERIOD, uint_val);
217218
g_object_get(G_OBJECT (pElement), "streaming-type", &uint_val, NULL);
218219
assert_equals_uint64(TEST_STREAMING_TYPE, uint_val);
219220
g_object_get(G_OBJECT (pElement), "content-type", &str_val, NULL);
220221
assert_equals_string(TEST_CONTENT_TYPE.c_str(), str_val);
222+
g_free(str_val);
221223
g_object_get(G_OBJECT (pElement), "max-latency", &uint_val, NULL);
222224
assert_equals_uint64(TEST_MAX_LATENCY, uint_val);
223225
g_object_get(G_OBJECT (pElement), "fragment-duration", &uint_val, NULL);
@@ -248,16 +250,21 @@ GST_START_TEST(check_properties_are_passed_correctly)
248250
assert_equals_uint64(TEST_CONNECTION_STALENESS, uint_val);
249251
g_object_get(G_OBJECT (pElement), "codec-id", &str_val, NULL);
250252
assert_equals_string(TEST_CODEC_ID.c_str(), str_val);
253+
g_free(str_val);
251254
g_object_get(G_OBJECT (pElement), "track-name", &str_val, NULL);
252255
assert_equals_string(TEST_TRACK_NAME.c_str(), str_val);
256+
g_free(str_val);
253257
g_object_get(G_OBJECT (pElement), "access-key", &str_val, NULL);
254258
assert_equals_string(TEST_ACCESS_KEY.c_str(), str_val);
259+
g_free(str_val);
255260
g_object_get(G_OBJECT (pElement), "secret-key", &str_val, NULL);
256261
assert_equals_string(TEST_SECRET_KEY.c_str(), str_val);
262+
g_free(str_val);
257263
g_object_get(G_OBJECT (pElement), "rotation-period", &uint_val, NULL);
258264
assert_equals_uint64(TEST_ROTATION_PERIOD, uint_val);
259265
g_object_get(G_OBJECT (pElement), "log-config", &str_val, NULL);
260266
assert_equals_string(TEST_LOG_CONFIG.c_str(), str_val);
267+
g_free(str_val);
261268

262269
cleanup_kinesisvideoproducersink(pElement);
263270

0 commit comments

Comments
 (0)