feat update
All checks were successful
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 1m33s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m32s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m16s

This commit is contained in:
tqcq 2024-03-30 08:54:42 +08:00
parent 7dd4652964
commit a74cf3219c
4 changed files with 40 additions and 41 deletions

View File

@ -24,19 +24,19 @@ add_subdirectory(3party/asyncplusplus EXCLUDE_FROM_ALL)
# add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL) # add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL)
# add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL) # add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
if(NOT TARGET marl) if(NOT TARGET marl)
add_subdirectory(3party/marl EXCLUDE_FROM_ALL) add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
endif() endif()
if(NOT TARGET rpc_core) if(NOT TARGET rpc_core)
add_subdirectory(3party/rpc_core EXCLUDE_FROM_ALL) add_subdirectory(3party/rpc_core EXCLUDE_FROM_ALL)
endif() endif()
if(NOT TARGET fmt) if(NOT TARGET fmt)
add_subdirectory(3party/fmt EXCLUDE_FROM_ALL) add_subdirectory(3party/fmt EXCLUDE_FROM_ALL)
endif() endif()
if(SLED_LOCATION_PATH) if(SLED_LOCATION_PATH)
target_compile_definitions( target_compile_definitions(
sled PRIVATE __SLED_LOCATION_PATH="${SLED_LOCATION_PATH}") sled PRIVATE __SLED_LOCATION_PATH="${SLED_LOCATION_PATH}")
endif() endif()
# add_subdirectory(3party/eigen EXCLUDE_FROM_ALL) # add_subdirectory(3party/eigen EXCLUDE_FROM_ALL)
@ -44,8 +44,7 @@ target_include_directories(sled PUBLIC include 3party/eigen 3party/inja
3party/rxcpp) 3party/rxcpp)
target_sources( target_sources(
sled sled
PRIVATE PRIVATE src/async/async.cc
src/async/async.cc
src/filesystem/path.cc src/filesystem/path.cc
src/log/log.cc src/log/log.cc
src/network/async_resolver.cc src/network/async_resolver.cc
@ -84,16 +83,14 @@ target_sources(
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
check_c_compiler_flag("-Wl,--whole-archive" SUPPORT_COMPILE_WHOLE_ARCHIVE) check_c_compiler_flag("-Wl,--whole-archive" SUPPORT_COMPILE_WHOLE_ARCHIVE)
if(SUPPORT_COMPILE_WHOLE_ARCHIVE) if(SUPPORT_COMPILE_WHOLE_ARCHIVE)
set(WHOLE_ARCHIVE_WRAPPER_START "-Wl,--whole-archive") set(WHOLE_ARCHIVE_WRAPPER_START "-Wl,--whole-archive")
set(WHOLE_ARCHIVE_WRAPPER_END "-Wl,--no-whole-archive") set(WHOLE_ARCHIVE_WRAPPER_END "-Wl,--no-whole-archive")
endif() endif()
target_link_libraries( target_link_libraries(
sled sled
PUBLIC rpc_core fmt marl PUBLIC rpc_core fmt marl Async++
Async++ # protobuf::libprotobuf ${WHOLE_ARCHIVE_WRAPPER_START}
# protobuf::libprotobuf
# ${WHOLE_ARCHIVE_WRAPPER_START}
tcmalloc_and_profiler_static tcmalloc_and_profiler_static
# ${WHOLE_ARCHIVE_WRAPPER_END} # ${WHOLE_ARCHIVE_WRAPPER_END}
) )
@ -102,33 +99,33 @@ target_link_libraries(
set_target_properties(sled PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(sled PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(SLED_BUILD_BENCHMARK) if(SLED_BUILD_BENCHMARK)
if(NOT TARGET benchmark) if(NOT TARGET benchmark)
find_package(benchmark REQUIRED) find_package(benchmark REQUIRED)
endif() endif()
add_executable( add_executable(
sled_benchmark sled_benchmark
src/random_bench.cc src/strings/base64_bench.cc src/random_bench.cc src/strings/base64_bench.cc
src/system/fiber/fiber_bench.cc src/system/thread_pool_bench.cc src/system/fiber/fiber_bench.cc src/system/thread_pool_bench.cc
src/system_time_bench.cc) src/system_time_bench.cc)
target_link_libraries(sled_benchmark PRIVATE sled benchmark::benchmark target_link_libraries(sled_benchmark PRIVATE sled benchmark::benchmark
benchmark::benchmark_main) benchmark::benchmark_main)
endif(SLED_BUILD_BENCHMARK) endif(SLED_BUILD_BENCHMARK)
if(SLED_BUILD_TESTS) if(SLED_BUILD_TESTS)
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
googletest googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
) )
FetchContent_MakeAvailable(googletest) FetchContent_MakeAvailable(googletest)
add_executable( add_executable(
sled_tests sled_tests
# src/exec/just_test.cc # src/exec/just_test.cc
src/async/async_test.cc src/async/async_test.cc
src/any_test.cc src/any_test.cc
src/filesystem/path_test.cc src/filesystem/path_test.cc
src/futures/promise_test.cc # src/futures/promise_test.cc
src/futures/detail/just_test.cc src/futures/detail/just_test.cc
src/log/fmt_test.cc src/log/fmt_test.cc
# src/profiling/profiling_test.cc # src/profiling/profiling_test.cc
@ -141,23 +138,27 @@ if(SLED_BUILD_TESTS)
src/system/thread_pool_test.cc src/system/thread_pool_test.cc
src/rx_test.cc src/rx_test.cc
src/uri_test.cc) src/uri_test.cc)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(sled_tests PRIVATE -Wthread-safety) set(EXTRA_FLAGS -Wthread-safety -g -fsanitize=address
endif() -fno-omit-frame-pointer -fno-optimize-sibling-calls)
target_link_libraries(sled_tests PRIVATE sled GTest::gtest GTest::gtest_main) target_compile_options(sled_tests PRIVATE ${EXTRA_FLAGS})
add_test(NAME sled_tests COMMAND sled_tests)
target_link_options(sled_tests PRIVATE ${EXTRA_FLAGS})
endif()
target_link_libraries(sled_tests PRIVATE sled GTest::gtest GTest::gtest_main)
add_test(NAME sled_tests COMMAND sled_tests)
endif(SLED_BUILD_TESTS) endif(SLED_BUILD_TESTS)
if(SLED_BUILD_FUZZ) if(SLED_BUILD_FUZZ)
macro(add_fuzz_test name sources) macro(add_fuzz_test name sources)
add_executable(${name} ${sources}) add_executable(${name} ${sources})
target_link_libraries(${name} PRIVATE sled) target_link_libraries(${name} PRIVATE sled)
target_compile_options(${name} PRIVATE -g -O1 -fsanitize=fuzzer,address target_compile_options(${name} PRIVATE -g -O1 -fsanitize=fuzzer,address
-fsanitize-coverage=trace-cmp) -fsanitize-coverage=trace-cmp)
target_link_options(${name} PRIVATE -fsanitize=fuzzer,address target_link_options(${name} PRIVATE -fsanitize=fuzzer,address
-fsanitize-coverage=trace-cmp) -fsanitize-coverage=trace-cmp)
endmacro() endmacro()
add_fuzz_test(base64_fuzz src/strings/base64_fuzz.cc) add_fuzz_test(base64_fuzz src/strings/base64_fuzz.cc)
endif(SLED_BUILD_FUZZ) endif(SLED_BUILD_FUZZ)

View File

@ -20,9 +20,10 @@ public:
auto submit(F &&f, Args &&...args) -> std::future<decltype(f(args...))> auto submit(F &&f, Args &&...args) -> std::future<decltype(f(args...))>
{ {
std::function<decltype(f(args...))()> func = std::bind(std::forward<F>(f), std::forward<Args>(args)...); std::function<decltype(f(args...))()> func = std::bind(std::forward<F>(f), std::forward<Args>(args)...);
auto task_ptr = std::make_shared<std::packaged_task<decltype(f(args...))()>>(func); auto task_ptr = std::make_shared<std::packaged_task<decltype(f(args...))()>>(func);
auto future = task_ptr->get_future();
scheduler_->enqueue(marl::Task([task_ptr]() { (*task_ptr)(); })); scheduler_->enqueue(marl::Task([task_ptr]() { (*task_ptr)(); }));
return task_ptr->get_future(); return future;
} }
void Delete() override; void Delete() override;

View File

@ -27,9 +27,5 @@ TEST(Async, parallel_for)
TEST(Async, parallel_reduce) TEST(Async, parallel_reduce)
{ {
auto r = async::parallel_reduce(async::irange(1, 5), 0, [](int x, int y) { auto r = async::parallel_reduce(async::irange(1, 5), 0, [](int x, int y) { return x + y; });
LOGD("", "{},{}", x, y);
return x + y;
});
LOGD("", "{}", r);
} }

1
src/sanitizer_test.cc Normal file
View File

@ -0,0 +1 @@
#include <gtest/gtest.h>