Skip to content

Commit

Permalink
build: test on more platforms via QEMU in CI
Browse files Browse the repository at this point in the history
This commit runs the test suite via QEMU on GitHub Actions on
a variety of platforms.

Fixes: libuv#2842
PR-URL: libuv#2846
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
gengjiawen authored and cjihrig committed May 17, 2020
1 parent fcedadc commit 1c97611
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on: [push, pull_request]

jobs:
build-cross-qemu:
runs-on: ubuntu-latest
name: build-cross-qemu-${{ matrix.config.target }}

strategy:
fail-fast: false
matrix:
config:
- {target: arm, toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static }
- {target: armhf, toolchain: gcc-arm-linux-gnueabihf, cc: arm-linux-gnueabihf-gcc, qemu: qemu-arm-static }
- {target: aarch64, toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static }
- {target: riscv64, toolchain: gcc-riscv64-linux-gnu, cc: riscv64-linux-gnu-gcc, qemu: qemu-riscv64-static }
- {target: ppc, toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static }
- {target: ppc64, toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static }
- {target: ppc64le, toolchain: gcc-powerpc64le-linux-gnu, cc: powerpc64le-linux-gnu-gcc, qemu: qemu-ppc64le-static }
- {target: s390x, toolchain: gcc-s390x-linux-gnu, cc: s390x-linux-gnu-gcc, qemu: qemu-s390x-static }
- {target: mips, toolchain: gcc-mips-linux-gnu, cc: mips-linux-gnu-gcc, qemu: qemu-mips-static }
- {target: mips64, toolchain: gcc-mips64-linux-gnuabi64, cc: mips64-linux-gnuabi64-gcc, qemu: qemu-mips64-static }
- {target: mipsel, toolchain: gcc-mipsel-linux-gnu, cc: mipsel-linux-gnu-gcc, qemu: qemu-mipsel-static }
- {target: mips64el,toolchain: gcc-mips64el-linux-gnuabi64, cc: mips64el-linux-gnuabi64-gcc,qemu: qemu-mips64el-static }
- {target: alpha, toolchain: gcc-alpha-linux-gnu, cc: alpha-linux-gnu-gcc, qemu: qemu-alpha-static }
- {target: arm (u64 slots), toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static}
- {target: aarch64 (u64 slots), toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static}
- {target: ppc (u64 slots), toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static}
- {target: ppc64 (u64 slots), toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static}

