Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit b311f9f

Browse files
author
Ingvord
authored
Backport #275: split runner (#476)
* close #275 * Backport a5f30ba: old_tests::polling -> cxx_old_poll [5min] * Backport #331: Refactor event_reconnection.sh to cxx test; fix missing test - cxx_old_poll [30min] * Backport #275 [5min]
1 parent fbc9707 commit b311f9f

22 files changed

+2034
-3070
lines changed
Lines changed: 93 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,97 @@
1-
message("Generate runner.cpp")
1+
find_package (Threads REQUIRED)
22

3-
execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_DIR}/template/tango_template.tpl
4-
-o ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp
5-
../../new_tests/cxx_syntax.cpp
6-
../../new_tests/cxx_poll.cpp
7-
../../new_tests/cxx_poll_admin.cpp
8-
../../new_tests/cxx_dserver_cmd.cpp
9-
../../new_tests/cxx_dserver_misc.cpp
10-
../../new_tests/cxx_always_hook.cpp
11-
../../new_tests/cxx_blackbox.cpp
12-
../../new_tests/cxx_class_dev_signal.cpp
13-
../../new_tests/cxx_class_signal.cpp
14-
../../new_tests/cxx_attr_misc.cpp
15-
../../new_tests/cxx_attrprop.cpp
16-
../../new_tests/cxx_attr_write.cpp
17-
../../new_tests/cxx_attr_conf.cpp
18-
../../new_tests/cxx_attr.cpp
19-
../../new_tests/cxx_misc_util.cpp
20-
../../new_tests/cxx_templ_cmd.cpp
21-
../../new_tests/cxx_exception.cpp
22-
../../new_tests/cxx_cmd_query.cpp
23-
../../new_tests/cxx_seq_vec.cpp
24-
../../new_tests/cxx_signal.cpp
25-
../../new_tests/cxx_test_state_on.cpp
26-
../../new_tests/cxx_misc.cpp
27-
../../new_tests/cxx_cmd_types.cpp
28-
../../new_tests/cxx_group.cpp
29-
../../new_tests/cxx_encoded.cpp
30-
../../new_tests/cxx_database.cpp
31-
../../new_tests/cxx_mem_attr.cpp
32-
../../new_tests/cxx_enum_att.cpp
33-
../../new_tests/cxx_write_attr_hard.cpp
34-
../../new_tests/cxx_fwd_att.cpp
35-
../../new_tests/cxx_pipe_conf.cpp
36-
../../new_tests/cxx_pipe.cpp
37-
../../new_tests/cxx_z00_dyn_cmd.cpp
38-
../../new_tests/cxx_nan_inf_in_prop.cpp
3+
macro(CXX_GENERATE_TEST name)
4+
message("Generate ${name}.cpp")
5+
execute_process(COMMAND python cxxtestgen.py --template=${CMAKE_CURRENT_SOURCE_DIR}/template/tango_template.tpl
6+
-o ${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp
7+
../../new_tests/${name}.cpp
8+
../../new_tests/cxx_nan_inf_in_prop.cpp
399
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
4010

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

46-
add_test("CXX::runner" runner
47-
--device1=${DEV1}
48-
--device2=${DEV2}
49-
--device3=${DEV3}
50-
--fwd_device=${FWD_DEV}
51-
--loop=1
52-
--fulldsname=${SERV_NAME}/${INST_NAME}
53-
--serverhost=${HOST_NAME}
54-
--clienthost=${HOST_NAME}
55-
--serverversion=5
56-
--docurl=http://www.tango-controls.org
57-
--devtype=TestDevice
58-
--dbserver=sys/database/2
59-
--outpath=/tmp/
60-
--refpath=${CMAKE_CURRENT_SOURCE_DIR}/../new_tests/out/
61-
--loglevel=0
62-
--dsloglevel=5
63-
--suiteloop=1
64-
--devicealias=${DEV1_ALIAS}
65-
--attributealias=${ATTR_ALIAS}
66-
--verbose=true
67-
)
15+
add_executable(${name} $<TARGET_OBJECTS:compare_test_object> ${name}.cpp)
16+
target_include_directories(${name} PRIVATE include ${CMAKE_CURRENT_BINARY_DIR}/include)
17+
target_link_libraries(${name} PRIVATE tango ${CMAKE_THREAD_LIBS_INIT})
18+
target_compile_definitions(${name} PRIVATE "-DVALGRIND -D_PTHREADS -D_REENTRANT")
19+
20+
add_test(NAME "CXX::${name}" COMMAND $<TARGET_FILE:${name}>
21+
--device1=${DEV1}
22+
--device2=${DEV2}
23+
--device3=${DEV3}
24+
--device20=${DEV20}
25+
--fwd_device=${FWD_DEV}
26+
--loop=1
27+
--fulldsname=${SERV_NAME}/${INST_NAME}
28+
--serverhost=${HOST_NAME}
29+
--clienthost=${HOST_NAME}
30+
--serverversion=5
31+
--docurl=http://www.tango-controls.org
32+
--devtype=TestDevice
33+
--dbserver=sys/database/2
34+
--outpath=/tmp/
35+
--refpath=${CMAKE_CURRENT_SOURCE_DIR}/../new_tests/out/
36+
--loglevel=0
37+
--dsloglevel=5
38+
--suiteloop=1
39+
--devicealias=${DEV1_ALIAS}
40+
--attributealias=${ATTR_ALIAS}
41+
--verbose=true)
42+
endmacro()
43+
44+
CXX_GENERATE_TEST(cxx_syntax)
45+
CXX_GENERATE_TEST(cxx_poll)
46+
CXX_GENERATE_TEST(cxx_poll_admin)
47+
CXX_GENERATE_TEST(cxx_dserver_cmd)
48+
CXX_GENERATE_TEST(cxx_dserver_misc)
49+
CXX_GENERATE_TEST(cxx_always_hook)
50+
CXX_GENERATE_TEST(cxx_blackbox)
51+
CXX_GENERATE_TEST(cxx_class_dev_signal)
52+
CXX_GENERATE_TEST(cxx_class_signal)
53+
CXX_GENERATE_TEST(cxx_attr_misc)
54+
CXX_GENERATE_TEST(cxx_attrprop)
55+
CXX_GENERATE_TEST(cxx_attr_write)
56+
CXX_GENERATE_TEST(cxx_attr_conf)
57+
CXX_GENERATE_TEST(cxx_attr)
58+
CXX_GENERATE_TEST(cxx_misc_util)
59+
CXX_GENERATE_TEST(cxx_templ_cmd)
60+
CXX_GENERATE_TEST(cxx_exception)
61+
CXX_GENERATE_TEST(cxx_cmd_query)
62+
CXX_GENERATE_TEST(cxx_seq_vec)
63+
CXX_GENERATE_TEST(cxx_signal)#TODO Windows
64+
CXX_GENERATE_TEST(cxx_test_state_on)
65+
CXX_GENERATE_TEST(cxx_misc)
66+
CXX_GENERATE_TEST(cxx_cmd_types)
67+
CXX_GENERATE_TEST(cxx_group)
68+
CXX_GENERATE_TEST(cxx_encoded)
69+
CXX_GENERATE_TEST(cxx_database)
70+
CXX_GENERATE_TEST(cxx_mem_attr)
71+
CXX_GENERATE_TEST(cxx_enum_att)
72+
CXX_GENERATE_TEST(cxx_write_attr_hard)
73+
CXX_GENERATE_TEST(cxx_fwd_att)
74+
CXX_GENERATE_TEST(cxx_pipe_conf)
75+
CXX_GENERATE_TEST(cxx_pipe)
76+
CXX_GENERATE_TEST(cxx_z00_dyn_cmd)
77+
CXX_GENERATE_TEST(cxx_old_poll)
78+
CXX_GENERATE_TEST(cxx_server_event)
79+
CXX_GENERATE_TEST(cxx_reconnection_zmq)
80+
CXX_GENERATE_TEST(cxx_stateless_subscription)
81+
82+
83+
#utilities
84+
configure_file(bin/start_server.sh.cmake ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/start_server.sh @ONLY)
85+
configure_file(bin/kill_server.sh.cmake ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kill_server.sh @ONLY)
86+
87+
# now copy the temporary into the final destination, setting the permissions
88+
file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/start_server.sh
89+
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin
90+
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
91+
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
92+
file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kill_server.sh
93+
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin
94+
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
95+
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
96+
97+
configure_file(include/config.h.cmake include/config.h @ONLY)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
kill_servers(){
4+
PIDS=`ps -e | grep DevTest | grep -v grep | awk '{print $1}'`
5+
echo "PIDS = $PIDS"
6+
for pid in $PIDS
7+
do
8+
echo "Killing process with PID $pid"
9+
kill $pid
10+
done
11+
12+
sleep 2
13+
}
14+
15+
kill_servers
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
start_server(){
4+
echo "Starting DevTest $1"
5+
@PROJECT_BINARY_DIR@/cpp_test_ds/DevTest $1 -v5 1>@PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.out 2>&1 &
6+
echo $! > @PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.pid
7+
8+
sleep 7
9+
echo "Done. PID="`cat @PROJECT_BINARY_DIR@/cpp_test_ds/DevTest_$1.pid`
10+
}
11+
12+
start_server $1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef Config_h
2+
#define Config_h
3+
4+
#include <string>
5+
6+
namespace Tango {
7+
const std::string kProjectBinaryDir{"@PROJECT_BINARY_DIR@"};
8+
const std::string kStartServerCmd{"@CMAKE_CURRENT_BINARY_DIR@/bin/start_server.sh "};
9+
const std::string kKillServerCmd{"@CMAKE_CURRENT_BINARY_DIR@/bin/kill_server.sh"};
10+
}
11+
12+
#endif

cpp_test_suite/cxxtest/include/cxxtest/TangoPrinter.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <string>
2828
#include <string.h>
2929
#include <map>
30+
#include <config.h>
31+
#include <cstdlib>
3032

3133
// Tango exceptions handling
3234
//#undef _TS_CATCH_ABORT
@@ -761,6 +763,7 @@ class TangoPrinter: public ErrorFormatter
761763
params_tmp["device1"] = param_desc("--device1=", "device1 name, e.g. test/device/1");
762764
params_tmp["device2"] = param_desc("--device2=", "device2 name, e.g. test/device/2");
763765
params_tmp["device3"] = param_desc("--device3=", "device3 name, e.g. test/device/3");
766+
params_tmp["device20"] = param_desc("--device20=", "device20 name, e.g. test2/debian8/20");
764767
params_tmp["fulldsname"] = param_desc("--fulldsname=", "full device server name, e.g. devTest/myserver");
765768
params_tmp["clienthost"] = param_desc("--clienthost=",
766769
"client host's fully qualified domain name, e.g. mypc.myinstitute.com (small caps)");
@@ -783,6 +786,16 @@ class TangoPrinter: public ErrorFormatter
783786
return params_tmp;
784787
}
785788

789+
static void start_server(const std::string& instance){
790+
std::string command = Tango::kStartServerCmd;
791+
command += instance;
792+
system(command.c_str());
793+
}
794+
795+
static void kill_server() {
796+
system(Tango::kKillServerCmd.c_str());
797+
}
798+
786799
private:
787800
class Adapter: public OutputStream
788801
{

cpp_test_suite/event/CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ set(TESTS archive_event
1818
data_ready_event_buffer
1919
dev_intr_event
2020
multi_dev_event
21-
per_event
22-
# reco_event
23-
reco_zmq
24-
server_event
25-
stateless_sub)
21+
per_event)
2622

2723
foreach(TEST ${TESTS})
2824
TEST_SUITE_ADD_TEST(${TEST})
@@ -44,11 +40,4 @@ add_test(NAME "event::data_ready_event_buffer" COMMAND $<TARGET_FILE:data_ready
4440
add_test(NAME "event::multi_dev_event" COMMAND $<TARGET_FILE:multi_dev_event> ${DEV1} ${DEV2} ${DEV3})
4541
add_test(NAME "event::dev_intr_event" COMMAND $<TARGET_FILE:dev_intr_event> ${DEV1})
4642
add_test(NAME "event::pipe_event" COMMAND $<TARGET_FILE:pipe_event> ${DEV1})
47-
add_test(NAME "event::event_lock" COMMAND $<TARGET_FILE:event_lock> ${DEV1})
48-
49-
50-
#the following test performs several kill/start sequences, but must keep DEV1 alive in the end
51-
configure_file(test_reconnection.sh.cmake test_reconnection.sh @ONLY)
52-
execute_process(COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/test_reconnection.sh)
53-
add_test(NAME "event::reconnect" COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_reconnection.sh
54-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
43+
add_test(NAME "event::event_lock" COMMAND $<TARGET_FILE:event_lock> ${DEV1})

0 commit comments

Comments
 (0)