build: add asan checks
Fixes: https://github.com/libuv/libuv/issues/2999 PR-URL: https://github.com/libuv/libuv/pull/2998 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
30ff5bf216
commit
97a903309f
17
.github/workflows/sanitizer.yml
vendored
Normal file
17
.github/workflows/sanitizer.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Sanitizer checks
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
asan:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Envinfo
|
||||||
|
run: npx envinfo
|
||||||
|
- name: ASAN
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build && cmake .. -DBUILD_TESTING=ON -DASAN=ON -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
cmake --build . && ./uv_run_tests_a
|
||||||
|
|
||||||
@ -30,6 +30,13 @@ if(QEMU)
|
|||||||
add_definitions(-D__QEMU__=1)
|
add_definitions(-D__QEMU__=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(ASAN "Enable AddressSanitizer (ASan)" OFF)
|
||||||
|
if(ASAN AND CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang")
|
||||||
|
add_definitions(-D__ASAN__=1)
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Compiler check
|
# Compiler check
|
||||||
string(CONCAT is-msvc $<OR:
|
string(CONCAT is-msvc $<OR:
|
||||||
$<C_COMPILER_ID:MSVC>,
|
$<C_COMPILER_ID:MSVC>,
|
||||||
|
|||||||
@ -37,6 +37,9 @@
|
|||||||
* See https://github.com/joyent/libuv/issues/210
|
* See https://github.com/joyent/libuv/issues/210
|
||||||
*/
|
*/
|
||||||
TEST_IMPL(error_message) {
|
TEST_IMPL(error_message) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
/* Cop out. Can't do proper checks on systems with
|
/* Cop out. Can't do proper checks on systems with
|
||||||
|
|||||||
@ -96,6 +96,9 @@ static void touch_file(const char* name, unsigned int size) {
|
|||||||
|
|
||||||
|
|
||||||
TEST_IMPL(fs_copyfile) {
|
TEST_IMPL(fs_copyfile) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
const char src[] = "test_file_src";
|
const char src[] = "test_file_src";
|
||||||
uv_loop_t* loop;
|
uv_loop_t* loop;
|
||||||
uv_fs_t req;
|
uv_fs_t req;
|
||||||
|
|||||||
@ -673,6 +673,9 @@ TEST_IMPL(fs_event_watch_file_exact_path) {
|
|||||||
TEST_IMPL(fs_event_watch_file_twice) {
|
TEST_IMPL(fs_event_watch_file_twice) {
|
||||||
#if defined(NO_FS_EVENTS)
|
#if defined(NO_FS_EVENTS)
|
||||||
RETURN_SKIP(NO_FS_EVENTS);
|
RETURN_SKIP(NO_FS_EVENTS);
|
||||||
|
#endif
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
#endif
|
#endif
|
||||||
const char path[] = "test/fixtures/empty_file";
|
const char path[] = "test/fixtures/empty_file";
|
||||||
uv_fs_event_t watchers[2];
|
uv_fs_event_t watchers[2];
|
||||||
|
|||||||
@ -230,6 +230,9 @@ static void file_opendir_cb(uv_fs_t* req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(fs_readdir_file) {
|
TEST_IMPL(fs_readdir_file) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
const char* path;
|
const char* path;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|||||||
@ -2837,6 +2837,9 @@ TEST_IMPL(fs_scandir_non_existent_dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(fs_scandir_file) {
|
TEST_IMPL(fs_scandir_file) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
const char* path;
|
const char* path;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -3083,6 +3086,9 @@ static void fs_read_bufs(int add_flags) {
|
|||||||
uv_fs_req_cleanup(&close_req);
|
uv_fs_req_cleanup(&close_req);
|
||||||
}
|
}
|
||||||
TEST_IMPL(fs_read_bufs) {
|
TEST_IMPL(fs_read_bufs) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
fs_read_bufs(0);
|
fs_read_bufs(0);
|
||||||
fs_read_bufs(UV_FS_O_FILEMAP);
|
fs_read_bufs(UV_FS_O_FILEMAP);
|
||||||
|
|
||||||
|
|||||||
@ -693,6 +693,11 @@ static void ipc_on_connection(uv_stream_t* server, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void close_and_free_cb(uv_handle_t* handle) {
|
||||||
|
close_cb_called++;
|
||||||
|
free(handle);
|
||||||
|
}
|
||||||
|
|
||||||
static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) {
|
static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) {
|
||||||
int r;
|
int r;
|
||||||
uv_buf_t buf;
|
uv_buf_t buf;
|
||||||
@ -721,7 +726,7 @@ static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) {
|
|||||||
on_tcp_child_process_read);
|
on_tcp_child_process_read);
|
||||||
ASSERT_EQ(r, 0);
|
ASSERT_EQ(r, 0);
|
||||||
|
|
||||||
uv_close((uv_handle_t*)conn, close_cb);
|
uv_close((uv_handle_t*)conn, close_and_free_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,9 @@ TEST_IMPL(pipe_connect_bad_name) {
|
|||||||
|
|
||||||
|
|
||||||
TEST_IMPL(pipe_connect_to_file) {
|
TEST_IMPL(pipe_connect_to_file) {
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
const char* path = "test/fixtures/empty_file";
|
const char* path = "test/fixtures/empty_file";
|
||||||
uv_pipe_t client;
|
uv_pipe_t client;
|
||||||
uv_connect_t req;
|
uv_connect_t req;
|
||||||
|
|||||||
@ -155,6 +155,7 @@ TEST_IMPL(platform_output) {
|
|||||||
printf(" username: %s\n", pwd.username);
|
printf(" username: %s\n", pwd.username);
|
||||||
printf(" shell: %s\n", pwd.shell);
|
printf(" shell: %s\n", pwd.shell);
|
||||||
printf(" home directory: %s\n", pwd.homedir);
|
printf(" home directory: %s\n", pwd.homedir);
|
||||||
|
uv_os_free_passwd(&pwd);
|
||||||
|
|
||||||
pid = uv_os_getpid();
|
pid = uv_os_getpid();
|
||||||
ASSERT(pid > 0);
|
ASSERT(pid > 0);
|
||||||
|
|||||||
@ -426,6 +426,9 @@ TEST_IMPL(tty_pty) {
|
|||||||
#if defined(__QEMU__)
|
#if defined(__QEMU__)
|
||||||
RETURN_SKIP("Test does not currently work in QEMU");
|
RETURN_SKIP("Test does not currently work in QEMU");
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__ASAN__)
|
||||||
|
RETURN_SKIP("Test does not currently work in ASAN");
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__) || \
|
#if defined(__APPLE__) || \
|
||||||
defined(__DragonFly__) || \
|
defined(__DragonFly__) || \
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user