Files
slsDetectorPackage/slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp
T
2e4cd258a8
Build on RHEL9 docker image / build (push) Successful in 4m1s
Build on RHEL8 docker image / build (push) Successful in 5m1s
Build and Deploy on local RHEL9 / build (push) Successful in 2m1s
Build and Deploy on local RHEL8 / build (push) Successful in 5m7s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m37s
Run Simulator Tests on local RHEL8 / build (push) Successful in 22m10s
Dev/refactor caller tests master attributes (#1462)
* refactoring

* wip

* refactored, yet to take out checkers

* checker added

* wip acquire ctb state

* wip acquire ctb state

* wip, acq test

* acquire moved out

* fix

* wip, To fix masterattribtues

* wip, masterfilecheks

* wip, at ctbexpectedstate

* wip, fixing acquire

* wip, acquire done

* wip

* compiles

* refactoring

* minor

* minor

* reduced unnecessary includes

* fix in tests

* removed ctb state check

* ctb fix with ctb state

* fixed ctb guard tests

* minor debug

* work for xilinx ctb

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
2026-06-10 17:30:30 +02:00

80 lines
2.4 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "acquire/ExpectedState.h"
#include "checks/MasterFileChecks.h"
#include "sls/Detector.h"
#include "sls/ToString.h"
#include "sls/logger.h"
#include "catch.hpp"
#include <filesystem>
#include <fstream>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <sstream>
#include <string>
#ifdef HDF5C
#include "H5Cpp.h"
#endif
namespace sls {
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]") {
Detector det;
auto detType = det.getDetectorType().squash(defs::GENERIC);
INFO("Testing master file attributes with " << ToString(detType));
// currently num frame = 1 (default)
auto acq_state = acq::default_acquisition_state();
auto file_state = acq::default_file_state();
// if ctb, set to default and restore after test
std::optional<acq::CTBState> ctb_state = std::nullopt;
if (detType == defs::CHIPTESTBOARD ||
detType == defs::XILINX_CHIPTESTBOARD) {
ctb_state = std::make_optional(acq::default_ctb_state(detType));
}
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);
} catch (H5::Exception &e) {
LOG(logERROR) << "HDF5 error: " << e.getDetailMsg();
throw;
}
#endif
}
} // namespace sls