Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
TestResult.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
16#include "TestResult.hpp"
21#include <ostream>
22#include <sstream>
23#include <string>
24#include <vector>
25
26namespace shamtest::details {
27
29
30 using namespace shamsys::instance;
31
32 auto get_type_name = [](TestType t) -> std::string {
33 switch (t) {
34 case Benchmark : return "Benchmark";
35 case LongBenchmark : return "LongBenchmark";
36 case ValidationTest : return "ValidationTest";
37 case LongValidationTest: return "LongValidationTest";
38 case Unittest : return "Unittest";
39 }
40 };
41
42 auto get_str = [&]() -> std::string {
43 return "{\n"
44 R"( "type" : ")"
45 + get_type_name(type) + "\",\n" + R"( "name" : ")" + name + "\",\n"
46 + R"( "compute_queue" : ")"
47 + get_compute_queue().get_device().get_info<sycl::info::device::name>() + "\",\n"
48 + R"( "alt_queue" : ")"
49 + get_alt_queue().get_device().get_info<sycl::info::device::name>() + "\",\n"
50 + R"( "world_rank" : )" + std::to_string(world_rank) + ",\n"
51 + R"( "asserts" : )" + shambase::increase_indent(asserts.serialize_json())
52 + ",\n" + R"( "test_data" : )"
54 };
55
56 return get_str();
57 }
58
59 void TestResult::serialize(std::basic_stringstream<byte> &stream) {
60
61 shamlog_debug_mpi_ln("TEST", "serialize :", name);
62
63 shambase::stream_write(stream, type);
64
65 shambase::stream_write_string(stream, name);
66
67 shambase::stream_write(stream, world_rank);
68
69 asserts.serialize(stream);
70 test_data.serialize(stream);
71
72 shambase::stream_write_string(stream, tex_output);
73 }
74
75 TestResult TestResult::deserialize(std::basic_stringstream<byte> &reader) {
77 std::string name;
79 std::string tex_output;
80
81 shambase::stream_read(reader, type);
82
83 shambase::stream_read_string(reader, name);
84 shamlog_debug_mpi_ln("TEST", "deserialize :", name);
85
86 shambase::stream_read(reader, world_rank);
87
90
91 shambase::stream_read_string(reader, tex_output);
92
93 return TestResult{
94 type,
95 name,
97 std::move(asserts),
98 std::move(test_data),
99 std::move(tex_output)};
100 }
101
102} // namespace shamtest::details
Header file describing a Node Instance.
header describing return type of a test, and the type of the test
TestType
Describe the type of the performed test.
std::uint32_t u32
32 bit unsigned integer
std::string increase_indent(std::string in, std::string delim="\n ")
Increase indentation of a string.
Definition string.hpp:197
implementation details of the test library
Definition DataNode.hpp:23
Class to hold the list of assertion related to a test.
static TestAssertList deserialize(std::basic_stringstream< byte > &reader)
DeSerialize the assertion from binary format.
void serialize(std::basic_stringstream< byte > &stream)
Serialize the assertion in binary format.
std::string serialize_json()
Serialize the assertion in JSON.
List of data generated by a test.
std::string serialize_json()
Serialize the assertion in JSON.
void serialize(std::basic_stringstream< byte > &stream)
Serialize the assertion in binary format.
static TestDataList deserialize(std::basic_stringstream< byte > &reader)
DeSerialize the assertion from binary format.
static TestResult deserialize(std::basic_stringstream< byte > &reader)
DeSerialize the assertion from binary format.
std::string serialize_json()
Serialize the assertion in JSON.
void serialize(std::basic_stringstream< byte > &stream)
Serialize the assertion in binary format.