From 42116d7eebcf604bcde17f5c9c7a88874f41bff0 Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Mon, 30 Jan 2023 14:14:17 +0200 Subject: [PATCH] ci: Fix never-ending example srtp_zrtp and add it to CI-testing --- .gitlab-ci.yml | 1 + examples/srtp_zrtp.cc | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fcf51222..fcd797aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,6 +58,7 @@ examples_with_crypto: - ./sending_generic - ./srtp_user - ./zrtp_multistream + - ./srtp_zrtp artifacts: paths: diff --git a/examples/srtp_zrtp.cc b/examples/srtp_zrtp.cc index 0acbf2fd..3a09eec5 100644 --- a/examples/srtp_zrtp.cc +++ b/examples/srtp_zrtp.cc @@ -4,6 +4,9 @@ #include #include +constexpr int AMOUNT_OF_TEST_PACKETS = 30; +constexpr auto END_WAIT = std::chrono::seconds(5); + void thread_func(void) { /* See sending.cc for more details */ @@ -48,11 +51,23 @@ int main(void) char *message = (char *)"Hello, world!"; size_t msg_len = strlen(message); - for (;;) { + for (int i = 0; i < AMOUNT_OF_TEST_PACKETS; ++i) { uint8_t* message_data = new uint8_t[msg_len]; memcpy(message_data, message, msg_len); send->push_frame((uint8_t *)message_data, msg_len, RTP_NO_FLAGS); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } + + std::cout << "All packets sent, waiting " << END_WAIT.count() + << " seconds before exiting." << std::endl; + // destroy the session after waiting for END_WAIT seconds + std::this_thread::sleep_for(END_WAIT); + sess->destroy_stream(send); + if (sess) { + ctx.destroy_session(sess); + } + + return EXIT_SUCCESS; + }