order_3pl #188

Merged
peri4 merged 3 commits from order_3pl into master 2025-08-13 13:27:08 +03:00
37 changed files with 36 additions and 20 deletions

View File

@@ -91,6 +91,7 @@ set(HDR_DIRS)
set(PIP_UTILS_LIST)
set(PIP_TESTS_LIST)
set(PIP_EXPORTS)
set(PIP_3PL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rd")
set(PIP_SRC_MODULES "console;crypt;compress;usb;fftw;opencl;io_utils;client_server;cloud;lua;http_client;http_server")
foreach(_m ${PIP_SRC_MODULES})
@@ -106,7 +107,7 @@ macro(pip_module NAME LIBS LABEL INCLUDES SOURCES MSG)
set(CRES)
file(GLOB_RECURSE CPPS "libs/${NAME}/*.cpp" "libs/${NAME}/*.c")
file(GLOB_RECURSE HS "libs/${NAME}/*.h")
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h" "libs/${NAME}/3rd/*.h")
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h")
file(GLOB_RECURSE RES "libs/${NAME}/*.conf")
if (NOT "x${PHS}" STREQUAL "x")
list(REMOVE_ITEM HS ${PHS})
@@ -207,7 +208,6 @@ set(PIP_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}")
foreach(F ${PIP_FOLDERS})
if (IS_DIRECTORY "${F}")
list(APPEND PIP_INCLUDES "${F}")
#include_directories("${F}")
endif()
endforeach(F)
@@ -366,12 +366,10 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "" "")
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "${PIP_3PL_DIR}/BLAKE2" "")
generate_export_header(pip)
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
file(GLOB_RECURSE _RM_HDRS "libs/main/digest/3rd/*.h")
list(REMOVE_ITEM HDRS ${_RM_HDRS})
foreach(_m ${PIP_SRC_MODULES})
set_target_properties(pip PROPERTIES DEFINE_SYMBOL pip_${_m}_EXPORTS)
generate_export_header(pip BASE_NAME "pip_${_m}")
@@ -497,15 +495,16 @@ if (NOT CROSSTOOLS)
if (PIP_BUILD_LUA)
# Lua module
set(_lua_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/3rd/lua")
set(_lua_bri_dir "${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd")
set(_lua_src_dir "${PIP_3PL_DIR}/lua")
set(_lua_src_hdr "${_lua_src_dir}/lua.hpp" "${_lua_src_dir}/lua.h" "${_lua_src_dir}/luaconf.h" "${_lua_src_dir}/lualib.h")
pip_module(lua "" "PIP Lua support" "${_lua_src_dir};${_lua_bri_dir}" "${_lua_src_dir}" " (internal)")
target_include_directories(pip_lua PUBLIC "${_lua_src_dir}" "${_lua_bri_dir}")
pip_module(lua "" "PIP Lua support" "${_lua_src_dir};${PIP_3PL_DIR}" "${_lua_src_dir}" " (internal)")
target_include_directories(pip_lua PUBLIC "${_lua_src_dir}")
if (WIN32)
target_compile_definitions(pip_lua PRIVATE LUA_BUILD_AS_DLL LUA_CORE)
else()
target_compile_definitions(pip_lua PRIVATE LUA_USE_POSIX)
endif()
list(APPEND HDR_DIRS "${_lua_bri_dir}/LuaBridge")
list(APPEND HDR_DIRS "${PIP_3PL_DIR}/LuaBridge")
list(APPEND HDRS ${_lua_src_hdr})
endif()
@@ -710,7 +709,7 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"")
set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"")
set(DOXY_LOGO_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/pip.png\"")
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd\"")
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/3rd\"")
set(DOXY_DOMAIN "${PIP_DOMAIN}.${PROJECT_NAME}.doc")
if ("x${DOC_LANG}" STREQUAL "x")
set(DOXY_OUTPUT_LANGUAGE English)

View File

@@ -176,14 +176,16 @@ bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
PIString tp;
#ifdef WINDOWS
tp = PIDir::temporary().path() + PIDir::separator + "file" + PIString::fromNumber(randomi());
#else
char * rc = tmpnam(0);
if (!rc) return false;
tp = rc;
#endif
while (isExists(tp)) {
tp += PIString::fromNumber(randomi() % 10);
}
#else
char template_rc[] = "/tmp/pifile_tmp_XXXXXX";
int fd = mkstemp(template_rc);
if (fd == -1) return false;
::close(fd);
tp = template_rc;
#endif
return open(tp, mode);
}

View File

@@ -35,3 +35,4 @@ pip_test(math)
pip_test(core)
pip_test(piobject)
pip_test(client_server pip_client_server)
pip_test(io)

View File

@@ -102,7 +102,7 @@ int getClientsPings(const PIVector<ClientSendThread *> & clients) {
TEST(ClientServer, ManyClients) {
auto const loop_timeout = 1000_ms;
auto const loop_timeout = 100_ms;
constexpr int clients_count = 20;
PIVector<ClientSendThread *> clients;
auto s = createServer<false, false, 100_KiB>();
@@ -147,7 +147,7 @@ TEST(ClientServer, ManyClients) {
}
TEST(ClientServer, DynamicClients) {
auto const loop_timeout = 1000_ms;
auto const loop_timeout = 100_ms;
constexpr int clients_count = 20;
PIVector<ClientSendThread *> clients;
PIMutex clients_mutex;

14
tests/io/testpifile.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "pifile.h"
#include "gtest/gtest.h"
TEST(PIFile_Test, openTemporary) {
const auto ba = PIByteArray::fromHex("AABBCC");
PIFile f;
ASSERT_TRUE(f.openTemporary());
ASSERT_TRUE(f.path().isNotEmpty());
ASSERT_EQ(ba.size(), f.write(ba));
ASSERT_EQ(ba, f.readAll());
ASSERT_TRUE(f.close());
}

View File

@@ -351,7 +351,7 @@ TEST(PIMathMatrixT_Test, determinantIfSquare) {
matr.element(2, 1) = 2;
matr.element(2, 2) = 5;
d = matr.determinant();
EXPECT_DOUBLE_EQ(std::abs(i - d), 0.);
EXPECT_NEAR(std::abs(i - d), 0., 1e-12);
}
TEST(PIMathMatrixT_Test, invert) {
@@ -400,7 +400,7 @@ TEST(PIMathMatrixT_Test, inverted) {
d2 = matrix2.determinant();
matrix3 = matrix1.inverted();
EXPECT_EQ(matrix1, matrix3);
EXPECT_DOUBLE_EQ(std::abs(d1 - (1. / d2)), 0.);
EXPECT_NEAR(std::abs(d1 - (1. / d2)), 0., 1e-12);
}
TEST(PIMathMatrixT_Test, toUpperTriangular) {