mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-20 12:28:42 +01:00
added test cases
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#include "aare/RawMasterFile.hpp"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "test_config.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace aare;
|
||||
|
||||
|
||||
TEST_CASE("Parse a master file fname"){
|
||||
TEST_CASE("Parse a master file fname") {
|
||||
RawFileNameComponents m("test_master_1.json");
|
||||
REQUIRE(m.base_name() == "test");
|
||||
REQUIRE(m.ext() == ".json");
|
||||
@@ -14,7 +14,7 @@ TEST_CASE("Parse a master file fname"){
|
||||
REQUIRE(m.base_path() == "");
|
||||
}
|
||||
|
||||
TEST_CASE("Extraction of base path works"){
|
||||
TEST_CASE("Extraction of base path works") {
|
||||
RawFileNameComponents m("some/path/test_master_73.json");
|
||||
REQUIRE(m.base_name() == "test");
|
||||
REQUIRE(m.ext() == ".json");
|
||||
@@ -22,7 +22,7 @@ TEST_CASE("Extraction of base path works"){
|
||||
REQUIRE(m.base_path() == "some/path");
|
||||
}
|
||||
|
||||
TEST_CASE("Construction of master file name and data files"){
|
||||
TEST_CASE("Construction of master file name and data files") {
|
||||
RawFileNameComponents m("test_master_1.json");
|
||||
REQUIRE(m.master_fname() == "test_master_1.json");
|
||||
REQUIRE(m.data_fname(0, 0) == "test_d0_f0_1.raw");
|
||||
@@ -31,7 +31,7 @@ TEST_CASE("Construction of master file name and data files"){
|
||||
REQUIRE(m.data_fname(1, 1) == "test_d1_f1_1.raw");
|
||||
}
|
||||
|
||||
TEST_CASE("Construction of master file name and data files using old scheme"){
|
||||
TEST_CASE("Construction of master file name and data files using old scheme") {
|
||||
RawFileNameComponents m("test_master_1.raw");
|
||||
m.set_old_scheme(true);
|
||||
REQUIRE(m.master_fname() == "test_master_1.raw");
|
||||
@@ -41,16 +41,15 @@ TEST_CASE("Construction of master file name and data files using old scheme"){
|
||||
REQUIRE(m.data_fname(1, 1) == "test_d1_f000000000001_1.raw");
|
||||
}
|
||||
|
||||
TEST_CASE("Master file name does not fit pattern"){
|
||||
TEST_CASE("Master file name does not fit pattern") {
|
||||
REQUIRE_THROWS(RawFileNameComponents("somefile.json"));
|
||||
REQUIRE_THROWS(RawFileNameComponents("another_test_d0_f0_1.raw"));
|
||||
REQUIRE_THROWS(RawFileNameComponents("test_master_1.txt"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE("Parse scan parameters"){
|
||||
ScanParameters s("[enabled\ndac dac 4\nstart 500\nstop 2200\nstep 5\nsettleTime 100us\n]");
|
||||
TEST_CASE("Parse scan parameters") {
|
||||
ScanParameters s("[enabled\ndac dac 4\nstart 500\nstop 2200\nstep "
|
||||
"5\nsettleTime 100us\n]");
|
||||
REQUIRE(s.enabled());
|
||||
REQUIRE(s.dac() == "dac 4");
|
||||
REQUIRE(s.start() == 500);
|
||||
@@ -58,7 +57,7 @@ TEST_CASE("Parse scan parameters"){
|
||||
REQUIRE(s.step() == 5);
|
||||
}
|
||||
|
||||
TEST_CASE("A disabled scan"){
|
||||
TEST_CASE("A disabled scan") {
|
||||
ScanParameters s("[disabled]");
|
||||
REQUIRE_FALSE(s.enabled());
|
||||
REQUIRE(s.dac() == "");
|
||||
@@ -67,9 +66,9 @@ TEST_CASE("A disabled scan"){
|
||||
REQUIRE(s.step() == 0);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Parse a master file in .json format", "[.integration]"){
|
||||
auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json";
|
||||
TEST_CASE("Parse a master file in .json format", "[.integration]") {
|
||||
auto fpath =
|
||||
test_data_path() / "jungfrau" / "jungfrau_single_master_0.json";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawMasterFile f(fpath);
|
||||
|
||||
@@ -80,7 +79,7 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){
|
||||
REQUIRE(f.detector_type() == DetectorType::Jungfrau);
|
||||
// "Timing Mode": "auto",
|
||||
REQUIRE(f.timing_mode() == TimingMode::Auto);
|
||||
|
||||
|
||||
// "Geometry": {
|
||||
// "x": 1,
|
||||
// "y": 1
|
||||
@@ -100,10 +99,9 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){
|
||||
// "Max Frames Per File": 3,
|
||||
REQUIRE(f.max_frames_per_file() == 3);
|
||||
|
||||
//Jungfrau doesn't write but it is 16
|
||||
// Jungfrau doesn't write but it is 16
|
||||
REQUIRE(f.bitdepth() == 16);
|
||||
|
||||
|
||||
// "Frame Discard Policy": "nodiscard",
|
||||
|
||||
// "Frame Padding": 1,
|
||||
@@ -125,33 +123,48 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){
|
||||
// "Frames in File": 10,
|
||||
REQUIRE(f.frames_in_file() == 10);
|
||||
|
||||
//TODO! Should we parse this?
|
||||
// "Frame Header Format": {
|
||||
// "Frame Number": "8 bytes",
|
||||
// "SubFrame Number/ExpLength": "4 bytes",
|
||||
// "Packet Number": "4 bytes",
|
||||
// "Bunch ID": "8 bytes",
|
||||
// "Timestamp": "8 bytes",
|
||||
// "Module Id": "2 bytes",
|
||||
// "Row": "2 bytes",
|
||||
// "Column": "2 bytes",
|
||||
// "Reserved": "2 bytes",
|
||||
// "Debug": "4 bytes",
|
||||
// "Round Robin Number": "2 bytes",
|
||||
// "Detector Type": "1 byte",
|
||||
// "Header Version": "1 byte",
|
||||
// "Packets Caught Mask": "64 bytes"
|
||||
// }
|
||||
// }
|
||||
// TODO! Should we parse this?
|
||||
// "Frame Header Format": {
|
||||
// "Frame Number": "8 bytes",
|
||||
// "SubFrame Number/ExpLength": "4 bytes",
|
||||
// "Packet Number": "4 bytes",
|
||||
// "Bunch ID": "8 bytes",
|
||||
// "Timestamp": "8 bytes",
|
||||
// "Module Id": "2 bytes",
|
||||
// "Row": "2 bytes",
|
||||
// "Column": "2 bytes",
|
||||
// "Reserved": "2 bytes",
|
||||
// "Debug": "4 bytes",
|
||||
// "Round Robin Number": "2 bytes",
|
||||
// "Detector Type": "1 byte",
|
||||
// "Header Version": "1 byte",
|
||||
// "Packets Caught Mask": "64 bytes"
|
||||
// }
|
||||
// }
|
||||
|
||||
REQUIRE_FALSE(f.analog_samples());
|
||||
REQUIRE_FALSE(f.digital_samples());
|
||||
|
||||
REQUIRE_FALSE(f.digital_samples());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a master file in .raw format", "[.integration]"){
|
||||
|
||||
auto fpath = test_data_path() / "moench/moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw";
|
||||
TEST_CASE("Parse a master file in old .raw format",
|
||||
"[.integration][.files][.rawmasterfile]") {
|
||||
auto fpath = test_data_path() /
|
||||
"raw/jungfrau_2modules_version6.1.2/run_master_0.raw";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawMasterFile f(fpath);
|
||||
|
||||
CHECK(f.num_udp_interfaces_per_module() == 1);
|
||||
CHECK(f.n_modules() == 2);
|
||||
CHECK(f.geometry().row == 2);
|
||||
CHECK(f.geometry().col == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a master file in .raw format", "[.integration]") {
|
||||
|
||||
auto fpath =
|
||||
test_data_path() /
|
||||
"moench/"
|
||||
"moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawMasterFile f(fpath);
|
||||
|
||||
@@ -209,80 +222,74 @@ TEST_CASE("Parse a master file in .raw format", "[.integration]"){
|
||||
// Detector Type : 1 byte
|
||||
// Header Version : 1 byte
|
||||
// Packets Caught Mask : 64 bytes
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Read eiger master file", "[.integration]"){
|
||||
auto fpath = test_data_path() / "eiger" / "eiger_500k_32bit_master_0.json";
|
||||
TEST_CASE("Read eiger master file", "[.integration]") {
|
||||
auto fpath = test_data_path() / "eiger" / "eiger_500k_32bit_master_0.json";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawMasterFile f(fpath);
|
||||
|
||||
// {
|
||||
// "Version": 7.2,
|
||||
REQUIRE(f.version() == "7.2");
|
||||
// "Timestamp": "Tue Mar 26 17:24:34 2024",
|
||||
// "Detector Type": "Eiger",
|
||||
REQUIRE(f.detector_type() == DetectorType::Eiger);
|
||||
// "Timing Mode": "auto",
|
||||
REQUIRE(f.timing_mode() == TimingMode::Auto);
|
||||
// "Geometry": {
|
||||
// "x": 2,
|
||||
// "y": 2
|
||||
// },
|
||||
// "Image Size in bytes": 524288,
|
||||
REQUIRE(f.image_size_in_bytes() == 524288);
|
||||
// "Pixels": {
|
||||
// "x": 512,
|
||||
REQUIRE(f.pixels_x() == 512);
|
||||
// "y": 256
|
||||
REQUIRE(f.pixels_y() == 256);
|
||||
// },
|
||||
// "Max Frames Per File": 10000,
|
||||
REQUIRE(f.max_frames_per_file() == 10000);
|
||||
// "Frame Discard Policy": "nodiscard",
|
||||
REQUIRE(f.frame_discard_policy() == FrameDiscardPolicy::NoDiscard);
|
||||
// "Frame Padding": 1,
|
||||
REQUIRE(f.frame_padding() == 1);
|
||||
|
||||
// "Scan Parameters": "[disabled]",
|
||||
// "Total Frames": 3,
|
||||
// "Receiver Roi": {
|
||||
// "xmin": 4294967295,
|
||||
// "xmax": 4294967295,
|
||||
// "ymin": 4294967295,
|
||||
// "ymax": 4294967295
|
||||
// },
|
||||
// "Dynamic Range": 32,
|
||||
// "Ten Giga": 0,
|
||||
// "Exptime": "5s",
|
||||
// "Period": "1s",
|
||||
// "Threshold Energy": -1,
|
||||
// "Sub Exptime": "2.62144ms",
|
||||
// "Sub Period": "2.62144ms",
|
||||
// "Quad": 0,
|
||||
// "Number of rows": 256,
|
||||
// "Rate Corrections": "[0, 0]",
|
||||
// "Frames in File": 3,
|
||||
// "Frame Header Format": {
|
||||
// "Frame Number": "8 bytes",
|
||||
// "SubFrame Number/ExpLength": "4 bytes",
|
||||
// "Packet Number": "4 bytes",
|
||||
// "Bunch ID": "8 bytes",
|
||||
// "Timestamp": "8 bytes",
|
||||
// "Module Id": "2 bytes",
|
||||
// "Row": "2 bytes",
|
||||
// "Column": "2 bytes",
|
||||
// "Reserved": "2 bytes",
|
||||
// "Debug": "4 bytes",
|
||||
// "Round Robin Number": "2 bytes",
|
||||
// "Detector Type": "1 byte",
|
||||
// "Header Version": "1 byte",
|
||||
// "Packets Caught Mask": "64 bytes"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// {
|
||||
// "Version": 7.2,
|
||||
REQUIRE(f.version() == "7.2");
|
||||
// "Timestamp": "Tue Mar 26 17:24:34 2024",
|
||||
// "Detector Type": "Eiger",
|
||||
REQUIRE(f.detector_type() == DetectorType::Eiger);
|
||||
// "Timing Mode": "auto",
|
||||
REQUIRE(f.timing_mode() == TimingMode::Auto);
|
||||
// "Geometry": {
|
||||
// "x": 2,
|
||||
// "y": 2
|
||||
// },
|
||||
// "Image Size in bytes": 524288,
|
||||
REQUIRE(f.image_size_in_bytes() == 524288);
|
||||
// "Pixels": {
|
||||
// "x": 512,
|
||||
REQUIRE(f.pixels_x() == 512);
|
||||
// "y": 256
|
||||
REQUIRE(f.pixels_y() == 256);
|
||||
// },
|
||||
// "Max Frames Per File": 10000,
|
||||
REQUIRE(f.max_frames_per_file() == 10000);
|
||||
// "Frame Discard Policy": "nodiscard",
|
||||
REQUIRE(f.frame_discard_policy() == FrameDiscardPolicy::NoDiscard);
|
||||
// "Frame Padding": 1,
|
||||
REQUIRE(f.frame_padding() == 1);
|
||||
|
||||
// "Scan Parameters": "[disabled]",
|
||||
// "Total Frames": 3,
|
||||
// "Receiver Roi": {
|
||||
// "xmin": 4294967295,
|
||||
// "xmax": 4294967295,
|
||||
// "ymin": 4294967295,
|
||||
// "ymax": 4294967295
|
||||
// },
|
||||
// "Dynamic Range": 32,
|
||||
// "Ten Giga": 0,
|
||||
// "Exptime": "5s",
|
||||
// "Period": "1s",
|
||||
// "Threshold Energy": -1,
|
||||
// "Sub Exptime": "2.62144ms",
|
||||
// "Sub Period": "2.62144ms",
|
||||
// "Quad": 0,
|
||||
// "Number of rows": 256,
|
||||
// "Rate Corrections": "[0, 0]",
|
||||
// "Frames in File": 3,
|
||||
// "Frame Header Format": {
|
||||
// "Frame Number": "8 bytes",
|
||||
// "SubFrame Number/ExpLength": "4 bytes",
|
||||
// "Packet Number": "4 bytes",
|
||||
// "Bunch ID": "8 bytes",
|
||||
// "Timestamp": "8 bytes",
|
||||
// "Module Id": "2 bytes",
|
||||
// "Row": "2 bytes",
|
||||
// "Column": "2 bytes",
|
||||
// "Reserved": "2 bytes",
|
||||
// "Debug": "4 bytes",
|
||||
// "Round Robin Number": "2 bytes",
|
||||
// "Detector Type": "1 byte",
|
||||
// "Header Version": "1 byte",
|
||||
// "Packets Caught Mask": "64 bytes"
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user