mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-03 14:38:14 +02:00
extra tests
This commit is contained in:
@@ -44,31 +44,23 @@ TEST_CASE("check_master_file_attributes",
|
||||
}
|
||||
acq::CTBStateGuard ctb_guard(det, ctb_state);
|
||||
|
||||
// binary => /tmp/sls_test_master_0.json
|
||||
file_state.file_format = defs::BINARY;
|
||||
acq::run(det, acq_state, file_state);
|
||||
|
||||
std::string fname = acq::get_master_file_name(file_state);
|
||||
mf::Checker<mf::JsonContext> checker(fname);
|
||||
|
||||
// get expected state of parameters and check against master file
|
||||
acq::ExpectedState expected_state =
|
||||
acq::build_expected_state(det, acq_state, file_state, ctb_state);
|
||||
checks::check_metadata(checker, expected_state);
|
||||
|
||||
#ifdef HDF5C
|
||||
try {
|
||||
// hdf5 => /tmp/sls_test_master_0.h5
|
||||
file_state.file_format = defs::HDF5;
|
||||
acq::run(det, acq_state, file_state);
|
||||
|
||||
std::string fname = acq::get_master_file_name(file_state);
|
||||
mf::Checker<mf::H5Context> checker(fname);
|
||||
|
||||
// get expected state of parameters and check against master file
|
||||
acq::ExpectedState expected_state =
|
||||
acq::build_expected_state(det, acq_state, file_state, ctb_state);
|
||||
checks::check_metadata(checker, expected_state);
|
||||
#endif
|
||||
std::vector<defs::fileFormat> formats = {defs::BINARY, defs::HDF5};
|
||||
for (auto format : formats) {
|
||||
file_state.file_format = format;
|
||||
acq::run(det, acq_state, file_state);
|
||||
std::string fname = acq::get_master_file_name(file_state);
|
||||
mf::with_checker(fname, format, [&](auto &checker) {
|
||||
// get expected state of parameters and check against master
|
||||
// file
|
||||
acq::ExpectedState expected_state = acq::build_expected_state(
|
||||
det, acq_state, file_state, ctb_state);
|
||||
checks::check_metadata(checker, expected_state);
|
||||
});
|
||||
}
|
||||
#ifdef HDF5C
|
||||
} catch (H5::Exception &e) {
|
||||
LOG(logERROR) << "HDF5 error: " << e.getDetailMsg();
|
||||
throw;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-Caller-global.h"
|
||||
|
||||
#include "checks/MasterFileChecks.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
@@ -17,6 +19,10 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
namespace acq = sls::test::acquire;
|
||||
namespace mf = sls::test::master_file;
|
||||
namespace checks = sls::test::checks;
|
||||
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
@@ -3086,6 +3092,28 @@ TEST_CASE("udp_datastream", "[.detectorintegration]") {
|
||||
caller.call("udp_datastream", {"left", "0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_datastream [left, 0]\n");
|
||||
}
|
||||
// check master file
|
||||
{
|
||||
// expected
|
||||
std::vector<defs::portPosition> expected_ports =
|
||||
det.getPortPositionList();
|
||||
std::vector<int> expected_disabled_ports =
|
||||
det.getRxDisabledUDPPortIndices();
|
||||
// run
|
||||
auto acq_state = acq::default_acquisition_state();
|
||||
auto file_state = acq::default_file_state();
|
||||
std::vector<defs::fileFormat> formats = {defs::BINARY, defs::HDF5};
|
||||
for (auto format : formats) {
|
||||
file_state.file_format = format;
|
||||
acq::run(det, acq_state, file_state);
|
||||
std::string fname = acq::get_master_file_name(file_state);
|
||||
mf::with_checker(fname, format, [&](auto &checker) {
|
||||
checks::check_udp_ports_type(checker, expected_ports);
|
||||
checks::check_udp_ports_disabled(checker,
|
||||
expected_disabled_ports);
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("udp_datastream", {"right", "0"}, -1, PUT, oss);
|
||||
@@ -3139,6 +3167,29 @@ TEST_CASE("udp_datastream", "[.detectorintegration]") {
|
||||
caller.call("udp_datastream", {"top", "1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_datastream [top, 1]\n");
|
||||
}
|
||||
// check master file
|
||||
{
|
||||
// expected
|
||||
std::vector<defs::portPosition> expected_ports =
|
||||
det.getPortPositionList();
|
||||
std::vector<int> expected_disabled_ports =
|
||||
det.getRxDisabledUDPPortIndices();
|
||||
// run
|
||||
auto acq_state = acq::default_acquisition_state();
|
||||
auto file_state = acq::default_file_state();
|
||||
std::vector<defs::fileFormat> formats = {defs::BINARY,
|
||||
defs::HDF5};
|
||||
for (auto format : formats) {
|
||||
file_state.file_format = format;
|
||||
acq::run(det, acq_state, file_state);
|
||||
std::string fname = acq::get_master_file_name(file_state);
|
||||
mf::with_checker(fname, format, [&](auto &checker) {
|
||||
checks::check_udp_ports_type(checker, expected_ports);
|
||||
checks::check_udp_ports_disabled(
|
||||
checker, expected_disabled_ports);
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("udp_datastream", {"bottom", "1"}, -1, PUT, oss);
|
||||
|
||||
@@ -56,4 +56,23 @@ template <> class Checker<H5Context> {
|
||||
|
||||
#endif
|
||||
|
||||
template <typename F>
|
||||
void with_checker(const std::string &fname, defs::fileFormat format,
|
||||
#ifdef HDF5C
|
||||
F &&f)
|
||||
#else
|
||||
F &&f)
|
||||
#endif
|
||||
{
|
||||
if (format == defs::HDF5) {
|
||||
#ifdef HDF5C
|
||||
Checker<H5Context> checker(fname);
|
||||
f(checker);
|
||||
#endif
|
||||
} else {
|
||||
Checker<JsonContext> checker(fname);
|
||||
f(checker);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sls::test::master_file
|
||||
Reference in New Issue
Block a user