Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions test/cpp_test_suite/cxxtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package (Threads REQUIRED)

macro(CXX_GENERATE_TEST name)
message("Generate ${name}.cpp")
execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_DIR}/template/tango_template.tpl
Expand All @@ -11,14 +13,15 @@ macro(CXX_GENERATE_TEST name)
endif()

add_executable(${name} $<TARGET_OBJECTS:compare_test_object> ${name}.cpp)
target_include_directories(${name} PRIVATE include)
target_link_libraries(${name} PRIVATE tango)
target_include_directories(${name} PRIVATE include ${CMAKE_CURRENT_BINARY_DIR}/include)
target_link_libraries(${name} PRIVATE tango ${CMAKE_THREAD_LIBS_INIT})
target_compile_definitions(${name} PRIVATE "-DVALGRIND -D_PTHREADS -D_REENTRANT")

add_test(NAME "CXX::${name}" COMMAND $<TARGET_FILE:${name}>
--device1=${DEV1}
--device2=${DEV2}
--device3=${DEV3}
--device20=${DEV20}
--fwd_device=${FWD_DEV}
--loop=1
--fulldsname=${SERV_NAME}/${INST_NAME}
Expand Down Expand Up @@ -71,4 +74,24 @@ CXX_GENERATE_TEST(cxx_fwd_att)
CXX_GENERATE_TEST(cxx_pipe_conf)
CXX_GENERATE_TEST(cxx_pipe)
CXX_GENERATE_TEST(cxx_z00_dyn_cmd)
CXX_GENERATE_TEST(cxx_old_poll)
CXX_GENERATE_TEST(cxx_old_poll)
CXX_GENERATE_TEST(cxx_server_event)
CXX_GENERATE_TEST(cxx_reconnection_zmq)
CXX_GENERATE_TEST(cxx_stateless_subscription)


#utilities
configure_file(bin/start_server.sh.cmake ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/start_server.sh @ONLY)
configure_file(bin/kill_server.sh.cmake ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kill_server.sh @ONLY)

# now copy the temporary into the final destination, setting the permissions
file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/start_server.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kill_server.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

configure_file(include/config.h.cmake include/config.h @ONLY)
15 changes: 15 additions & 0 deletions test/cpp_test_suite/cxxtest/bin/kill_server.sh.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

kill_servers(){
PIDS=`ps -e | grep DevTest | grep -v grep | awk '{print $1}'`
echo "PIDS = $PIDS"
for pid in $PIDS
do
echo "Killing process with PID $pid"
kill $pid
done

sleep 2
}

kill_servers
12 changes: 12 additions & 0 deletions test/cpp_test_suite/cxxtest/bin/start_server.sh.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

start_server(){
echo "Starting DevTest $1"
@PROJECT_BINARY_DIR@/cpp_test_ds/DevTest $1 -v5 1>@PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.out 2>&1 &
echo $! > @PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.pid

sleep 7
echo "Done. PID="`cat @PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.pid`
}

start_server $1
12 changes: 12 additions & 0 deletions test/cpp_test_suite/cxxtest/include/config.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef Config_h
#define Config_h

#include <string>

namespace Tango {
const std::string kProjectBinaryDir{"@PROJECT_BINARY_DIR@"};
const std::string kStartServerCmd{"@CMAKE_CURRENT_BINARY_DIR@/bin/start_server.sh "};
const std::string kKillServerCmd{"@CMAKE_CURRENT_BINARY_DIR@/bin/kill_server.sh"};
}

#endif
14 changes: 13 additions & 1 deletion test/cpp_test_suite/cxxtest/include/cxxtest/TangoPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <string>
#include <string.h>
#include <map>
#include <config.h>
#include <cstdlib>

// Tango exceptions handling
//#undef _TS_CATCH_ABORT
Expand Down Expand Up @@ -130,7 +132,6 @@ namespace CxxTest
* in case a test case fails before restoring these settings by itself
*/
static set<string> restore_points;

public:
TangoPrinter( CXXTEST_STD(ostream) &o = CXXTEST_STD(cout), const char *preLine = ":", const char *postLine = "" ) :
ErrorFormatter( new Adapter(o), preLine, postLine ) {}
Expand Down Expand Up @@ -748,6 +749,7 @@ namespace CxxTest
params_tmp["device1"] = param_desc("--device1=", "device1 name, e.g. test/device/1");
params_tmp["device2"] = param_desc("--device2=", "device2 name, e.g. test/device/2");
params_tmp["device3"] = param_desc("--device3=", "device3 name, e.g. test/device/3");
params_tmp["device20"] = param_desc("--device20=", "device20 name, e.g. test2/debian8/20");
params_tmp["fulldsname"] = param_desc("--fulldsname=", "full device server name, e.g. devTest/myserver");
params_tmp["clienthost"] = param_desc("--clienthost=", "client host's fully qualified domain name, e.g. mypc.myinstitute.com (small caps)");
params_tmp["serverhost"] = param_desc("--serverhost=", "fully qualified domain name of the host on which the server is running, e.g. myserver.myinstitute.com (small caps)");
Expand All @@ -764,6 +766,16 @@ namespace CxxTest
return params_tmp;
}

static void start_server(const std::string& instance){
std::string command = Tango::kStartServerCmd;
command += instance;
system(command.c_str());
}

static void kill_server() {
system(Tango::kKillServerCmd.c_str());
}

private:
class Adapter : public OutputStream
{
Expand Down
15 changes: 2 additions & 13 deletions test/cpp_test_suite/event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ set(TESTS archive_event
data_ready_event_buffer
dev_intr_event
multi_dev_event
per_event
# reco_event
reco_zmq
server_event
stateless_sub)
per_event)

foreach(TEST ${TESTS})
TEST_SUITE_ADD_TEST(${TEST})
Expand All @@ -44,11 +40,4 @@ add_test(NAME "event::data_ready_event_buffer" COMMAND $<TARGET_FILE:data_ready
add_test(NAME "event::multi_dev_event" COMMAND $<TARGET_FILE:multi_dev_event> ${DEV1} ${DEV2} ${DEV3})
add_test(NAME "event::dev_intr_event" COMMAND $<TARGET_FILE:dev_intr_event> ${DEV1})
add_test(NAME "event::pipe_event" COMMAND $<TARGET_FILE:pipe_event> ${DEV1})
add_test(NAME "event::event_lock" COMMAND $<TARGET_FILE:event_lock> ${DEV1})


#the following test performs several kill/start sequences, but must keep DEV1 alive in the end
configure_file(test_reconnection.sh.cmake test_reconnection.sh @ONLY)
execute_process(COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/test_reconnection.sh)
add_test(NAME "event::reconnect" COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_reconnection.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME "event::event_lock" COMMAND $<TARGET_FILE:event_lock> ${DEV1})
Loading