compiles
Build on RHEL9 docker image / build (push) Successful in 3m43s
Build on RHEL8 docker image / build (push) Successful in 5m3s
Run Simulator Tests on local RHEL9 / build (push) Failing after 6m56s
Run Simulator Tests on local RHEL8 / build (push) Failing after 8m45s

This commit is contained in:
2026-05-28 22:56:17 +02:00
parent f1b14ef345
commit 22ee40c987
11 changed files with 188 additions and 152 deletions
@@ -25,35 +25,23 @@ namespace checks = sls::test::checks;
using test::GET;
using test::PUT;
// disable for jungfrau as it requires higher maximum receive buffer size
// sysctl net.core.rmem_max=$((100*1024*1024))
// sysctl net.core.rmem_default=$((100*1024*1024))
TEST_CASE("acquire_check_binary_file_size",
"[.detectorintegration][.disable_check_data_file]") {
Detector det;
auto det_type =
det.getDetectorType().tsquash("Inconsistent detector types to test");
if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD)
test_ctb_binary_file_size(det);
else
REQUIRE_NOTHROW(acquire_and_check_file_size(det));
}
void acquire_and_check_file_size(Detector &det, const acq::CTBState &ctb_state = acq::default_ctb_state()) {
void acquire_and_check_file_size(
Detector &det, const acq::CTBState &ctb_state = acq::default_ctb_state()) {
auto acq_state = acq::default_acquisition_state();
acq_state.num_frames = 2;
auto file_state = acq::default_file_state();
acq::run(det, acq_state, file_state, ctb_state);
auto image_size = acq::get_expected_image_size(det, ctb_state);
REQUIRE_NOTHROW(checks::check_binary_file_size(image_size, acq_state.num_frames));
REQUIRE_NOTHROW(
checks::check_binary_file_size(image_size, acq_state.num_frames));
}
void test_ctb_binary_file_size(Detector &det) {
auto det_type =
det.getDetectorType().tsquash("Inconsistent detector types to test");
acq::CTBState ctb_state = acq::default_ctb_state(det_type == defs::CHIPTESTBOARD);
acq::CTBState ctb_state =
acq::default_ctb_state(det_type == defs::CHIPTESTBOARD);
// readout mode = defs::ANALOG_AND_DIGITAL
// analog samples = 5000
// digital samples = 6000
@@ -67,79 +55,95 @@ void test_ctb_binary_file_size(Detector &det) {
// trans mask = 0x3
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.dbit_offset = 16;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.dbit_offset = 16;
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.dbit_offset = 16;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
ctb_state.dbit_offset = 16;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
ctb_state.dbit_offset = 16;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::TRANSCEIVER_ONLY;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::TRANSCEIVER_ONLY;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::TRANSCEIVER_ONLY;
ctb_state.dbit_offset = 16;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
ctb_state.dbit_offset = 16;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
{
acq::CTBStateGuard ctb_guard(det, ctb_state);
ctb_state.readout_mode = defs::ANALOG_ONLY;
ctb_state.dbit_offset = 16;
ctb_state.dbit_reorder = true;
REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state));
REQUIRE_NOTHROW(acquire_and_check_file_size(det, ctb_state));
}
}
// disable for jungfrau as it requires higher maximum receive buffer size
// sysctl net.core.rmem_max=$((100*1024*1024))
// sysctl net.core.rmem_default=$((100*1024*1024))
TEST_CASE("acquire_check_binary_file_size",
"[.detectorintegration][.disable_check_data_file]") {
Detector det;
auto det_type =
det.getDetectorType().tsquash("Inconsistent detector types to test");
if (det_type == defs::CHIPTESTBOARD ||
det_type == defs::XILINX_CHIPTESTBOARD)
test_ctb_binary_file_size(det);
else
REQUIRE_NOTHROW(acquire_and_check_file_size(det));
}
} // namespace sls
@@ -98,7 +98,6 @@ void test_onchip_dac_caller(defs::dacIndex index, const std::string &dacname,
}
}
std::pair<uint64_t, int>
calculate_ctb_image_size(const acq::CTBState &test_info, bool isXilinxCtb) {
@@ -25,7 +25,6 @@ namespace mf = sls::test::master_file;
namespace acq = sls::test::acquire;
namespace checks = sls::test::checks;
TEST_CASE("check_master_file_attributes",
"[.detectorintegration][.disable_check_data_file]") {
@@ -841,14 +841,14 @@ TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") {
auto file_state = acq::default_file_state();
file_state.file_format = defs::BINARY;
acq::run(det, acq_state.num_frames, file_state);
acq::run(det, acq_state, file_state);
std::string fname = acq::get_master_file_name(file_state);
REQUIRE(std::filesystem::exists(fname));
#ifdef HDF5C
file_state.file_format = defs::HDF5;
acq::run(det, acq_state.num_frames, file_state);
std::string fname = acq::get_master_file_name(file_state);
acq::run(det, acq_state, file_state);
fname = acq::get_master_file_name(file_state);
REQUIRE(std::filesystem::exists(fname));
if (det.size() > 1 || numinterfaces > 1) {
fname = acq::get_virtual_file_name(file_state);
@@ -32,9 +32,14 @@ void run_acquisition(Detector &det) {
det.stopReceiver();
}
void run(Detector &det, const AcquisitionState &acq_state,
const FileState &file_state) {
run(det, acq_state, file_state, default_ctb_state());
}
void run(Detector &det, const AcquisitionState &acq_state,
const FileState &file_state, const CTBState &ctb_state) {
//CTBStateGuard ctb_guard(det, ctb_state);
// CTBStateGuard ctb_guard(det, ctb_state);
FileStateGuard file_guard(det, file_state);
AcquisitionStateGuard acq_guard(det, acq_state);
run_acquisition(det);
+7 -7
View File
@@ -11,13 +11,6 @@ namespace sls::test::acquire {
class FileState;
class CTBState;
void wait_until_idle(const Detector &det);
void run_acquisition(Detector &det);
void run(Detector &det,
const AcquisitionState &acq_state = default_acquisition_state(),
const FileState &file_state = default_file_state(),
const CTBState &ctb_state = default_ctb_state());
struct AcquisitionState {
int64_t num_frames;
};
@@ -52,4 +45,11 @@ class AcquisitionStateGuard {
AcquisitionState saved_;
};
void wait_until_idle(const Detector &det);
void run_acquisition(Detector &det);
void run(Detector &det, const AcquisitionState &acq_state,
const FileState &file_state);
void run(Detector &det, const AcquisitionState &acq_state,
const FileState &file_state, const CTBState &ctb_state);
} // namespace sls::test::acquire
@@ -15,11 +15,11 @@ defs::detectorType get_detector_type(const Detector &det) {
return det.getDetectorType().tsquash("Inconsistent detector type");
}
defs::xy get_geometry (const Detector& det) {
defs::xy get_geometry(const Detector &det) {
auto modGeometry = det.getModuleGeometry();
auto portperModGeometry = det.getPortPerModuleGeometry();
return defs::xy{modGeometry.x * portperModGeometry.x,
modGeometry.y * portperModGeometry.y};
modGeometry.y * portperModGeometry.y};
}
int get_dynamic_range(const Detector &det) {
@@ -126,7 +126,8 @@ ns get_period(const Detector &det) {
}
int get_num_udp_interfaces(const Detector &det) {
return det.getNumberofUDPInterfaces().tsquash("Inconsistent number of UDP interfaces");
return det.getNumberofUDPInterfaces().tsquash(
"Inconsistent number of UDP interfaces");
}
int get_read_n_rows(const Detector &det) {
@@ -141,7 +142,7 @@ bool ten_giga(const Detector &det) {
return det.getTenGiga().tsquash("Inconsistent 10Giga setting");
}
std::pair<ns, ns> get_sub_exptime_and_sub_period(const Detector& det) {
std::pair<ns, ns> get_sub_exptime_and_sub_period(const Detector &det) {
auto exptime = det.getSubExptime().tsquash("Inconsistent sub exptime");
auto deadtime = det.getSubDeadTime().tsquash("Inconsistent sub deadtime");
auto sub_period = exptime + deadtime;
@@ -158,17 +159,19 @@ acq::CommonExpectedState build_common_state(const Detector &det,
e.port_shape = get_port_shape(det);
e.max_frames_per_file =
det.getFramesPerFile().tsquash("Inconsistent frames per file");
e.frame_discard_policy = det.getRxFrameDiscardPolicy().tsquash("Inconsistent frame discard policy");
e.frame_discard_policy = det.getRxFrameDiscardPolicy().tsquash(
"Inconsistent frame discard policy");
e.partial_frames_padding = static_cast<int>(
det.getPartialFramesPadding().tsquash("Inconsistent frame padding"));
e.scan_parameters = det.getScan().tsquash("Inconsistent scan parameters");
e.total_frames = get_total_frames(det);
e.frames_in_file = det.getFramesCaught()[0][0];
e.additional_json_header = det.getAdditionalJsonHeader().tsquash("Inconsistent JSON header");
e.additional_json_header =
det.getAdditionalJsonHeader().tsquash("Inconsistent JSON header");
return e;
}
acq::JungfrauExpectedState build_jungfrau_specific_state(const Detector& det) {
acq::JungfrauExpectedState build_jungfrau_specific_state(const Detector &det) {
acq::JungfrauExpectedState e;
e.rois = get_rois(det);
e.exptime = get_exptime(det);
@@ -179,7 +182,7 @@ acq::JungfrauExpectedState build_jungfrau_specific_state(const Detector& det) {
return e;
}
acq::MoenchExpectedState build_moench_specific_state(const Detector& det) {
acq::MoenchExpectedState build_moench_specific_state(const Detector &det) {
acq::MoenchExpectedState e;
e.rois = get_rois(det);
e.exptime = get_exptime(det);
@@ -190,14 +193,15 @@ acq::MoenchExpectedState build_moench_specific_state(const Detector& det) {
return e;
}
acq::EigerExpectedState build_eiger_specific_state(const Detector& det) {
acq::EigerExpectedState build_eiger_specific_state(const Detector &det) {
acq::EigerExpectedState e;
e.rois = get_rois(det);
e.dynamic_range = get_dynamic_range(det);
e.ten_giga = ten_giga(det);
e.exptime = get_exptime(det);
e.period = get_period(det);
e.threshold_energy = det.getThresholdEnergy().tsquash("Inconsistent threshold energy");
e.threshold_energy =
det.getThresholdEnergy().tsquash("Inconsistent threshold energy");
auto [sub_exptime, sub_period] = get_sub_exptime_and_sub_period(det);
e.sub_exptime = sub_exptime;
e.sub_period = sub_period;
@@ -211,22 +215,28 @@ acq::EigerExpectedState build_eiger_specific_state(const Detector& det) {
return e;
}
acq::Mythen3ExpectedState build_mythen3_specific_state(const Detector& det) {
acq::Mythen3ExpectedState build_mythen3_specific_state(const Detector &det) {
acq::Mythen3ExpectedState e;
e.rois = get_rois(det);
e.dynamic_range = get_dynamic_range(det);
e.ten_giga = ten_giga(det);
e.period = get_period(det);
e.counter_mask = det.getCounterMask().tsquash("Inconsistent counter mask for Mythen3 detector");
e.exp_times = det.getExptimeForAllGates().tsquash("Inconsistent exposure times for all gates");
e.gate_delays = det.getGateDelayForAllGates().tsquash("Inconsistent gate delays");
e.num_gates = det.getNumberOfGates().tsquash("Inconsistent number of gates for Mythen3 detector");
e.threshold_energies = det.getAllThresholdEnergy().tsquash("Inconsistent threshold energies");
e.counter_mask = det.getCounterMask().tsquash(
"Inconsistent counter mask for Mythen3 detector");
e.exp_times = det.getExptimeForAllGates().tsquash(
"Inconsistent exposure times for all gates");
e.gate_delays =
det.getGateDelayForAllGates().tsquash("Inconsistent gate delays");
e.num_gates = det.getNumberOfGates().tsquash(
"Inconsistent number of gates for Mythen3 detector");
e.threshold_energies =
det.getAllThresholdEnergy().tsquash("Inconsistent threshold energies");
e.readout_speed = get_readout_speed(det);
return e;
}
acq::Gotthard2ExpectedState build_gotthard2_specific_state(const Detector& det) {
acq::Gotthard2ExpectedState
build_gotthard2_specific_state(const Detector &det) {
acq::Gotthard2ExpectedState e;
e.rois = get_rois(det);
e.exptime = get_exptime(det);
@@ -236,7 +246,8 @@ acq::Gotthard2ExpectedState build_gotthard2_specific_state(const Detector& det)
return e;
}
acq::CTBExpectedState build_ctb_specific_state(const Detector& det, const acq::CTBState& ctb_state) {
acq::CTBExpectedState build_ctb_specific_state(const Detector &det,
const acq::CTBState &ctb_state) {
acq::CTBExpectedState e;
e.exptime = get_exptime(det);
e.period = get_period(det);
@@ -244,31 +255,34 @@ acq::CTBExpectedState build_ctb_specific_state(const Detector& det, const acq::C
return e;
}
acq::DetectorSpecificState build_detector_specific_state(const Detector& det, const acq::CTBState& ctb_state) {
acq::DetectorSpecificState
build_detector_specific_state(const Detector &det,
const acq::CTBState &ctb_state) {
switch (det.getDetectorType().tsquash("bad type")) {
case defs::JUNGFRAU:
return build_jungfrau_specific_state(det);
case defs::MOENCH:
return build_moench_specific_state(det);
case defs::EIGER:
return build_eiger_specific_state(det);
case defs::MYTHEN3:
return build_mythen3_specific_state(det);
case defs::GOTTHARD2:
return build_gotthard2_specific_state(det);
case defs::CHIPTESTBOARD:
case defs::XILINX_CHIPTESTBOARD:
return build_ctb_specific_state(det, ctb_state);
case defs::JUNGFRAU:
return build_jungfrau_specific_state(det);
case defs::MOENCH:
return build_moench_specific_state(det);
case defs::EIGER:
return build_eiger_specific_state(det);
case defs::MYTHEN3:
return build_mythen3_specific_state(det);
case defs::GOTTHARD2:
return build_gotthard2_specific_state(det);
case defs::CHIPTESTBOARD:
case defs::XILINX_CHIPTESTBOARD:
return build_ctb_specific_state(det, ctb_state);
}
throw sls::RuntimeError("Unsupported detector type");
}
} // anonymous namespace
namespace sls::test::acquire {
ExpectedState build_expected_state(const Detector& det, const AcquisitionState &acq_state, const FileState &file_state, const CTBState &ctb_state) {
ExpectedState build_expected_state(const Detector &det,
const AcquisitionState &acq_state,
const FileState &file_state,
const CTBState &ctb_state) {
ExpectedState e;
e.common_state = build_common_state(det, ctb_state);
e.file_state = file_state;
@@ -3,16 +3,16 @@
#pragma once
#include "Acquire.h"
#include "CTBState.h"
#include "FileState.h"
#include "Acquire.h"
#include <variant>
namespace sls::test::acquire {
struct CommonExpectedState {
defs::detectorType det_type{};
defs::detectorType det_type{};
defs::timingMode timing_mode{};
defs::xy geometry{};
int image_size{};
@@ -86,13 +86,10 @@ struct CTBExpectedState {
CTBState ctb_acq_state{};
};
using DetectorSpecificState = std::variant<
JungfrauExpectedState,
MoenchExpectedState,
EigerExpectedState,
Mythen3ExpectedState,
Gotthard2ExpectedState,
CTBExpectedState>;
using DetectorSpecificState =
std::variant<JungfrauExpectedState, MoenchExpectedState, EigerExpectedState,
Mythen3ExpectedState, Gotthard2ExpectedState,
CTBExpectedState>;
struct ExpectedState {
FileState file_state{};
@@ -102,7 +99,7 @@ struct ExpectedState {
};
template <typename T>
const T& get_detector_specific_state(const ExpectedState& expected_state) {
const T &get_detector_specific_state(const ExpectedState &expected_state) {
return std::get<T>(expected_state.detector_specific_state);
}
@@ -110,7 +107,11 @@ template <typename T> bool is_type(const ExpectedState &e) {
return std::holds_alternative<T>(e.detector_specific_state);
}
ExpectedState build_expected_state(const Detector& det, const AcquisitionState &acq_state = default_acquisition_state(), const FileState &file_state = default_file_state(), const CTBState &ctb_state = default_ctb_state());
ExpectedState build_expected_state(
const Detector &det,
const AcquisitionState &acq_state = default_acquisition_state(),
const FileState &file_state = default_file_state(),
const CTBState &ctb_state = default_ctb_state());
int get_expected_image_size(const Detector &det,
const CTBState &ctb_state = default_ctb_state());
@@ -12,22 +12,22 @@ namespace sls::test::checks {
namespace acq = sls::test::acquire;
namespace mf = sls::test::master_file;
inline bool operator==(sls::ns lhs, sls::ns rhs) {
return lhs.count() == rhs.count();
}
// different values based on file format
template <typename CheckerT>
void check_version(CheckerT &checker) {
template <typename CheckerT> void check_version(CheckerT &checker) {
#ifdef HDF5C
if constexpr(std::is_same_v<CheckerT, mf::Checker<mf::H5Context>>) {
checker.template check<double>(MasterAttributes::N_VERSION.data(), HDF5_WRITER_VERSION, mf::AccessType::Attribute);
if constexpr (std::is_same_v<CheckerT, mf::Checker<mf::H5Context>>) {
checker.template check<double>(MasterAttributes::N_VERSION.data(),
HDF5_WRITER_VERSION,
mf::AccessType::Attribute);
} else
#endif
{
checker.template check<double>(MasterAttributes::N_VERSION.data(), BINARY_WRITER_VERSION);
checker.template check<double>(MasterAttributes::N_VERSION.data(),
BINARY_WRITER_VERSION);
}
}
@@ -45,7 +45,8 @@ void check_timing_mode(CheckerT &checker, const defs::timingMode &value) {
template <typename CheckerT>
void check_geometry(CheckerT &checker, const defs::xy &value) {
checker.template check<defs::xy>(MasterAttributes::N_GEOMETRY.data(), expected.common_state.geometry);
checker.template check<defs::xy>(MasterAttributes::N_GEOMETRY.data(),
value);
}
template <typename CheckerT>
@@ -230,14 +231,14 @@ void check_readout_mode(CheckerT &checker, const defs::readoutMode &value) {
value == defs::TRANSCEIVER_ONLY);
if (analog)
checker.template check<std::string>(MasterAttributes::N_ANALOG.data(),
analog);
checker.template check<int>(MasterAttributes::N_ANALOG.data(),
static_cast<int>(analog));
if (digital)
checker.template check<std::string>(MasterAttributes::N_DIGITAL.data(),
digital);
checker.template check<int>(MasterAttributes::N_DIGITAL.data(),
static_cast<int>(digital));
if (trans)
checker.template check<std::string>(
MasterAttributes::N_TRANSCEIVER.data(), trans);
checker.template check<int>(MasterAttributes::N_TRANSCEIVER.data(),
static_cast<int>(trans));
}
template <typename CheckerT>
@@ -275,7 +276,7 @@ void check_dbit_list(CheckerT &checker, const std::vector<int> &value) {
for (auto &i : value) {
dbit_bitset |= (static_cast<uint64_t>(1) << i);
}
checker.template check<uint64_t>(MasterAttributes::N_DBIT_LIST.data(),
checker.template check<uint64_t>(MasterAttributes::N_DBIT_BITSET.data(),
dbit_bitset);
}
@@ -285,34 +286,14 @@ void check_dbit_reorder(CheckerT &checker, const int &value) {
}
template <typename CheckerT>
void check_metadata(CheckerT &checker, const acq::ExpectedState &expected) {
switch (expected.common_state.det_type) {
case defs::JUNGFRAU:
check_jungfrau_metadata(checker, expected);
break;
case defs::MOENCH:
check_moench_metadata(checker, expected);
break;
case defs::EIGER:
check_eiger_metadata(checker, expected);
break;
case defs::MYTHEN3:
check_mythen3_metadata(checker, expected);
break;
case defs::GOTTHARD2:
check_gotthard2_metadata(checker, expected);
break;
case defs::CHIPTESTBOARD:
check_ctb_metadata(checker, expected);
break;
default:
throw std::runtime_error(
"Unsupported detector type for metadata checks");
}
void check_transceiver_mask(CheckerT &checker, const uint32_t &value) {
checker.template check<uint32_t>(
MasterAttributes::N_TRANSCEIVER_MASK.data(), value);
}
template <typename CheckerT>
void check_common_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_common_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
check_version(checker);
auto st = expected.common_state;
check_detector_type(checker, st.det_type);
@@ -329,7 +310,8 @@ void check_common_metadata(CheckerT &checker, const acq::ExpectedState& expected
}
template <typename CheckerT>
void check_jungfrau_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_jungfrau_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
const auto &st =
std::get<acq::JungfrauExpectedState>(expected.detector_specific_state);
check_rois(checker, st.rois);
@@ -341,7 +323,8 @@ void check_jungfrau_metadata(CheckerT &checker, const acq::ExpectedState& expect
}
template <typename CheckerT>
void check_moench_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_moench_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
const auto &st =
std::get<acq::MoenchExpectedState>(expected.detector_specific_state);
check_rois(checker, st.rois);
@@ -353,7 +336,8 @@ void check_moench_metadata(CheckerT &checker, const acq::ExpectedState& expected
}
template <typename CheckerT>
void check_eiger_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_eiger_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
const auto &st =
std::get<acq::EigerExpectedState>(expected.detector_specific_state);
check_rois(checker, st.rois);
@@ -371,7 +355,8 @@ void check_eiger_metadata(CheckerT &checker, const acq::ExpectedState& expected)
}
template <typename CheckerT>
void check_mythen3_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_mythen3_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
const auto &st =
std::get<acq::Mythen3ExpectedState>(expected.detector_specific_state);
check_rois(checker, st.rois);
@@ -387,7 +372,8 @@ void check_mythen3_metadata(CheckerT &checker, const acq::ExpectedState& expecte
}
template <typename CheckerT>
void check_gotthard2_metadata(CheckerT &checker, const acq::ExpectedState& expected) {
void check_gotthard2_metadata(CheckerT &checker,
const acq::ExpectedState &expected) {
const auto &st =
std::get<acq::Gotthard2ExpectedState>(expected.detector_specific_state);
check_rois(checker, st.rois);
@@ -422,14 +408,42 @@ void check_ctb_metadata(CheckerT &checker, const acq::ExpectedState &expected) {
check_digital_samples(checker, st.ctb_acq_state.num_dbit_samples);
check_transceiver_samples(checker, st.ctb_acq_state.num_trans_samples);
check_dbit_offset(checker, st.ctb_acq_state.dbit_offset);
check_dbit_bitset(checker, st.ctb_acq_state.dbit_list);
check_dbit_list(checker, st.ctb_acq_state.dbit_list);
check_dbit_reorder(checker, st.ctb_acq_state.dbit_reorder);
check_transceiver_mask(checker, st.ctb_acq_state.transceiver_mask);
}
void check_binary_file_size(
const int expected_image_size, const int64_t num_frames,
const acq::FileState &st = acq::default_file_state()) {
template <typename CheckerT>
void check_metadata(CheckerT &checker, const acq::ExpectedState &expected) {
check_common_metadata(checker, expected);
switch (expected.common_state.det_type) {
case defs::JUNGFRAU:
check_jungfrau_metadata(checker, expected);
break;
case defs::MOENCH:
check_moench_metadata(checker, expected);
break;
case defs::EIGER:
check_eiger_metadata(checker, expected);
break;
case defs::MYTHEN3:
check_mythen3_metadata(checker, expected);
break;
case defs::GOTTHARD2:
check_gotthard2_metadata(checker, expected);
break;
case defs::CHIPTESTBOARD:
check_ctb_metadata(checker, expected);
break;
default:
throw std::runtime_error(
"Unsupported detector type for metadata checks");
}
}
inline void
check_binary_file_size(const int expected_image_size, const int64_t num_frames,
const acq::FileState &st = acq::default_file_state()) {
assert(st.file_format == defs::BINARY);
auto fname = acq::get_first_port_first_file_name(st);
auto expected_file_size =
@@ -30,7 +30,7 @@ template <> class Checker<JsonContext> {
}
private:
const JsonContext &ctx_;
JsonContext ctx_;
};
/** HDF5 Specialization */
@@ -38,7 +38,7 @@ template <> class Checker<JsonContext> {
template <> class Checker<H5Context> {
public:
explicit Checker(const std::string& path) : ctx_(path) {}
explicit Checker(const std::string &path) : ctx_(path) {}
explicit Checker(H5Context ctx) : ctx_(std::move(ctx)) {}
const H5Context &context() const { return ctx_; }
@@ -2,11 +2,12 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "catch.hpp"
#include <filesystem>
#include <fstream>
#include <optional>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <string>
@@ -17,13 +18,13 @@
namespace sls::test::master_file {
struct JsonContext {
const rapidjson::Document doc;
rapidjson::Document doc;
explicit JsonContext(const std::string &path) {
parse_binary_master_attributes(path);
}
private:
private:
void parse_binary_master_attributes(const std::string &file_path) {
REQUIRE(std::filesystem::exists(file_path));
@@ -38,15 +39,14 @@ struct JsonContext {
rapidjson::ParseResult result = doc.Parse(json_str.c_str());
if (!result) {
std::cout << "JSON parse error: "
<< GetParseError_En(result.Code())
<< " (at offset " << result.Offset() << ")"
<< std::endl;
std::cout << "JSON parse error: " << GetParseError_En(result.Code())
<< " (at offset " << result.Offset() << ")" << std::endl;
size_t offset = result.Offset();
std::string context =
json_str.substr(std::max(0, (int)offset - 20), 40);
std::cout << "Context around error: \"" << context << "\"" << std::endl;
std::cout << "Context around error: \"" << context << "\""
<< std::endl;
}
REQUIRE(result);