aare/utils/test/merge_frames.test.cpp
Bechir Braham 9637d0602f
receive multimodule (#65)
* add config files for multimodule receiving

* read subfiles with unordered and missing frames

* save work debugging

* Revert "save work debugging"

This reverts commit e791992a05efd754f93a80c980d17397eb4b6045.

* Revert "read subfiles with unordered and missing frames"

This reverts commit 1177fd129d3690db92e9597ccda62598e5a44d41.

* throw when two frames have different frame numbers

* write single part RawFile (working beta)

* correct total number of frames in master file

* add new mythen file with syncd frames

* save work

* save work for receive multimodule
multimodule config results in too much packet loss. needs more debugging.

* setup Task Distributiosn/ parallelization programming model

* read frames with same frame number

* clang-tidy fixes, formatting, add tests

* added second receiver

* Synchronize between zmq streams and merge frames

* improve readability in loop

* fix failing tests

* add simple test for merge frames

---------

Co-authored-by: Bechir <bechir.brahem420@gmail.com>
Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
2024-05-07 11:06:37 +02:00

39 lines
1.5 KiB
C++

#include "aare/utils/merge_frames.hpp"
#include <catch2/catch_test_macros.hpp>
using namespace aare;
// void merge_frames(std::vector<std::byte *> &part_buffers, size_t part_size, std::byte *merged_frame, const xy
// &geometry,
// size_t cols = 0, size_t rows = 0, size_t bitdepth = 0) {
TEST_CASE("merge frames {2,1}") {
xy geo = {2, 1};
std::vector<uint32_t> p1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<uint32_t> p2 = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
size_t part_size = p1.size() * sizeof(uint32_t);
Frame f(10, 2, 32);
std::vector<std::byte *> part_buffers = {reinterpret_cast<std::byte *>(p1.data()),
reinterpret_cast<std::byte *>(p2.data())};
merge_frames(part_buffers, part_size, f.data(), geo);
auto v = f.view<uint32_t>();
for (ssize_t i = 0; i < v.size(); i++) {
REQUIRE(v[i] == i);
}
}
TEST_CASE("merge frames {1,2}") {
xy geo = {1, 2};
std::vector<uint32_t> p1 = {0, 1, 2, 3, 4, 10, 11, 12, 13, 14};
std::vector<uint32_t> p2 = {5, 6, 7, 8, 9, 15, 16, 17, 18, 19};
size_t part_size = p1.size() * sizeof(uint32_t);
Frame f(2, 10, 32);
std::vector<std::byte *> part_buffers = {reinterpret_cast<std::byte *>(p1.data()),
reinterpret_cast<std::byte *>(p2.data())};
merge_frames(part_buffers, part_size, f.data(), geo, 2, 10, 32);
auto v = f.view<uint32_t>();
for (ssize_t i = 0; i < v.size(); i++) {
REQUIRE(v[i] == i);
}
}