Skip to content

Commit

Permalink
test: Add slimcc compiler compatibility test.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 2, 2024
1 parent b473630 commit 4201066
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
analysis:
strategy:
matrix:
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, rpm, tcc, tokstyle]
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, rpm, slimcc, tcc, tokstyle]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand Down
1 change: 1 addition & 0 deletions other/docker/slimcc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!/Makefile
13 changes: 13 additions & 0 deletions other/docker/slimcc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SOURCES := auto_tests/send_message_test.c \
auto_tests/auto_test_support.c \
testing/misc_tools.c \
$(wildcard tox*/*.c tox*/*/*.c) \
third_party/cmp/cmp.c
OBJECTS := $(SOURCES:.c=.o)

CC := /work/slimcc/slimcc
CFLAGS := $(shell pkg-config --cflags libsodium opus vpx)
LDFLAGS := $(shell pkg-config --libs libsodium opus vpx)

send_message_test: $(OBJECTS)
$(CC) -o $@ $+ $(LDFLAGS)
6 changes: 6 additions & 0 deletions other/docker/slimcc/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -eux
BUILD=slimcc
other/docker/sources/build
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
28 changes: 28 additions & 0 deletions other/docker/slimcc/slimcc.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM toxchat/c-toxcore:sources AS sources
FROM ubuntu:22.04

RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
git \
libc-dev \
libopus-dev \
libsodium-dev \
libvpx-dev \
make \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /work/slimcc
RUN ["git", "clone", "--depth=1", "https://github.com/fuhsnn/slimcc", "/work/slimcc"]
RUN ["make", "CFLAGS=-O3"]

WORKDIR /work/c-toxcore
COPY --from=sources /src/ /work/c-toxcore
COPY other/docker/slimcc/Makefile /work/c-toxcore/
RUN ["make"]

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN ./send_message_test | grep "tox clients connected"
11 changes: 6 additions & 5 deletions toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ static void fill_addr6(const IP6 *ip, struct in6_addr *addr)
#define INADDR_LOOPBACK 0x7f000001
#endif /* !defined(INADDR_LOOPBACK) */

static const IP empty_ip = {{0}};

IP4 get_ip4_broadcast(void)
{
const IP4 ip4_broadcast = { INADDR_BROADCAST };
Expand All @@ -361,7 +359,7 @@ IP4 get_ip4_loopback(void)
IP6 get_ip6_loopback(void)
{
/* in6addr_loopback isn't available everywhere, so we do it ourselves. */
IP6 loopback = empty_ip.ip.v6;
IP6 loopback = {{0}};
loopback.uint8[15] = 1;
return loopback;
}
Expand Down Expand Up @@ -1492,6 +1490,8 @@ int ipport_cmp_handler(const void *a, const void *b, size_t size)
return cmp_uint(ipp_a->port, ipp_b->port);
}

static const IP empty_ip = {{0}};

/** nulls out ip */
void ip_reset(IP *ip)
{
Expand All @@ -1502,14 +1502,15 @@ void ip_reset(IP *ip)
*ip = empty_ip;
}

static const IP_Port empty_ip_port = {{{0}}};

/** nulls out ip_port */
void ipport_reset(IP_Port *ipport)
{
if (ipport == nullptr) {
return;
}

const IP_Port empty_ip_port = {{{0}}};
*ipport = empty_ip_port;
}

Expand All @@ -1520,7 +1521,7 @@ void ip_init(IP *ip, bool ipv6enabled)
return;
}

*ip = empty_ip;
ip_reset(ip);
ip->family = ipv6enabled ? net_family_ipv6() : net_family_ipv4();
}

Expand Down

0 comments on commit 4201066

Please sign in to comment.