Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.

Commit

Permalink
release v2.8.0 (#133)
Browse files Browse the repository at this point in the history
* async: add new tests (#107)

* cmake: add path to windows build

* mock: fix warning

* dns/client: add async getaddrinfo usage (#112)

* dns: refactor IP checks and add system test

* use dnsc_getaddrinfo

* fmt: workaround for windows compiler

* sys: fix unlink and WIN32

* test: cast values to fix WIN32 warnings

* trace: fix unlink and WIN32

* main: only run regular tests if GETOPT is missing

* test: various fixes for WIN32

* async: fix multithreading tests (#115)

* main: if GETOPT is missing run regular tests

* cmake: add LINKLIBS variable

* test cmake on Windows (#114)

* test cmake on Windows

* You have an error in your yaml syntax on line 14

* fix yaml syntax error

* try to find re

* try to find rem

* mock: fix win32 warning

* fix unlink warnings

* fix warnings

* fix write

* fix size_t

* write needs unsigned int

* link to win32 libs

* add qwave

* execute retest.exe in build/debug

* set verbose

* set verbose

* disable all

* update flags

* ci: fix compiler list and choco

* LINKLIBS and flags

* test: fix c11 err handling

* cmake: use re config (#118)

* base64: Encoding/Decoding with URL and Filename Safe Alphabet (#113)

* cmake: bump minimum to 3.10 (#119)

* Don't fail on compilation when there no OpenSSL on target platform (#120)

* trice: fix win32 with explicit error tests (#121)

* http: test http/https requests with large body

* http: validate body of http requests for get method

* http: add test for http conn requests

* dns: test dnsc_getaddrinfo_enabled

* rtp: Update tests for the changed rtp_send signature.

This updates RTP tests for compatibility with this PR:

baresip/re#418

* crc32: add re wrapper

* sipreg: use TEST_ERR and remove static port test

Tests should run without interfere with each other. Looks like on Github
Actions runners share the same port range sometimes? So for tests we have to use
dynamic ports.

* cmake: no need to link to libz

* sa: init err

* cmake: add optional zlib linking

* cmake/FindREM: add rem-static target name

* sys: remove old sys div test (#130)

* aubuf: refactor aubuf_auframe test (#70)

* rtcp: use udp_send() (#132)

* rtcp: use udp_send()

* rtcp: add workaround for OOM test

Co-authored-by: Sebastian Reimers <[email protected]>
Co-authored-by: Alfred E. Heggestad <[email protected]>
Co-authored-by: Dmitry Ilyin <[email protected]>
Co-authored-by: Franz Auernigg <[email protected]>
Co-authored-by: Andrey Semashev <[email protected]>
  • Loading branch information
6 people authored Oct 1, 2022
1 parent fcf6251 commit 514de41
Show file tree
Hide file tree
Showing 22 changed files with 717 additions and 298 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
strategy:
matrix:
compiler: [gcc, clang]
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
compiler: gcc
- os: windows-latest
compiler: clang
env:
CC: ${{ matrix.compiler }}

Expand All @@ -32,6 +34,11 @@ jobs:
run: |
echo "OPENSSL_ROOT_DIR=/usr/local/opt/openssl" >> $GITHUB_ENV
- name: install packages
if: ${{ runner.os == 'Windows' }}
run: |
choco install --no-progress openssl
- uses: sreimers/[email protected]
with:
name: re
Expand All @@ -45,6 +52,7 @@ jobs:
secret: ${{ secrets.GITHUB_TOKEN }}

- name: make re/rem
shell: bash
run: |
for p in re rem; do
cmake -S $p -B $p/build
Expand All @@ -69,3 +77,10 @@ jobs:
run: |
OPENSSL_ROOT_DIR=/usr/local/opt/openssl cmake -DCMAKE_C_FLAGS="-Werror" . && make
./retest -r
- name: retest
if: ${{ runner.os == 'Windows' }}
run: |
cmake -B build -DCMAKE_C_FLAGS="/WX"
cmake --build build
build\Debug\retest.exe -v -r
106 changes: 20 additions & 86 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Versioning
#

cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.10)

project(retest C)

Expand All @@ -21,21 +21,14 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
# Module/Package Includes
#

include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckSymbolExists)
find_package(RE REQUIRED)
find_package(REM REQUIRED)
find_package(Threads REQUIRED)
find_package(OpenSSL)


##############################################################################
#
# Compile options/definitions
#

option(USE_OPENSSL "Enable OpenSSL" ${OPENSSL_FOUND})
option(USE_SANITIZER "Sanitizers like: address, thread, undefined, memory")
include(sanitizer)

Expand Down Expand Up @@ -66,86 +59,13 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wshorten-64-to-32)
endif()

check_include_file(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()

check_function_exists(thrd_create HAVE_THREADS)
if(HAVE_THREADS)
add_definitions(-DHAVE_THREADS)
endif()

if(CMAKE_USE_PTHREADS_INIT)
add_definitions(-DHAVE_PTHREAD)
set(HAVE_PTHREAD ON)
endif()

check_symbol_exists("arc4random" "stdlib.h" HAVE_ARC4RANDOM)
if(HAVE_ARC4RANDOM)
add_definitions(-DHAVE_ARC4RANDOM)
endif()


include_directories(
src
../re/include
../rem/include
${RE_INCLUDE_DIRS}
${REM_INCLUDE_DIRS}
)

add_definitions(
-DHAVE_ATOMIC
-DHAVE_INET6
-DHAVE_SELECT
)

if(UNIX)
add_definitions(
-DHAVE_GETOPT
-DHAVE_POLL
-DHAVE_PWD_H
-DHAVE_ROUTE_LIST
-DHAVE_SETRLIMIT
-DHAVE_STRERROR_R
-DHAVE_STRINGS_H
-DHAVE_SYS_TIME_H
-DHAVE_UNAME
-DHAVE_SELECT_H
-DHAVE_SIGNAL
)
if(NOT ANDROID)
add_definitions(-DHAVE_GETIFADDRS)
endif()
endif()


if(MSVC)
add_definitions(
-DHAVE_IO_H
-D_CRT_SECURE_NO_WARNINGS
)
endif()

if(WIN32)
add_definitions(
-DWIN32 -D_WIN32_WINNT=0x0600
)
endif()

if(USE_OPENSSL)
add_definitions(
-DUSE_DTLS
-DUSE_OPENSSL
-DUSE_OPENSSL_AES
-DUSE_OPENSSL_DTLS
-DUSE_OPENSSL_HMAC
-DUSE_OPENSSL_SRTP
-DUSE_TLS
)
endif()

find_package(re CONFIG REQUIRED HINTS ../re/cmake)

##############################################################################
#
Expand All @@ -158,6 +78,7 @@ set(SRCS
src/aubuf.c
src/aulevel.c
src/auresamp.c
src/async.c
src/av1.c
src/base64.c
src/bfcp.c
Expand Down Expand Up @@ -241,10 +162,23 @@ endif()
# Main target object
#

set(LINKLIBS ${REM_LIBRARIES} ${RE_LIBRARIES} ${OPENSSL_LIBRARIES})
if(WIN32)
list(APPEND LINKLIBS qwave iphlpapi wsock32 ws2_32)
else()
list(APPEND LINKLIBS -lpthread -lm)
endif()

if(ZLIB_FOUND)
list(APPEND LINKLIBS ZLIB::ZLIB)
endif()

add_executable(${PROJECT_NAME} ${SRCS})
set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS 1)

target_link_libraries(${PROJECT_NAME}
PRIVATE ${REM_LIBRARIES} ${RE_LIBRARIES} ${OPENSSL_LIBRARIES}
-lz -lpthread -lm)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LINKLIBS})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${RE_DEFINITIONS})

if(USE_OPENSSL)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
endif()
3 changes: 2 additions & 1 deletion cmake/FindRE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ find_path(RE_INCLUDE_DIR re.h
HINTS ../re/include ${PC_LIBRE_INCLUDEDIR} ${PC_LIBRE_INCLUDE_DIRS})

find_library(RE_LIBRARY NAMES re libre re-static
HINTS ../re ../re/build ${PC_LIBRE_LIBDIR} ${PC_LIBRE_LIBRARY_DIRS})
HINTS ../re ../re/build ../re/build/Debug
${PC_LIBRE_LIBDIR} ${PC_LIBRE_LIBRARY_DIRS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RE DEFAULT_MSG RE_LIBRARY RE_INCLUDE_DIR)
Expand Down
5 changes: 3 additions & 2 deletions cmake/FindREM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ pkg_check_modules(PC_LIBREM QUIET librem)
find_path(REM_INCLUDE_DIR rem.h
HINTS ../rem/include ${PC_LIBREM_INCLUDEDIR} ${PC_LIBREM_INCLUDE_DIRS})

find_library(REM_LIBRARY NAMES rem librem
HINTS ../rem ../rem/build ${PC_LIBREM_LIBDIR} ${PC_LIBREM_LIBRARY_DIRS})
find_library(REM_LIBRARY NAMES rem librem rem-static
HINTS ../rem ../rem/build ../rem/build/Debug
${PC_LIBREM_LIBDIR} ${PC_LIBREM_LIBRARY_DIRS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(REM DEFAULT_MSG REM_LIBRARY REM_INCLUDE_DIR)
Expand Down
113 changes: 113 additions & 0 deletions src/async.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* @file async.c Testcode for re async
*
* Copyright (C) 2022 Sebastian Reimers
*/
#define _BSD_SOURCE 1
#define _DEFAULT_SOURCE 1

#ifndef WIN32
#include <netdb.h>
#endif

#include <string.h>
#include <re.h>
#include "test.h"

#define DEBUG_MODULE "async"
#define DEBUG_LEVEL 5
#include <re_dbg.h>

struct test_cnt {
int tests;
int done;
};

struct test {
char domain[128];
struct sa sa;
int err;
int err_expected;
struct test_cnt *cnt;
};

static int blocking_getaddr(void *arg)
{
int err;
struct test *test = arg;
struct addrinfo *res = NULL;
struct addrinfo hints;

memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;


/* Blocking */
err = getaddrinfo(test->domain, NULL, &hints, &res);
if (err)
return EADDRNOTAVAIL;

sa_set_sa(&test->sa, res->ai_addr);
freeaddrinfo(res);

return 0;
}


static void completed(int err, void *arg)
{
struct test *test = arg;
struct sa sa;

if (err)
goto out;

err = re_thread_check();
TEST_ERR(err);

sa_set_str(&sa, "127.0.0.1", 0);
if (!sa_cmp(&sa, &test->sa, SA_ADDR))
err = EINVAL;

TEST_ERR(err);

out:
test->err = err;
if (++test->cnt->done >= test->cnt->tests)
re_cancel();
}


int test_async(void)
{
int err;

struct test_cnt cnt = {0, 0};

struct test testv[] = {
{"localhost", {.len = 0}, -1, 0, &cnt},
{"test.notfound", {.len = 0}, -1, EADDRNOTAVAIL, &cnt}
};

cnt.tests = ARRAY_SIZE(testv);

err = re_thread_async_init(2);
TEST_ERR(err);

for (size_t i = 0; i < ARRAY_SIZE(testv); i++) {
err = re_thread_async(blocking_getaddr, completed, &testv[i]);
TEST_ERR(err);
}

err = re_main_timeout(200);
TEST_ERR(err);

for (size_t i = 0; i < ARRAY_SIZE(testv); i++) {
TEST_EQUALS(testv[i].err_expected, testv[i].err);
}

out:
re_thread_async_close();
return err;
}
Loading

0 comments on commit 514de41

Please sign in to comment.