Skip to content

Commit 109a738

Browse files
committed
Make CI workflow.
1 parent cfd8224 commit 109a738

7 files changed

Lines changed: 126 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
posix:
10+
name: ${{ matrix.name }}
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: Ubuntu 22.04 GCC
18+
os: ubuntu-22.04
19+
cc: gcc
20+
cxx: g++
21+
packages: build-essential
22+
cc_flags: -march=native
23+
24+
- name: Ubuntu 22.04 Clang
25+
os: ubuntu-22.04
26+
cc: clang
27+
cxx: clang++
28+
packages: clang
29+
cc_flags: -march=native
30+
31+
- name: Ubuntu 24.04 GCC
32+
os: ubuntu-24.04
33+
cc: gcc
34+
cxx: g++
35+
packages: build-essential
36+
cc_flags: -march=native
37+
38+
- name: Ubuntu 24.04 Clang
39+
os: ubuntu-24.04
40+
cc: clang
41+
cxx: clang++
42+
packages: clang
43+
cc_flags: -march=native
44+
45+
env:
46+
CC: ${{ matrix.cc }}
47+
CXX: ${{ matrix.cxx }}
48+
CC_FLAGS: ${{ matrix.cc_flags }}
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Install dependencies
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y cmake expect netcat-openbsd ${{ matrix.packages }}
58+
59+
- name: Show tool versions
60+
run: |
61+
cmake --version
62+
"${CC}" --version
63+
64+
- name: Configure
65+
run: |
66+
cmake \
67+
-DCMAKE_C_FLAGS="-Werror ${CC_FLAGS}" \
68+
-S platforms/posix \
69+
-B platforms/posix/build
70+
71+
- name: Build
72+
run: cmake --build platforms/posix/build
73+
74+
- name: Test
75+
working-directory: platforms/posix/build
76+
run: ctest -V

platforms/posix/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ ENDIF (IS_BIG_ENDIAN)
9393

9494
enable_testing()
9595

96-
add_test(basic ${CMAKE_SOURCE_DIR}/../../scripts/do-test.sh ${CMAKE_SOURCE_DIR})
96+
add_test(NAME basic COMMAND
97+
${CMAKE_COMMAND} -E env BUILDDIR=${CMAKE_CURRENT_BINARY_DIR}
98+
${CMAKE_SOURCE_DIR}/../../scripts/do-test.sh ${CMAKE_SOURCE_DIR}
99+
)
97100
add_test(NAME usipy_test_uac COMMAND usipy_test_uac)
98101
add_test(NAME usipy_test_ua COMMAND usipy_test_ua)
99102

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
${BUILDDIR}/usipy_test 2>&1 | tee "${MLOG}" &
1+
MON_PIDFILE="${BUILDDIR}/usipy_test.pid"
2+
rm -f "${MON_PIDFILE}"
3+
(
4+
"${BUILDDIR}/usipy_test" 2>&1 &
5+
echo ${!} > "${MON_PIDFILE}"
6+
wait ${!}
7+
) | tee "${MLOG}" &
8+
MON_PIPE_PID=${!}

platforms/posix/usipy_test_ua.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ bind_loopback_udp(void)
4343
sin.sin_family = AF_INET;
4444
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4545
sin.sin_port = 0;
46-
assert(bind(sock, (struct sockaddr *)&sin, sizeof(sin)) == 0);
46+
if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) != 0) {
47+
perror("bind_loopback_udp bind");
48+
assert(0);
49+
}
4750
return (sock);
4851
}
4952

platforms/posix/usipy_test_uac.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ bind_loopback_udp(void)
318318
sin.sin_family = AF_INET;
319319
sin.sin_port = htons(0);
320320
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
321-
assert(bind(sock, (const struct sockaddr *)&sin, sizeof(sin)) == 0);
321+
if (bind(sock, (const struct sockaddr *)&sin, sizeof(sin)) != 0) {
322+
perror("bind_loopback_udp bind");
323+
assert(0);
324+
}
322325
return (sock);
323326
}
324327

scripts/do-test.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ TOOLSDIR=`dirname ${TOOLSPATH}`
1010

1111
MLOG="${BUILDDIR}/monitor.log"
1212
TESTS="empty foobar 100trying ACK OPTIONS INVITE CANCEL 200OK"
13+
MON_PID=
14+
MON_PIPE_PID=
15+
16+
cleanup()
17+
{
18+
if [ ! -z "${MON_PID}" ]
19+
then
20+
kill -TERM "${MON_PID}" 2>/dev/null || true
21+
wait "${MON_PID}" 2>/dev/null || true
22+
fi
23+
if [ ! -z "${MON_PIPE_PID}" ]
24+
then
25+
wait "${MON_PIPE_PID}" 2>/dev/null || true
26+
fi
27+
}
28+
trap cleanup EXIT INT TERM
1329

1430
if [ -e "${MLOG}" ]
1531
then
@@ -18,7 +34,17 @@ fi
1834

1935
. "${SRCDIR}/scripts/test_start.sub"
2036
MON_RC=${?}
21-
MON_PID=${!}
37+
i=0
38+
while [ ${i} -lt 10 ] && [ ! -s "${MON_PIDFILE}" ]
39+
do
40+
sleep 1
41+
i=$((${i} + 1))
42+
done
43+
if [ ! -s "${MON_PIDFILE}" ]
44+
then
45+
exit 1
46+
fi
47+
MON_PID=`cat "${MON_PIDFILE}"`
2248

2349
. "${SRCDIR}/scripts/test_waitready.sub"
2450

@@ -36,8 +62,8 @@ then
3662
done
3763
sleep 3
3864
fi
39-
kill -TERM ${MON_PID}
40-
wait ${MON_PID} || true
65+
cleanup
66+
MON_PID=
4167
if [ -z "${BRD_IP}" ]
4268
then
4369
exit 1

scripts/test.common.sub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ then
1717
. "${SRCDIR}/scripts/test.common.sub"
1818
fi
1919

20-
BUILDDIR="${SRCDIR}/build"
20+
BUILDDIR="${BUILDDIR:-${SRCDIR}/build}"
2121
DIFF="diff -u"

0 commit comments

Comments
 (0)