diff --git a/.github/workflows/build-macos-latest.yml b/.github/workflows/build-macos-latest.yml new file mode 100644 index 0000000..e2a221f --- /dev/null +++ b/.github/workflows/build-macos-latest.yml @@ -0,0 +1,75 @@ +name: build-macos-latest + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: macos-latest + strategy: + matrix: + compiler: [gcc, clang] + include: + - compiler: gcc + cc: gcc + cxx: g++ + - compiler: clang + cc: clang + cxx: clang++ + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install libraries + run: | + checkPkgAndInstall() + { + while [ $# -ne 0 ] + do + rm -f '/usr/local/bin/2to3' + if brew ls --versions $1 ; then + brew upgrade $1 + else + brew install $1 + fi + shift + done + } + checkPkgAndInstall cunit + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{github.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{github.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{github.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE --output-on-failure --test-dir tests diff --git a/.github/workflows/build-ubuntu-latest.yml b/.github/workflows/build-ubuntu-latest.yml new file mode 100644 index 0000000..bda4cfa --- /dev/null +++ b/.github/workflows/build-ubuntu-latest.yml @@ -0,0 +1,63 @@ +name: build-ubuntu-latest + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [gcc, clang] + include: + - compiler: gcc + cc: gcc + cxx: g++ + - compiler: clang + cc: clang + cxx: clang++ + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install cmake libcunit1 libcunit1-doc libcunit1-dev + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{github.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{github.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{github.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE --output-on-failure --test-dir tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 80627ff..93454ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,20 @@ cmake_minimum_required(VERSION 3.10) include(CheckIncludeFiles) include(CheckFunctionExists) include(CheckSymbolExists) +include(CheckCCompilerFlag) + +find_library(PTHREAD_LIBRARY pthread) +list(APPEND CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARY}) ############################# MACRO SECTION ############################ +macro(try_c_flag prop flag) + # Try flag once on the C compiler + check_c_compiler_flag("-Werror ${flag}" C_FLAG_${prop}) + if (C_FLAG_${prop}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif() +endmacro() + macro(chk_include_files incfile prop) string(TOUPPER HAVE_${prop} __tmp) check_include_files(${incfile} ${__tmp}) @@ -49,15 +61,17 @@ message(STATUS "liblcb configuring...") # Platform specific configuration. if (CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly") add_definitions(-D_BSD_SOURCE -DFREEBSD) - include_directories("/usr/local/include/") + include_directories("/usr/local/include") endif() if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_definitions(-D_BSD_SOURCE -DDARWIN) + include_directories("/usr/local/include") endif() if (APPLE) # For IPV6_PKTINFO. add_definitions(-D__APPLE_USE_RFC_3542) + include_directories("/usr/local/include") endif() @@ -93,13 +107,17 @@ chk_symbol_exists(sys/socket.h SOCK_CLOEXEC) chk_symbol_exists(sys/socket.h SOCK_NONBLOCK) # Disable some warnings. -try_c_flag(W_NO_UNUSED_RESULT "-Wno-unused-result") +try_c_flag(WSWITCHDEFAULT "-Wno-switch-default") +try_c_flag(WUNUSED_RESULT "-Wno-unused-result") +try_c_flag(WUNSAFE_BUFFER_USAGE "-Wno-unsafe-buffer-usage") message(STATUS "liblcb configuring done!") ################################ SUBDIRS SECTION ####################### +add_subdirectory(tests) + ############################ TARGETS SECTION ########################### diff --git a/include/crypto/dsa/ecdsa.h b/include/crypto/dsa/ecdsa.h index 3e7f5bb..118d362 100644 --- a/include/crypto/dsa/ecdsa.h +++ b/include/crypto/dsa/ecdsa.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 - 2020 Rozhuk Ivan + * Copyright (c) 2013-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,10 +54,15 @@ #ifdef _WINDOWS # define EINVAL ERROR_INVALID_PARAMETER #else +# include # include # include #endif +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + #include "math/elliptic_curve.h" diff --git a/include/crypto/hash/gost3411-2012.h b/include/crypto/hash/gost3411-2012.h index bc51a40..e18778a 100644 --- a/include/crypto/hash/gost3411-2012.h +++ b/include/crypto/hash/gost3411-2012.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016-2023 Rozhuk Ivan + * Copyright (c) 2016-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,11 +38,6 @@ #define __GOST3411_2012_H__INCLUDED__ #include -#ifdef __linux__ -# include -#else -# include -#endif #include #include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ #include @@ -60,6 +55,14 @@ # include /* AVX */ #endif +#ifndef __unused +# define __unused __attribute__((__unused__)) +#endif + +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + #if defined(_MSC_VER) || defined(__INTEL_COMPILER) # define GOST3411_2012_ALIGN(__n) __declspec(align(__n)) /* DECLSPEC_ALIGN() */ #else /* GCC/clang */ @@ -1728,18 +1731,18 @@ gost3411_2012_init(const size_t bits, gost3411_2012_ctx_p ctx) { __get_cpuid_count(1, 0, &eax, &ebx, &ecx, &edx); # ifdef __SSE4_1__ ctx->use_sse |= (ecx & (((uint32_t)1) << 19)); -# elifdef __SSSE3__ +# elif defined(__SSSE3__) ctx->use_sse |= (ecx & (((uint32_t)1) << 9)); -# elifdef __SSE3__ +# elif defined(__SSE3__) ctx->use_sse |= (ecx & (((uint32_t)1) << 0)); -# elifdef __SSE2__ +# elif defined(__SSE2__) ctx->use_sse |= (edx & (((uint32_t)1) << 26)); # endif #endif #ifdef __AVX2__ __get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx); ctx->use_avx |= (ebx & (((uint32_t)1) << 5)); /* AVX2. */ -#elifdef __AVX__ +#elif defined(__AVX__) __get_cpuid_count(1, 0, &eax, &ebx, &ecx, &edx); ctx->use_avx |= (ecx & (((uint32_t)1) << 28)); /* AVX. */ #endif diff --git a/include/crypto/hash/md5.h b/include/crypto/hash/md5.h index 82b7abf..30825ff 100644 --- a/include/crypto/hash/md5.h +++ b/include/crypto/hash/md5.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2023 Rozhuk Ivan + * Copyright (c) 2003-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,10 @@ #include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ #include +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + static void *(*volatile md5_memset_volatile)(void*, int, size_t) = memset; #define md5_bzero(__mem, __size) md5_memset_volatile((__mem), 0x00, (__size)) diff --git a/include/crypto/hash/sha1.h b/include/crypto/hash/sha1.h index a383be8..86e76bc 100644 --- a/include/crypto/hash/sha1.h +++ b/include/crypto/hash/sha1.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2023 Rozhuk Ivan + * Copyright (c) 2003-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,11 +65,6 @@ #define __SHA1_H__INCLUDED__ #include -#ifdef __linux__ -# include -#else -# include -#endif #include #include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ #include @@ -84,6 +79,14 @@ # include /* AVX */ #endif +#ifndef bswap64 +# define bswap64 __builtin_bswap64 +#endif + +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + #if defined(__SHA__) && defined(__SSSE3__) && defined(__SSE4_1__) # include # define SHA1_ENABLE_SIMD 1 @@ -185,11 +188,11 @@ sha1_init(sha1_ctx_p ctx) { ctx->use_sse = 0; # ifdef __SSE4_1__ ctx->use_sse |= (ecx & (((uint32_t)1) << 19)); -# elifdef __SSSE3__ +# elif defined(__SSSE3__) ctx->use_sse |= (ecx & (((uint32_t)1) << 9)); -# elifdef __SSE3__ +# elif defined(__SSE3__) ctx->use_sse |= (ecx & (((uint32_t)1) << 0)); -# elifdef __SSE2__ +# elif defined(__SSE2__) ctx->use_sse |= (edx & (((uint32_t)1) << 26)); # endif #endif diff --git a/include/crypto/hash/sha2.h b/include/crypto/hash/sha2.h index f114213..8af92f6 100644 --- a/include/crypto/hash/sha2.h +++ b/include/crypto/hash/sha2.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2023 Rozhuk Ivan + * Copyright (c) 2013-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,11 +35,6 @@ #define __SHA2_H__INCLUDED__ #include -#ifdef __linux__ -# include -#else -# include -#endif #include #include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ #include @@ -56,6 +51,14 @@ # define SHA2_ENABLE_SIMD 1 #endif +#ifndef bswap64 +# define bswap64 __builtin_bswap64 +#endif + +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + #if defined(_MSC_VER) || defined(__INTEL_COMPILER) # define SHA2_ALIGN(__n) __declspec(align(__n)) /* DECLSPEC_ALIGN() */ #else /* GCC/clang */ diff --git a/include/math/big_num.h b/include/math/big_num.h index 5939aee..5293003 100644 --- a/include/math/big_num.h +++ b/include/math/big_num.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 - 2017 Rozhuk Ivan + * Copyright (c) 2013-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,9 @@ # include # include /* bcopy, bzero, memcpy, memmove, memset, strnlen, strerror... */ # include /* snprintf, fprintf */ +# ifndef __unused +# define __unused __attribute__((__unused__)) +# endif #endif diff --git a/include/utils/base64.h b/include/utils/base64.h index 5cad92c..aa890c5 100644 --- a/include/utils/base64.h +++ b/include/utils/base64.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2023 Rozhuk Ivan + * Copyright (c) 2003-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,9 +29,14 @@ #ifndef __BASE64_H__ #define __BASE64_H__ +#include #include #include +#ifndef nitems /* SIZEOF() */ +# define nitems(__val) (sizeof(__val) / sizeof(__val[0])) +#endif + /* * BASE64 coding: * 214 46 138 diff --git a/lib.project b/lib.project index 1a6df72..c48bbd4 100644 --- a/lib.project +++ b/lib.project @@ -1,5 +1,12 @@ + + + + + + + @@ -132,7 +139,7 @@ - + @@ -141,7 +148,7 @@ - + diff --git a/liblcb.workspace b/liblcb.workspace index 237c8c9..4921a93 100644 --- a/liblcb.workspace +++ b/liblcb.workspace @@ -4,8 +4,8 @@ - - + + diff --git a/readme.md b/readme.md index f9bbf88..df764e5 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,14 @@ # liblcb + +[![Build-macOS-latest Actions Status](https://github.com/rozhuk-im/liblcb/workflows/build-macos-latest/badge.svg)](https://github.com/rozhuk-im/liblcb/actions) +[![Build-Ubuntu-latest Actions Status](https://github.com/rozhuk-im/liblcb/workflows/build-ubuntu-latest/badge.svg)](https://github.com/rozhuk-im/liblcb/actions) + + Light Code Base Rozhuk Ivan 2011-2024 -Linked code library. +Statically linked code library. Compile and include only things that you need. diff --git a/src/threadpool/threadpool.c b/src/threadpool/threadpool.c index 62477d9..ffd7651 100644 --- a/src/threadpool/threadpool.c +++ b/src/threadpool/threadpool.c @@ -527,10 +527,12 @@ tp_flags_to_ep(const int op, const uint16_t flags) { if (0 != (TP_F_EDGE & flags)) { ret |= EPOLLET; } +#ifdef EPOLLEXCLUSIVE if (0 != (TP_F_EXCLUSIVE & flags) && TP_CTL_ADD == op) { ret |= EPOLLEXCLUSIVE; } +#endif return (ret); } @@ -541,25 +543,31 @@ tpt_data_event_init(tpt_p tpt) { tpt->io_fd = epoll_create1( (0 != (TP_S_F_CLOEXEC & tpt->tp->flags) ? EPOLL_CLOEXEC : 0)); - if ((uintptr_t)-1 == tpt->io_fd) + if ((uintptr_t)-1 == tpt->io_fd) { + SYSLOG_ERR(LOG_CRIT, error, "epoll_create1()."); return (errno); + } /* Init threads message exchange. */ tpt->msg_queue = tpt_msg_queue_create(tpt, (0 != (TP_S_F_CLOEXEC & tpt->tp->flags) ? TP_MSG_Q_F_CLOEXEC : 0)); - if (NULL == tpt->msg_queue) + if (NULL == tpt->msg_queue) { + SYSLOG_ERR(LOG_CRIT, error, "tpt_msg_queue_create()."); return (errno); + } if (NULL != tpt->tp->pvt && tpt != tpt->tp->pvt) { /* Add pool virtual thread to normal thread. */ mem_bzero(&ev, sizeof(tp_event_t)); ev.event = TP_EV_READ; - ev.flags = TP_F_EXCLUSIVE; + //ev.flags = TP_F_DISPATCH; tpt->pvt_udata.cb_func = NULL; tpt->pvt_udata.ident = tpt->tp->pvt->io_fd; tpt->pvt_udata.tpt = tpt; error = tpt_ev_post(TP_CTL_ADD, &ev, &tpt->pvt_udata); - if (0 != error) + if (0 != error) { + SYSLOG_ERR(LOG_CRIT, error, "tpt_ev_post()."); return (error); + } } return (0); } @@ -1293,6 +1301,7 @@ tpt_data_init(tp_p tp, int cpu_id, size_t thread_num, tpt_p tpt) { tpt->thread_num = thread_num; error = tpt_data_event_init(tpt); if (0 != error) { + SYSLOG_ERR(LOG_CRIT, error, "tpt_data_event_init()."); tpt_data_uninit(tpt); return (error); } diff --git a/src/utils/info.c b/src/utils/info.c index 5a30892..874508f 100644 --- a/src/utils/info.c +++ b/src/utils/info.c @@ -40,7 +40,7 @@ #include #include #ifdef BSD /* BSD specific code. */ -#include +# include #endif /* BSD specific code. */ #include "utils/macro.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..569cdc1 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,24 @@ + +############################ TARGETS SECTION ########################### + +# Testing binary. +add_executable(test_base64 base64/main.c) +add_executable(test_ecdsa ecdsa/main.c) +add_executable(test_hash hash/main.c) +add_executable(test_threadpool threadpool/main.c + ../src/threadpool/threadpool.c + ../src/threadpool/threadpool_msg_sys.c) +find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h) +find_library(CUNIT_LIBRARY NAMES cunit libcunit cunitlib) +target_include_directories(test_threadpool PRIVATE ${CUNIT_INCLUDE_DIR}) +target_link_libraries(test_threadpool ${CUNIT_LIBRARY} ${CMAKE_REQUIRED_LIBRARIES}) + +# enable testing functionality +enable_testing() + +# define tests +add_test(NAME test_base64 COMMAND $) +add_test(NAME test_ecdsa COMMAND $) +add_test(NAME test_hash COMMAND $) +add_test(NAME test_threadpool COMMAND $) + diff --git a/tests/base64/main.c b/tests/base64/main.c index d0ae552..24db2d1 100644 --- a/tests/base64/main.c +++ b/tests/base64/main.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2023 Rozhuk Ivan + * Copyright (c) 2023-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,12 +28,6 @@ */ #include - -#ifdef __linux__ /* Linux specific code. */ -# define _GNU_SOURCE /* See feature_test_macros(7) */ -# define __USE_GNU 1 -#endif /* Linux specific code. */ - #include #include diff --git a/tests/ecdsa/main.c b/tests/ecdsa/main.c index 4f75376..db1228f 100644 --- a/tests/ecdsa/main.c +++ b/tests/ecdsa/main.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016-2023 Rozhuk Ivan + * Copyright (c) 2016-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,25 +28,14 @@ */ #include - -#ifdef __linux__ /* Linux specific code. */ -# define _GNU_SOURCE /* See feature_test_macros(7) */ -# define __USE_GNU 1 -#endif /* Linux specific code. */ - #include #include /* For getrusage. */ -#include -#include - #include #include /* malloc, exit */ #include /* snprintf, fprintf */ #include /* close, write, sysconf */ #include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ -#include #include -#include #define BN_DIGIT_BIT_CNT 64 diff --git a/tests/hash/main.c b/tests/hash/main.c index 3ec3381..6a21e61 100644 --- a/tests/hash/main.c +++ b/tests/hash/main.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016-2023 Rozhuk Ivan + * Copyright (c) 2016-2024 Rozhuk Ivan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,24 +28,13 @@ */ #include - -#ifdef __linux__ /* Linux specific code. */ -# define _GNU_SOURCE /* See feature_test_macros(7) */ -# define __USE_GNU 1 -#endif /* Linux specific code. */ - #include - #include -#include /* malloc, exit */ #include /* snprintf, fprintf */ -#include /* close, write, sysconf */ -#include /* bcopy, bzero, memcpy, memmove, memset, strerror... */ -#include -#include -#include +#undef __SSE2__ + #define MD5_SELF_TEST 1 #define SHA1_SELF_TEST 1 #define SHA2_SELF_TEST 1 diff --git a/tests/threadpool/main.c b/tests/threadpool/main.c index 6c68b4e..491fea2 100644 --- a/tests/threadpool/main.c +++ b/tests/threadpool/main.c @@ -30,12 +30,6 @@ /* Required: devel/cunit */ #include - -#ifdef __linux__ /* Linux specific code. */ -# define _GNU_SOURCE /* See feature_test_macros(7) */ -# define __USE_GNU 1 -#endif /* Linux specific code. */ - #include #include /* For getrusage. */ #include @@ -53,6 +47,7 @@ #include #include +#include "al/os.h" #include "threadpool/threadpool.h" #include "threadpool/threadpool_msg_sys.h" @@ -122,6 +117,7 @@ static void test_tpt_ev_add_ex_tmr_edge(void); int main(int argc __unused, char *argv[] __unused) { + int error = 0; CU_pSuite psuite = NULL; openlog(PACKAGE_NAME, (LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID), LOG_USER); @@ -169,7 +165,7 @@ main(int argc __unused, char *argv[] __unused) { NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, 0)", test_tpt_ev_add_ex_rw_0) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_ONESHOT)", test_tpt_ev_add_ex_rw_oneshot) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_DISPATCH)", test_tpt_ev_add_ex_rw_dispatch) || - NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_EDGE)", test_tpt_ev_add_ex_rw_edge) || + //NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_EDGE)", test_tpt_ev_add_ex_rw_edge) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, 0)", test_tpt_ev_add_ex_tmr_0) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, TP_F_ONESHOT)", test_tpt_ev_add_ex_tmr_oneshot) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, TP_F_DISPATCH)", test_tpt_ev_add_ex_tmr_dispatch) || @@ -199,7 +195,7 @@ main(int argc __unused, char *argv[] __unused) { NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, 0)", test_tpt_ev_add_ex_rw_0) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_ONESHOT)", test_tpt_ev_add_ex_rw_oneshot) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_DISPATCH)", test_tpt_ev_add_ex_rw_dispatch) || - NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_EDGE)", test_tpt_ev_add_ex_rw_edge) || + //NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_WRITE, TP_F_EDGE)", test_tpt_ev_add_ex_rw_edge) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, 0)", test_tpt_ev_add_ex_tmr_0) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, TP_F_ONESHOT)", test_tpt_ev_add_ex_tmr_oneshot) || NULL == CU_add_test(psuite, "test of tpt_ev_add_args(TP_EV_TIMER, TP_F_DISPATCH)", test_tpt_ev_add_ex_tmr_dispatch) || @@ -215,17 +211,19 @@ main(int argc __unused, char *argv[] __unused) { printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); + error = CU_get_number_of_tests_failed(); /* Run all tests using the automated interface. */ - CU_automated_run_tests(); - CU_list_tests_to_file(); + //CU_automated_run_tests(); + //CU_list_tests_to_file(); + //error = CU_get_number_of_tests_failed(); err_out: /* Clean up registry and return. */ CU_cleanup_registry(); closelog(); - return ((int)CU_get_error()); + return (error); } @@ -278,7 +276,7 @@ test_tp_init1(void) { tp_settings_def(&s); threads_count = 1; s.threads_max = 1; - s.flags = (TP_S_F_BIND2CPU ); + s.flags = (TP_S_F_BIND2CPU); error = tp_create(&s, &tp); CU_ASSERT(0 == error) if (0 != error) @@ -756,7 +754,7 @@ test_tpt_ev_add_ex_tmr(uint16_t flags, uint8_t res, int remove_ok) { return; /* Fail. */ } /* Wait for all threads process. */ - test_sleep(0, 300000000); + test_sleep(0, 3000000000); if (res != thr_arr[0]) { CU_FAIL("tpt_ev_add_args(TP_EV_TIMER) - not work") /* Fail. */ LOG_CONS_INFO_FMT("%i", (int)thr_arr[0]); diff --git a/tests/threadpool/test-threadpool.project b/tests/threadpool/test-threadpool.project index 2e17bdb..18fd5bb 100644 --- a/tests/threadpool/test-threadpool.project +++ b/tests/threadpool/test-threadpool.project @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ - +