Skip to content

Commit a95c8d4

Browse files
authored
Merge pull request #130 from Flow-IPC/tkt-flow-94_should-log-perf
Flow has gained a unit test suite similar to Flow-IPC and now houses various common test utilities, so they are removed here, and instead we reuse them from their new location in Flow. / In test/demo programs using the new (albeit optional) flow::log::Config::init_component_to_union_idx_mapping() arg in the now-recommended way.
2 parents d0925cd + 285ded7 commit a95c8d4

File tree

13 files changed

+40
-94
lines changed

13 files changed

+40
-94
lines changed

conanfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def requirements(self):
125125
flow_version = load_version_from_file("./flow/VERSION")
126126
self.requires("capnproto/1.0.1")
127127
self.requires(f"flow/{flow_version}")
128-
self.requires("gtest/1.14.0")
129128
self.requires("jemalloc/5.2.1")
130129

131130
def build_requirements(self):

flow

Submodule flow updated 1360 files

ipc_session

ipc_shm

test/suite/perf_demo/common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ void setup_logging(std::optional<flow::log::Simple_ostream_logger>* std_logger,
9494
// Console logger setup.
9595
static Config std_log_config;
9696
std_log_config.init_component_to_union_idx_mapping<Flow_log_component>
97-
(1000, Config::standard_component_payload_enum_sparse_length<Flow_log_component>());
97+
(1000, Config::standard_component_payload_enum_sparse_length<Flow_log_component>(), true);
9898
std_log_config.init_component_to_union_idx_mapping<ipc::Log_component>
99-
(2000, Config::standard_component_payload_enum_sparse_length<ipc::Log_component>());
99+
(2000, Config::standard_component_payload_enum_sparse_length<ipc::Log_component>(), true);
100100
std_log_config.init_component_names<Flow_log_component>(flow::S_FLOW_LOG_COMPONENT_NAME_MAP, false, "flow-");
101101
std_log_config.init_component_names<ipc::Log_component>(ipc::S_IPC_LOG_COMPONENT_NAME_MAP, false, "ipc-");
102102
std_logger->emplace(&std_log_config);

test/suite/unit_test/CMakeLists.txt

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,14 @@
1515
# See the License for the specific language governing
1616
# permissions and limitations under the License.
1717

18-
# We'll need Google's unit-test framework, so let's find that.
19-
block()
20-
set(lib_name "gtest")
21-
# Search for static lib specifically. TODO: Is this needed really? Being paranoid here?
22-
if(UNIX)
23-
set(lib_name "lib${lib_name}.a")
24-
else()
25-
message(FATAL_ERROR "Unsupported OS; please modify script to search for static lib Windows-style.")
26-
endif()
27-
find_library(GTEST_LIB NAMES ${lib_name})
28-
if(NOT GTEST_LIB)
29-
message(FATAL_ERROR
30-
"Could not find Google unit-test gtest library ([${lib_name}]) location via CMake uber-searcher "
31-
"find_library(). Do not fret: Please build gtest if not yet done and try again; "
32-
"if it is still not found then please supply the full path to the library file (including "
33-
"the file itself) as the CMake knob (cache setting) GTEST_LIB.")
34-
endif()
35-
message(VERBOSE "CMake uber-searcher find_library() located Google unit-test gtest lib (see below); "
36-
"though you can override this via cache setting.")
37-
38-
# Search for its include-root.
39-
find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h)
40-
if(NOT GTEST_INCLUDE_DIR)
41-
message(FATAL_ERROR
42-
"Could not find Google unit-test gtest/*.h include-path via CMake uber-searcher "
43-
"find_path(gtest/gtest.h). Do not fret: Please build gtest if not yet done and try again; "
44-
"if it is still not found then please supply the full path to gtest/gtest.h (excluding the "
45-
"directory and file themselves) as the CMake knob (cache setting) GTEST_INCLUDE_DIR.")
46-
endif()
47-
48-
# Note: These days Google's unit-test framework, at least when built with CMake, exports
49-
# the stuff needed to just do find_package(GTest). We could use that above, as we do for Cap'n Proto
50-
# and others. However I (ygoldfel) have it on good authority that people build the notoriously easy-to-build
51-
# GTest in a myriad ways, and this find_package() support may not be produced. So we go with the
52-
# naughty more-manual way above.
53-
endblock()
54-
55-
message(STATUS "Google unit-test gtest lib location: [${GTEST_LIB}].")
18+
include("${FLOW_LIKE_META_ROOT_flow}/tools/cmake/FlowLikeLoadGoogleTest.cmake")
19+
# See instructions in that file re. mechanics and conventions of GoogleTest-using programs;
20+
# we shall declare a few now. GTEST_LIB and GTEST_INCLUDE_DIR are set for us.
5621

5722
# This test requires some little silly capnp schemas.
5823
find_package(CapnProto CONFIG REQUIRED)
5924

6025
# Test program: unit_test.
61-
# Unit tests are built on Google's unit-test framework. The conventions we use are roughly as follows.
62-
# - The unit test files shall be interspersed together with the code of the various libraries libipc_*,
63-
# albeit always in directories named test/.
64-
# - In addition the needed program driver(s) (i.e., guys with main()), in the root namespace, shall *not* be
65-
# so interspersed but rather will live separately under unit_test/ (here).
66-
# - Let `class X` in namespace N (so N::X) be located in D/X.hpp (at least), where D is a directory usually
67-
# corresponding to namespace N (more or less).
68-
# - Its unit test might be then called X_test and shall reside in namespace N::test::X_test.
69-
# Its source code shall be in D/test/X_test.cpp.
70-
# - Any supporting code outside of that file can be anywhere under D/test, in files named `test_*.hpp` and
71-
# `test_*.cpp`; a convention might be to start with `test_X.?pp`, though even more support files may also
72-
# be present.
73-
# - For support files like this potentially applicable to ~all unit tests, they shall live in ipc::test
74-
# and therefore ipc/test/.
75-
#
76-
# The relevant translation units (.cpp, .capnp -> .c++) shall be listed directly below, in normal CMake fashion,
77-
# under the relevant unit-test executables. We do not make an intermediate libtest* or anything like that;
78-
# the relevant object files are compiled directly from their relevant source files. (This is pretty common
79-
# when using the GOogle unit-test framework.) Do note, again, that those relevant source files are directly
80-
# under the sub-projects' source trees: ipc_*/src/.../test/....
81-
#
82-
# This executable, libipc_unit_test, is the compendium of unit tests to execute.
83-
# In addition there are more executables which it will itself run as needed as part of certain specific unit tests.
84-
# These are built below.
8526

8627
# Test program libipc_test_borrower.exec: executed by ipc/shm/arena_lend/jemalloc/test/shm_pool_collection_test.
8728

@@ -123,9 +64,9 @@ endfunction()
12364
set(isal_root ${FLOW_LIKE_META_ROOT_ipc_shm_arena_lend}/src)
12465

12566
set(SRCS
67+
${FLOW_LIKE_META_ROOT_flow}/src/flow/test/test_common_util.cpp
68+
${FLOW_LIKE_META_ROOT_flow}/src/flow/test/test_file_util.cpp
12669
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_common_util.cpp
127-
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_config.cpp
128-
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_file_util.cpp
12970
${isal_root}/ipc/session/standalone/shm/arena_lend/jemalloc/test/shm_session_test.cpp
13071
${isal_root}/ipc/session/standalone/shm/arena_lend/jemalloc/test/test_shm_session_server.cpp
13172
${isal_root}/ipc/session/standalone/shm/arena_lend/jemalloc/test/test_shm_session_server_executor.cpp
@@ -163,16 +104,16 @@ set(CAPNP_SCHEMAS
163104
handle_binary(libipc_unit_test.exec)
164105

165106
set(SRCS
166-
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_common_util.cpp
167-
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_config.cpp
107+
${FLOW_LIKE_META_ROOT_flow}/src/flow/test/test_common_util.cpp
168108
${isal_root}/ipc/shm/arena_lend/test/test_borrower.cpp
169109
test_borrower_main.cpp)
170110
unset(CAPNP_SCHEMAS)
171111
handle_binary(libipc_test_borrower.exec)
172112

173113
set(SRCS
114+
${FLOW_LIKE_META_ROOT_flow}/src/flow/test/test_common_util.cpp
115+
${FLOW_LIKE_META_ROOT_flow}/src/flow/test/test_file_util.cpp
174116
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_common_util.cpp
175-
${FLOW_LIKE_META_ROOT_ipc_core}/src/ipc/test/test_file_util.cpp
176117
${isal_root}/ipc/session/standalone/shm/arena_lend/jemalloc/test/test_shm_session_server_executor.cpp
177118
${isal_root}/ipc/session/standalone/shm/arena_lend/jemalloc/test/test_shm_session_server.cpp
178119
${isal_root}/ipc/shm/arena_lend/test/test_shm_object.cpp

test/suite/unit_test/sanitize/tsan/suppressions_clang.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# Had some issues matching ^ and $ in this one; leaving them out at times; these are very unlikely to match something
2121
# unintentional.
2222

23+
# Maintenance note: The below suppression is similarly in Flow's flow/.../unit_test/sanitize/....
24+
# If this is changed, then consider the other one; and vice versa.
25+
2326
# This suppression eliminates a rather large (in our context) number of warnings. Each warning can be, as of this
2427
# writing, classified as type A and type B, where type A is by far more common (e.g., 10:1 or so).
2528
#
@@ -48,7 +51,7 @@
4851
# the test code is (when it comes down to it) accessing std::cout concurrently from multiple threads.
4952
# Formally speaking this is documented in Flow to be allowed, in the sense that it won't lead to undefined behavior
5053
# (crashing, etc.); but also recommended-against, because concurrent access to an ostream is liable to result in
51-
# qualtitatively unpleasant output: interleaved text, sometimes confusing formatting, etc. Indeed this is a known
54+
# qualitatively unpleasant output: interleaved text, sometimes confusing formatting, etc. Indeed this is a known
5255
# problem as of this writing; I have noticed that during parallelization-involving tests, the logs can be
5356
# (in spots) quite unpleasant to read; and I've made a @todo to that effect (also read on). (I speculate that
5457
# my colleague is aware of it too; it just was not a top-priority concern, as the related unit tests did their

0 commit comments

Comments
 (0)