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

Commit

Permalink
stable (#153)
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

* leb128: remove debug

* http: fix http content length format (#136)

* Support run specific integration test and add http with local dnssrv (#135)

* support run specific integration test

* http: add integration test for http using local dns server

* odict: check return value of compare()

* odict: use correct union field (boolean) (#137)

Fixes a bug on Alpine/S390x which is 64-bit Big Endian architecture

* test: use fs_stdio_restore() (#138)

* oom: align testcase names

* align testcase names

* tmr: increase upper bound

* remove leb128 printf

* sys: add todo

* net: add ipv6_supported()

* sys: unique filename in test_sys_fs_fopen (#142)

* net: remove logging

* Enable valgrind for Linux build (#140)

* integration: make IPv6 tests optional

* bfcp: check for handler errors after re_main

* fmt: add test_fmt_str_itoa (#143)

* git: ignore cmake generated files

* workflows: add run-on-arch action (#134)

* test_multithread: increase timeout to 15 seconds

* tls: remove some warnings (#144)

* ci/run-on-arch: add prepare (needed for dependency) (#145)

* ci: use actions/checkout@v3 (#148)

* list: add test_list_flush (#151)

* list: fix flushl global (#152)

Co-authored-by: Sebastian Reimers <[email protected]>
Co-authored-by: Dmitry Ilyin <[email protected]>
Co-authored-by: Franz Auernigg <[email protected]>
Co-authored-by: Andrey Semashev <[email protected]>
Co-authored-by: Franz <[email protected]>
  • Loading branch information
6 people authored Nov 1, 2022
1 parent 514de41 commit e4f419a
Show file tree
Hide file tree
Showing 20 changed files with 371 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# os: [ubuntu-latest, macos-latest] # @todo: macOS need fixes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: sreimers/[email protected]
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ jobs:
CC: ${{ matrix.compiler }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: install packages linux
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update -q -y && sudo apt-get install -q -y libssl-dev valgrind
- name: openssl path macos
if: ${{ runner.os == 'macOS' }}
Expand Down Expand Up @@ -70,7 +75,7 @@ jobs:
if: ${{ runner.os == 'Linux' }}
run: |
cmake -DCMAKE_C_FLAGS="-Werror" . && make
./retest -r
valgrind --leak-check=full --show-reachable=yes --error-exitcode=42 ./retest -v -r
- name: retest
if: ${{ runner.os == 'macOS' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: ccheck
run: |
wget "https://raw.githubusercontent.com/baresip/baresip/main/test/ccheck.py"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: sreimers/[email protected]
with:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
CC: ${{ matrix.compiler }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: install devel tools
run: |
yum -y install git gcc clang cmake openssl-devel pkgconfig zlib-devel net-tools
Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/run-on-arch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
on: [push, pull_request]

jobs:
prepare:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: sreimers/[email protected]
with:
name: re
repo: https://github.com/baresip/re
secret: ${{ secrets.GITHUB_TOKEN }}

- uses: sreimers/[email protected]
with:
name: rem
repo: https://github.com/baresip/rem
secret: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v3
with:
name: prepare
path: |
re
rem
build_job:
# The host should always be linux
runs-on: ubuntu-18.04
name: Build on ${{ matrix.distro }} ${{ matrix.arch }}
needs: prepare

# Run steps on a matrix of 3 arch/distro combinations
strategy:
matrix:
include:
- arch: armv7
distro: alpine_latest
- arch: aarch64
distro: bullseye
- arch: s390x
distro: fedora_latest

steps:
- uses: actions/checkout@v3

- name: Download re/rem
uses: actions/download-artifact@v3
with:
name: prepare

- uses: uraimo/run-on-arch-action@v2
name: Build artifact
id: build
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}

# Not required, but speeds up builds
githubToken: ${{ github.token }}

# Create an artifacts directory
setup: |
mkdir -p "${PWD}/artifacts"
# The shell to run commands with in the container
shell: /bin/sh

# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
case "${{ matrix.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y cmake gcc git make libssl-dev
;;
fedora*)
dnf -y update
dnf -y install cmake gcc git make openssl-devel
;;
alpine*)
apk update
apk add cmake gcc git linux-headers make musl-dev openssl-dev
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
for p in re rem; do
cmake -S $p -B $p/build -DCMAKE_C_FLAGS="-Werror"
cmake --build $p/build -j
done
for p in re rem; do
mv $p ../.
done
cmake -B build -DCMAKE_C_FLAGS="-Werror"
cmake --build build -j
./build/retest -v -r
- name: Show the artifact
# Items placed in /artifacts in the container will be in
# ${PWD}/artifacts on the host.
run: |
ls -al "${PWD}/artifacts"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ tags

# Vim swp files
*.swp

# cmake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
5 changes: 0 additions & 5 deletions src/av1.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,11 @@ static int test_leb128(void)
if (err)
goto out;

re_printf("leb128 value: [ %w ]\n", mb->buf, mb->end);

mb->pos = 0;

err = av1_leb128_decode(mb, &val_dec);
ASSERT_EQ(0, err);

printf("decoded: %" PRIu64 " / %" PRIx64 "\n",
val_dec, val_dec);

ASSERT_EQ(val, val_dec);

mb = mem_deref(mb);
Expand Down
12 changes: 12 additions & 0 deletions src/bfcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,18 @@ int test_bfcp_tcp(void)
err = re_main_timeout(100);
TEST_ERR(err);

if (cli->handler_err) {
DEBUG_WARNING("client error: %m\n", cli->handler_err);
err = cli->handler_err;
goto out;
}

if (srv->handler_err) {
DEBUG_WARNING("server error: %m\n", srv->handler_err);
err = srv->handler_err;
goto out;
}

TEST_EQUALS((estab_handler_called | resp_handler_called), cli->flags);
TEST_EQUALS((conn_handler_called | estab_handler_called |
recv_handler_called), srv->flags);
Expand Down
32 changes: 32 additions & 0 deletions src/fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,3 +1056,35 @@ int test_fmt_str_bool(void)

return err;
}


int test_fmt_str_itoa(void)
{
char buf[ITOA_BUFSZ];
char *s;
int err = 0;

s = str_itoa(0, buf, 10);
TEST_ASSERT(!str_casecmp(s, "0"));

s = str_itoa(42, buf, 10);
TEST_ASSERT(!str_casecmp(s, "42"));

s = str_itoa(UINT32_MAX, buf, 10);
TEST_ASSERT(!str_casecmp(s, "4294967295"));

s = str_itoa(UINT32_MAX, buf, 16);
TEST_ASSERT(!str_casecmp(s, "FFFFFFFF"));

s = str_itoa(23, buf, 2);
TEST_ASSERT(!str_casecmp(s, "10111"));

s = str_itoa(UINT32_MAX, buf, 2);
TEST_ASSERT(!str_casecmp(s, "11111111111111111111111111111111"));

out:
if (err)
DEBUG_WARNING("err itoa string: %s\n", s);

return err;
}
48 changes: 35 additions & 13 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ enum large_body_test {
REQ_HTTP_REQUESTS = 2
};

enum {
IP_127_0_0_1 = 0x7f000001,
};

static int test_http_response_no_reasonphrase(void)
{
Expand Down Expand Up @@ -392,13 +395,15 @@ static size_t http_req_long_body_handler(struct mbuf *mb, void *arg)
}


static int test_http_loop_base(bool secure, const char *met, bool http_conn)
static int test_http_loop_base(bool secure, const char *met, bool http_conn,
bool dns_srv_query)
{
struct http_sock *sock = NULL;
struct http_cli *cli = NULL;
struct http_req *req = NULL;
struct http_reqconn *conn = NULL;
struct dnsc *dnsc = NULL;
struct dns_server *dns_srv = NULL;
struct sa srv, dns;
struct test t;
char url[256];
Expand All @@ -416,10 +421,18 @@ static int test_http_loop_base(bool secure, const char *met, bool http_conn)

t.secure = secure;

if (dns_srv_query) {
/* Setup Mocking DNS Server */
err = dns_server_alloc(&dns_srv, false);
TEST_ERR(err);

err = dns_server_add_a(dns_srv, "test1.example.net",
IP_127_0_0_1, 1);
TEST_ERR(err);
}

err |= sa_set_str(&srv, "127.0.0.1", 0);
err |= sa_set_str(&dns, "127.0.0.1", 53); /* note: unused */
if (err)
goto out;

if (secure) {

Expand All @@ -440,7 +453,7 @@ static int test_http_loop_base(bool secure, const char *met, bool http_conn)
if (err)
goto out;

err = dnsc_alloc(&dnsc, NULL, &dns, 1);
err = dnsc_alloc(&dnsc, NULL, dns_srv ? &dns_srv->addr : &dns, 1);
if (err)
goto out;

Expand All @@ -460,8 +473,10 @@ static int test_http_loop_base(bool secure, const char *met, bool http_conn)
#endif

(void)re_snprintf(url, sizeof(url),
"http%s://127.0.0.1:%u/index.html",
secure ? "s" : "", sa_port(&srv));
"http%s://%s:%u/index.html",
secure ? "s" : "",
dns_srv_query ? "test1.example.net" : "127.0.0.1",
sa_port(&srv));

for (i = 1; i <= REQ_HTTP_REQUESTS; i++) {
t.i_req_body = 0;
Expand Down Expand Up @@ -514,7 +529,7 @@ static int test_http_loop_base(bool secure, const char *met, bool http_conn)
put ? http_req_long_body_handler :
http_req_body_handler,
&t,
"Content-Length: %llu\r\n%s\r\n%s",
"Content-Length: %zu\r\n%s\r\n%s",
t.clen,
t.clen > REQ_BODY_CHUNK_SIZE ?
"Expect: 100-continue\r\n" : "",
Expand Down Expand Up @@ -553,6 +568,7 @@ static int test_http_loop_base(bool secure, const char *met, bool http_conn)
mem_deref(cli);
mem_deref(dnsc);
mem_deref(sock);
mem_deref(dns_srv);

return err;
}
Expand Down Expand Up @@ -625,39 +641,45 @@ int test_http_client_set_tls(void)

int test_http_loop(void)
{
return test_http_loop_base(false, "GET", false);
return test_http_loop_base(false, "GET", false, false);
}


#ifdef USE_TLS
int test_https_loop(void)
{
return test_http_loop_base(true, "GET", false);
return test_http_loop_base(true, "GET", false, false);
}
#endif


int test_http_large_body(void)
{
return test_http_loop_base(false, "PUT", false);
return test_http_loop_base(false, "PUT", false, false);
}


#ifdef USE_TLS
int test_https_large_body(void)
{
return test_http_loop_base(true, "PUT", false);
return test_http_loop_base(true, "PUT", false, false);
}
#endif


int test_http_conn(void)
{
return test_http_loop_base(false, "GET", true);
return test_http_loop_base(false, "GET", true, false);
}


int test_http_conn_large_body(void)
{
return test_http_loop_base(false, "PUT", true);
return test_http_loop_base(false, "PUT", true, false);
}


int test_dns_http_integration(void)
{
return test_http_loop_base(false, "GET", true, true);
}
Loading

0 comments on commit e4f419a

Please sign in to comment.