steps:
- uses: actions/checkout@v2
- name: Install QEMU
# this ensure install latest qemu on ubuntu, apt get version is old
env:
QEMU_SRC: "https://archive.ubuntu.com/ubuntu/pool/universe/q/qemu"
QEMU_VER: "qemu-user-static_4\\.2-.*_amd64.deb$"
run: |
DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER`
wget $QEMU_SRC/$DEB
sudo dpkg -i $DEB
- name: Install ${{ matrix.config.toolchain }}
run: |
sudo apt install ${{ matrix.config.toolchain }} -y
- name: Build
run: |
mkdir build
cd build && cmake .. -DBUILD_TESTING=ON -DQEMU=ON -DCMAKE_C_COMPILER=${{ matrix.config.cc }}
cmake --build .
ls -lh
- name: Test
run: |
${{ matrix.config.qemu }} build/uv_run_tests_a
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ipch

# Clion / IntelliJ project files
/.idea/
cmake-build-debug/

*.xcodeproj
*.xcworkspace
Expand Down
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ cmake_dependent_option(LIBUV_BUILD_BENCH
"Build the benchmarks when building unit tests and we are the root project" ON
"LIBUV_BUILD_TESTS" OFF)

# Qemu Build
option(QEMU "build for qemu" OFF)
if(QEMU)
add_definitions(-D__QEMU__=1)
endif()

# Compiler check
string(CONCAT is-msvc $<OR:
$<C_COMPILER_ID:MSVC>,
Expand Down Expand Up @@ -525,7 +531,11 @@ if(LIBUV_BUILD_TESTS)
add_executable(uv_run_tests_a ${uv_test_sources} uv_win_longpath.manifest)
target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines})
target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags})
target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries})
if(QEMU)
target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries} -static)
else()
target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries})
endif()
add_test(NAME uv_test_a
COMMAND uv_run_tests_a
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -565,3 +575,11 @@ if(WIN32)
RUNTIME DESTINATION lib/$<CONFIG>
ARCHIVE DESTINATION lib/$<CONFIG>)
endif()

message(STATUS "summary of build options:
Install prefix: ${CMAKE_INSTALL_PREFIX}
Target system: ${CMAKE_SYSTEM_NAME}
Compiler:
C compiler: ${CMAKE_C_COMPILER}
CFLAGS: ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
")
10 changes: 10 additions & 0 deletions test/test-connection-fail.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ static void connection_fail(uv_connect_cb connect_cb) {
* expect an error.
*/
TEST_IMPL(connection_fail) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

connection_fail(on_connect_with_close);

ASSERT(timer_close_cb_calls == 0);
Expand All @@ -136,6 +141,11 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
TEST_IMPL(connection_fail_doesnt_auto_close) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

int r;

r = uv_timer_init(uv_default_loop(), &timer);
Expand Down
5 changes: 5 additions & 0 deletions test/test-get-currentexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
extern char executable_path[];

TEST_IMPL(get_currentexe) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

char buffer[PATHMAX];
char path[PATHMAX];
size_t size;
Expand Down
5 changes: 5 additions & 0 deletions test/test-get-passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include <string.h>

TEST_IMPL(get_passwd) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

uv_passwd_t pwd;
size_t len;
int r;
Expand Down
8 changes: 8 additions & 0 deletions test/test-getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ TEST_IMPL(getaddrinfo_fail) {


TEST_IMPL(getaddrinfo_fail_sync) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
uv_getaddrinfo_t req;

/* Use a FQDN by ending in a period */
Expand Down Expand Up @@ -144,6 +148,10 @@ TEST_IMPL(getaddrinfo_basic) {


TEST_IMPL(getaddrinfo_basic_sync) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
uv_getaddrinfo_t req;

ASSERT(0 == uv_getaddrinfo(uv_default_loop(),
Expand Down
5 changes: 5 additions & 0 deletions test/test-getnameinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ TEST_IMPL(getnameinfo_basic_ip4) {


TEST_IMPL(getnameinfo_basic_ip4_sync) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

ASSERT(0 == uv_ip4_addr(address_ip4, port, &addr4));

ASSERT(0 == uv_getnameinfo(uv_default_loop(),
Expand Down
5 changes: 5 additions & 0 deletions test/test-platform-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@


TEST_IMPL(platform_output) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

char buffer[512];
size_t rss;
size_t size;
Expand Down
5 changes: 5 additions & 0 deletions test/test-tcp-write-after-connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ static void connect_cb(uv_connect_t *req, int status) {


TEST_IMPL(tcp_write_after_connect) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

struct sockaddr_in sa;
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &sa));
ASSERT(0 == uv_loop_init(&loop));
Expand Down
4 changes: 4 additions & 0 deletions test/test-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ static void getaddrinfo_do(struct getaddrinfo_req* req) {
static void getaddrinfo_cb(uv_getaddrinfo_t* handle,
int status,
struct addrinfo* res) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
struct getaddrinfo_req* req;

ASSERT(status == 0);
Expand Down
5 changes: 5 additions & 0 deletions test/test-udp-multicast-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ static void sv_send_cb(uv_udp_send_t* req, int status) {


TEST_IMPL(udp_multicast_interface) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

int r;
uv_udp_send_t req;
uv_buf_t buf;
Expand Down
5 changes: 5 additions & 0 deletions test/test-udp-multicast-interface6.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ static void sv_send_cb(uv_udp_send_t* req, int status) {


TEST_IMPL(udp_multicast_interface6) {
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif

int r;
uv_udp_send_t req;
uv_buf_t buf;
Expand Down
4 changes: 4 additions & 0 deletions test/test-udp-multicast-join6.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ TEST_IMPL(udp_multicast_join6) {

ASSERT(r == 0);

/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
r = uv_udp_recv_start(&server, alloc_cb, cl_recv_cb);
ASSERT(r == 0);

Expand Down
4 changes: 4 additions & 0 deletions test/test-udp-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ TEST_IMPL(udp_no_autobind) {
ASSERT(UV_EBADF == uv_udp_set_ttl(&h, 1));
#endif
ASSERT(UV_EBADF == uv_udp_set_multicast_loop(&h, 1));
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
ASSERT(UV_EBADF == uv_udp_set_multicast_interface(&h, "0.0.0.0"));

uv_close((uv_handle_t*) &h, NULL);
Expand Down

0 comments on commit 1c97611

Please sign in to comment.