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

merge retest into re #695

Merged
merged 17 commits into from
Feb 18, 2023
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
10 changes: 1 addition & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ jobs:
run: |
cmake -B build && cmake --build build

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest.git
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- name: retest
run: |
cd ..
cd retest && make && ./retest -r
./build/test/retest -r -v
17 changes: 4 additions & 13 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,13 @@ jobs:

- name: make
run: |
cmake -B build -DCMAKE_C_FLAGS="--coverage" && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest.git
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'
cmake -B build -DCMAKE_C_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage"
cmake --build build -j

- name: retest
run: |
cd ..
cd retest; cmake -B build -DCMAKE_EXE_LINKER_FLAGS="--coverage" && \
cmake --build build -j && \
./build/retest -a -v && \
./build/retest -r -m select -v
./build/test/retest -a -v
./build/test/retest -r -m select -v

- name: gcov
run: |
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,12 @@ jobs:

- uses: actions/checkout@v3 # needed for pr checkout

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest
secret: ${{ secrets.GITHUB_TOKEN }}

- uses: sreimers/pr-dependency-action@v0.5
with:
name: baresip-win32
repo: https://github.com/baresip/baresip-win32
secret: ${{ secrets.GITHUB_TOKEN }}

- name: "baresip-win32 repo"
run: |
mv retest baresip-win32/

- uses: actions/checkout@v3
with:
path: baresip-win32/re
Expand All @@ -63,7 +53,7 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: retest-exe
path: baresip-win32/retest/build/retest.exe
path: baresip-win32/re/build/test/retest.exe
retention-days: 1

wintest:
Expand All @@ -75,10 +65,10 @@ jobs:
- uses: actions/download-artifact@v2
- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest
name: re
repo: https://github.com/baresip/re
secret: ${{ secrets.GITHUB_TOKEN }}

- name: "run retest.exe"
run: mv retest-exe/retest.exe retest/ && cd retest && ./retest.exe -v
run: mv retest-exe/retest.exe re/ && cd re && ./retest.exe -v
shell: bash
10 changes: 1 addition & 9 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ jobs:
run: |
cmake -B build -DHAVE_THREADS= && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest.git
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- name: retest
run: |
cd ..
cd retest && make && ./retest -riv
./build/test/retest -riv
12 changes: 1 addition & 11 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ jobs:
run: |
cmake -B build && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- name: retest
run: |
cd ..
cd retest
cmake -B build && cmake --build build -j
valgrind --leak-check=full --show-reachable=yes --error-exitcode=42 ./build/retest -r -v
valgrind --leak-check=full --show-reachable=yes --error-exitcode=42 ./build/test/retest -r -v
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/build*
test
test.c
test.d
test.o
*stamp
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -725,3 +725,10 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libre.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT Development
)


##############################################################################
# Test
#

add_subdirectory(test)
13 changes: 13 additions & 0 deletions cmake/sanitizer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if(USE_SANITIZER STREQUAL "address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
elseif(USE_SANITIZER STREQUAL "thread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
elseif(USE_SANITIZER STREQUAL "undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
elseif(USE_SANITIZER STREQUAL "memory")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
endif()
182 changes: 182 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
#
# CMakeLists.txt
#
# Copyright (C) 2010 - 2022 Alfred E. Heggestad
#

##############################################################################
#
# Versioning
#

project(retest C)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)


##############################################################################
#
# Module/Package Includes
#

#find_package(RE REQUIRED)

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

option(USE_SANITIZER "Sanitizers like: address, thread, undefined, memory")
include(sanitizer)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE Debug)

if(MSVC)
add_compile_options("/W3")
else()
add_compile_options(
-Wall
-Wbad-function-cast
-Wcast-align
-Wextra
-Wmissing-declarations
-Wmissing-prototypes
-Wnested-externs
-Wold-style-definition
-Wshadow -Waggregate-return
-Wstrict-prototypes
-Wvla
)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wshorten-64-to-32)
endif()

include_directories(
../include
.
)

find_package(re CONFIG REQUIRED HINTS ../cmake)

##############################################################################
#
# Source/Header section
#

set(SRCS
aac.c
aes.c
aubuf.c
aulevel.c
auresamp.c
async.c
av1.c
base64.c
bfcp.c
conf.c
convert.c
crc32.c
dns.c
dsp.c
dtmf.c
fir.c
fmt.c
g711.c
h264.c
h265.c
hash.c
hmac.c
http.c
httpauth.c
ice.c
jbuf.c
json.c
list.c
main.c
mbuf.c
md5.c
mem.c
mock/dnssrv.c
mock/fuzz.c
mock/nat.c
mock/pf.c
mock/sipsrv.c
mock/stunsrv.c
mock/tcpsrv.c
mock/turnsrv.c
mqueue.c
net.c
odict.c
pcp.c
remain.c
rtcp.c
rtmp.c
rtp.c
rtpext.c
sa.c
sdp.c
sha.c
sip.c
sipauth.c
sipevent.c
sipreg.c
sipsess.c
srtp.c
stun.c
sys.c
tcp.c
telev.c
test.c
thread.c
tmr.c
trace.c
trice.c
turn.c
udp.c
unixsock.c
uri.c
vid.c
vidconv.c
websock.c
)

if(USE_OPENSSL)
list(APPEND SRCS
tls.c
dtls.c
combo/dtls_turn.c
mock/cert.c
)
endif()


##############################################################################
#
# Main target object
#

set(LINKLIBS re ${OPENSSL_LIBRARIES})
if(WIN32)
list(APPEND LINKLIBS qwave iphlpapi wsock32 ws2_32)
else()
list(APPEND LINKLIBS -lpthread -lm ${RESOLV_LIBRARY})
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 ${LINKLIBS})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${RE_DEFINITIONS})

if(USE_OPENSSL)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
endif()
34 changes: 34 additions & 0 deletions test/aac.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @file aac.c AAC (Advanced Audio Coding) Testcode
*
* Copyright (C) 2010 Creytiv.com
*/

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


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


int test_aac(void)
{
static const uint8_t buf[2] = {0x12, 0x10};
struct aac_header hdr;
int err;

err = aac_header_decode(&hdr, buf, sizeof(buf));
if (err)
return err;

TEST_EQUALS(44100, hdr.sample_rate);
TEST_EQUALS(2, hdr.channels);
TEST_EQUALS(1024, hdr.frame_size);

out:
return err;
}
Loading