Skip to content
Snippets Groups Projects
Commit 37f55629 authored by Jonathan Hanks's avatar Jonathan Hanks
Browse files

Closes #128, the daqd exits if a gds broadcast list is specified with channels that do not exist.

parent 434f7180
No related branches found
No related tags found
1 merge request!123Closes #128, the daqd exits if a gds broadcast list is specified with channels that do not exist.
......@@ -181,6 +181,12 @@ add_test(NAME test_crc32_table_lookup
COMMAND test_crc32_table_lookup
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
configure_file(tests/daqdrc_broadcast_test ${CMAKE_CURRENT_BINARY_DIR}/daqdrc_broadcast_test COPYONLY)
configure_file(tests/test_daqd_stop_on_bad_broadcast_list.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test_daqd_stop_on_bad_broadcast_list.sh @ONLY)
add_test(NAME test_daqd_stop_on_bad_broadcast_list
COMMAND /bin/bash ./test_daqd_stop_on_bad_broadcast_list.sh
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if (libNDS2Client_FOUND)
configure_file(tests/test_daqd_stop_on_stream_jump.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test_daqd_stop_on_stream_jump.sh @ONLY)
......
......@@ -44,9 +44,8 @@ namespace comm_impl
{
if ( !IS_TP_DCU( cur_dcu ) && !IS_MYRINET_DCU( cur_dcu ) )
{
std::cerr
<< "requested DCUID not in the standard range: "
<< cur_dcu << std::endl;
std::cerr << "requested DCUID not in the standard range: "
<< cur_dcu << std::endl;
exit( 1 );
}
}
......@@ -168,6 +167,49 @@ namespace comm_impl
}
}
if ( !daqd.broadcast_set.empty( ) )
{
std::vector< std::string > missing_broadcast_channels{};
std::for_each( daqd.broadcast_set.begin( ),
daqd.broadcast_set.end( ),
[&missing_broadcast_channels](
const std::string& cur_broadcast_channel ) {
const channel_t* start = daqd.channels;
const auto end = start + daqd.num_channels;
auto it = std::find_if(
start,
end,
[&cur_broadcast_channel](
const channel_t& cur_channel ) -> bool {
// only active non tp channels are marked
// with trend != 0, so check the name,
// tp, and active state
return cur_broadcast_channel ==
cur_channel.name &&
cur_channel.trend;
} );
if ( it == end )
{
missing_broadcast_channels.emplace_back(
cur_broadcast_channel );
}
} );
if ( !missing_broadcast_channels.empty( ) )
{
std::cerr << "The GDS broadcast list requests channels that "
"are not available"
<< std::endl;
std::copy(
missing_broadcast_channels.begin( ),
missing_broadcast_channels.end( ),
std::ostream_iterator< std::string >( std::cerr, "\n" ) );
std::cerr << std::endl;
throw std::runtime_error( "The GDS broadcast list requests "
"channels that are not available" );
}
}
// Calculate memory size needed for channels status storage in the main
// buffer and increment main block size
daqd.block_size += 17 * sizeof( int ) * daqd.num_channels;
......
set thread_stack_size=10240;
set dcu_status_check=1;
set debug=0;
set log=6;
set zero_bad_data=0;
set master_config="MASTER";
set broadcast_config="BCAST";
configure channels begin end;
#tpconfig "TESTPOINT";
status dcu;
#tpconfig "TESTPOINT";
set gps_leaps = 820108813;
set detector_name="TST";
set detector_prefix="X6";
set detector_longitude=-90.7742403889;
set detector_latitude=30.5628943337;
set detector_elevation=.0;
set detector_azimuths=1.1,4.7123889804;
set detector_altitudes=1.0,2.0;
set detector_midpoints=2000.0, 2000.0;
#enable frame_wiper;
#set num_dirs = 10;
#set frames_per_dir=225;
#set full_frames_per_file=1;
#set full_frames_blocks_per_frame=32;
#set frame_dir="/frames/full", "M-R-", ".gwf";
#scan frames;
#enable trend_frame_wiper;
#set trend_num_dirs=10;
#set trend_frames_per_dir=1440;
#set trend_frame_dir= "/frames/trend/second", "M-T-", ".gwf";
#set raw-minute-trend-dir="/frames/trend/minute/raw";
#set nds-jobs-dir="/opt/fb";
set parameter "shmem_input" = "local_dc";
set parameter "shmem_size" = "104857600";
set parameter "write_frame_checksums"="0";
set parameter "GDS_BROADCAST"="1";
set full_frames_blocks_per_frame=1;
set frame_dir="/dev/shm", "X-R-", ".gwf";
#enable minute-trend-frame-wiper;
#set minute-trend-num-dirs=10;
#set minute-trend-frames-per-dir=24;
#set minute-trend-frame-dir="/frames/trend/minute", "M-M-", ".gwf";
#
#scan minute-trend-frames;
#scan trend-frames;
scan frames;
start main 5;
start profiler;
# comment out this block to stop saving data
start frame-saver;
sync frame-saver;
#start trender;
#start trend-frame-saver;
#sync trend-frame-saver;
#start minute-trend-frame-saver;
#sync minute-trend-frame-saver;
#start raw-minute-trend-saver;
start frame-writer "127.255.255.255" broadcast="127.0.0.1" all;
#start fast-writer "127.255.255.255" broadcast="127.0.0.0" all;
sleep 2;
#sleep 5;
start producer;
start listener 8088 1;
# for this test we do not need to clear the crcs
#sleep 60;
#clear crc;
#!/bin/bash
CWD="@CMAKE_CURRENT_BINARY_DIR@"
TDIR=""
PID_MULTI_STREAM1=0
PID_DAQD=0
function kill_proc {
if [ $1 -gt 0 ]; then
echo "Closing process $1"
kill $1
fi
}
function cleanup {
rm -rf daqdrc_broadcast_test_final
if [ "x$TDIR" != "x" ]; then
if [ -d $TDIR ]; then
rm -rf "$TDIR"
fi
fi
kill_proc $PID_MULTI_STREAM1
kill_proc $PID_DAQD
}
MUTLI_STREAM="$CWD/../fe_stream_test/fe_multi_stream_test"
if [ ! -x "$MUTLI_STREAM" ]; then
echo "cannot find $MULTI_STREAM"
exit 1
fi
DAQD="$CWD/../daqd/daqd"
if [ ! -x "$DAQD" ]; then
echo "cannot find $DAQD"
exit 1
fi
if [ ! -r /dev/gpstime ]; then
echo "the gpstime module must be loaded, configured, and accessible by this user"
exit 1
fi
if [ ! -r /dev/mbuf ]; then
echo "the mbuf module must be loaded, configured, and accessible by this user"
exit 1
fi
PYTHON=""
which python > /dev/null
if [ $? -eq 0 ]; then
PYTHON=`which python`
else
which python3 > /dev/null
if [ $? -eq 0 ]; then
PYTHON=`which python3`
else
echo "Cannot find python or python3"
exit 1
fi
fi
trap cleanup EXIT
TDIR=`$PYTHON -c "from __future__ import print_function; import tempfile; print(tempfile.mkdtemp())"`
mkdir "$TDIR/ini_files"
mkdir "$TDIR/logs"
echo "Ini dir = $TDIR/ini_files"
"$MUTLI_STREAM" -i "$TDIR/ini_files" -M "$TDIR/ini_files/master" -b local_dc -m 100 -k 300 -R 247 > "$TDIR/logs/multi_stream" &
PID_MULTI_STREAM1=$!
echo "Streamer PID = $PID_MULTI_STREAM1"
sleep 1
MASTER_FILE="$TDIR/ini_files/master"
TESTPOINT_FILE=""
BROADCAST_FILE="$TDIR/ini_files/broadcast"
cat daqdrc_broadcast_test | sed s\|MASTER\|$MASTER_FILE\| | sed s\|TESTPOINT\|$TESTPOINT_FILE\| | sed s\|BCAST\|$BROADCAST_FILE\| > daqdrc_broadcast_test_final
echo "[X1:NON_EXISTANT1]" > $BROADCAST_FILE
echo "[X1:NON_EXISTANT2]" >> $BROADCAST_FILE
echo "[X1:NON_EXISTANT3]" >> $BROADCAST_FILE
"$DAQD" -c daqdrc_broadcast_test_final &> "$TDIR/logs/daqd" &
PID_DAQD=$!
echo "Sleeping to allow the daq to run"
sleep 10
if [ -d "/proc/$PID_DAQD" ]; then
echo "daqd process did not terminate as expected"
exit 1
fi
echo "daqd is terminated as expected"
PID_DAQD=0
grep "The GDS broadcast list requests channels that are not available" $TDIR/logs/daqd
RESULT=$?
if [ "$RESULT" -ne "0" ]; then
echo "Missing expected error message in the logs"
exit 1
fi
echo "Test successful"
exit 0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment