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
156 changes: 93 additions & 63 deletions cpp_test_suite/cxxtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,97 @@
message("Generate runner.cpp")
find_package (Threads REQUIRED)

execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_DIR}/template/tango_template.tpl
-o ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp
../../new_tests/cxx_syntax.cpp
../../new_tests/cxx_poll.cpp
../../new_tests/cxx_poll_admin.cpp
../../new_tests/cxx_dserver_cmd.cpp
../../new_tests/cxx_dserver_misc.cpp
../../new_tests/cxx_always_hook.cpp
../../new_tests/cxx_blackbox.cpp
../../new_tests/cxx_class_dev_signal.cpp
../../new_tests/cxx_class_signal.cpp
../../new_tests/cxx_attr_misc.cpp
../../new_tests/cxx_attrprop.cpp
../../new_tests/cxx_attr_write.cpp
../../new_tests/cxx_attr_conf.cpp
../../new_tests/cxx_attr.cpp
../../new_tests/cxx_misc_util.cpp
../../new_tests/cxx_templ_cmd.cpp
../../new_tests/cxx_exception.cpp
../../new_tests/cxx_cmd_query.cpp
../../new_tests/cxx_seq_vec.cpp
../../new_tests/cxx_signal.cpp
../../new_tests/cxx_test_state_on.cpp
../../new_tests/cxx_misc.cpp
../../new_tests/cxx_cmd_types.cpp
../../new_tests/cxx_group.cpp
../../new_tests/cxx_encoded.cpp
../../new_tests/cxx_database.cpp
../../new_tests/cxx_mem_attr.cpp
../../new_tests/cxx_enum_att.cpp
../../new_tests/cxx_write_attr_hard.cpp
../../new_tests/cxx_fwd_att.cpp
../../new_tests/cxx_pipe_conf.cpp
../../new_tests/cxx_pipe.cpp
../../new_tests/cxx_z00_dyn_cmd.cpp
../../new_tests/cxx_nan_inf_in_prop.cpp
macro(CXX_GENERATE_TEST name)
message("Generate ${name}.cpp")
execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_DIR}/template/tango_template.tpl
-o ${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp
../../new_tests/${name}.cpp
../../new_tests/cxx_nan_inf_in_prop.cpp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

add_executable(runner $<TARGET_OBJECTS:compare_test_object> ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp)
target_include_directories(runner PUBLIC include)
target_link_libraries(runner PUBLIC tango ${CMAKE_DL_LIBS})
target_compile_definitions(runner PUBLIC "-DVALGRIND -D_PTHREADS -D_REENTRANT")
if(${FAILED})
message(SEND_ERROR " Failed to generate ${name}.cpp. rv=${FAILED}")
endif()

add_test("CXX::runner" runner
--device1=${DEV1}
--device2=${DEV2}
--device3=${DEV3}
--fwd_device=${FWD_DEV}
--loop=1
--fulldsname=${SERV_NAME}/${INST_NAME}
--serverhost=${HOST_NAME}
--clienthost=${HOST_NAME}
--serverversion=5
--docurl=http://www.tango-controls.org
--devtype=TestDevice
--dbserver=sys/database/2
--outpath=/tmp/
--refpath=${CMAKE_CURRENT_SOURCE_DIR}/../new_tests/out/
--loglevel=0
--dsloglevel=5
--suiteloop=1
--devicealias=${DEV1_ALIAS}
--attributealias=${ATTR_ALIAS}
--verbose=true
)
add_executable(${name} $<TARGET_OBJECTS:compare_test_object> ${name}.cpp)
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}
--serverhost=${HOST_NAME}
--clienthost=${HOST_NAME}
--serverversion=5
--docurl=http://www.tango-controls.org
--devtype=TestDevice
--dbserver=sys/database/2
--outpath=/tmp/
--refpath=${CMAKE_CURRENT_SOURCE_DIR}/../new_tests/out/
--loglevel=0
--dsloglevel=5
--suiteloop=1
--devicealias=${DEV1_ALIAS}
--attributealias=${ATTR_ALIAS}
--verbose=true)
endmacro()

CXX_GENERATE_TEST(cxx_syntax)
CXX_GENERATE_TEST(cxx_poll)
CXX_GENERATE_TEST(cxx_poll_admin)
CXX_GENERATE_TEST(cxx_dserver_cmd)
CXX_GENERATE_TEST(cxx_dserver_misc)
CXX_GENERATE_TEST(cxx_always_hook)
CXX_GENERATE_TEST(cxx_blackbox)
CXX_GENERATE_TEST(cxx_class_dev_signal)
CXX_GENERATE_TEST(cxx_class_signal)
CXX_GENERATE_TEST(cxx_attr_misc)
CXX_GENERATE_TEST(cxx_attrprop)
CXX_GENERATE_TEST(cxx_attr_write)
CXX_GENERATE_TEST(cxx_attr_conf)
CXX_GENERATE_TEST(cxx_attr)
CXX_GENERATE_TEST(cxx_misc_util)
CXX_GENERATE_TEST(cxx_templ_cmd)
CXX_GENERATE_TEST(cxx_exception)
CXX_GENERATE_TEST(cxx_cmd_query)
CXX_GENERATE_TEST(cxx_seq_vec)
CXX_GENERATE_TEST(cxx_signal)#TODO Windows
CXX_GENERATE_TEST(cxx_test_state_on)
CXX_GENERATE_TEST(cxx_misc)
CXX_GENERATE_TEST(cxx_cmd_types)
CXX_GENERATE_TEST(cxx_group)
CXX_GENERATE_TEST(cxx_encoded)
CXX_GENERATE_TEST(cxx_database)
CXX_GENERATE_TEST(cxx_mem_attr)
CXX_GENERATE_TEST(cxx_enum_att)
CXX_GENERATE_TEST(cxx_write_attr_hard)
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_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 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 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 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
13 changes: 13 additions & 0 deletions 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 @@ -761,6 +763,7 @@ class TangoPrinter: public ErrorFormatter
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)");
Expand All @@ -783,6 +786,16 @@ class TangoPrinter: public ErrorFormatter
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 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