GCC Code Coverage Report


Directory: ./
File: src/iguana/tests/include/TestValidator.h
Date: 2025-03-24 18:50:00
Exec Total Coverage
Lines: 15 19 78.9%
Functions: 1 1 100.0%
Branches: 24 48 50.0%

Line Branch Exec Source
1 // test an iguana algorithm validator
2
3 #include <filesystem>
4 #include <hipo4/reader.h>
5 #include <iguana/algorithms/Validator.h>
6
7 9 inline int TestValidator(
8 std::string vdor_name,
9 std::vector<std::string> bank_names,
10 std::string data_file,
11 int num_events,
12 std::string output_dir,
13 bool verbose)
14 {
15
16 // check arguments
17
2/4
✓ Branch 0 (2→3) taken 9 times.
✗ Branch 1 (2→4) not taken.
✗ Branch 2 (3→4) not taken.
✓ Branch 3 (3→6) taken 9 times.
9 if(vdor_name == "" || bank_names.empty()) {
18 fmt::print(stderr, "ERROR: need validator name and banks\n");
19 return 1;
20 }
21
1/2
✗ Branch 0 (6→8) not taken.
✓ Branch 1 (6→10) taken 9 times.
9 if(data_file == "") {
22 fmt::print(stderr, "ERROR: need a data file for command 'validator'\n");
23 return 1;
24 }
25
26 // open the HIPO file
27 9 hipo::reader reader(data_file.c_str());
28
3/6
✓ Branch 0 (11→12) taken 9 times.
✗ Branch 1 (11→53) not taken.
✓ Branch 2 (12→13) taken 9 times.
✗ Branch 3 (12→41) not taken.
✓ Branch 4 (14→15) taken 9 times.
✗ Branch 5 (14→19) not taken.
9 auto banks = reader.getBanks(bank_names);
29
30 // make the output directory
31
1/2
✓ Branch 0 (14→15) taken 9 times.
✗ Branch 1 (14→19) not taken.
9 if(output_dir != "")
32
2/4
✓ Branch 0 (15→16) taken 9 times.
✗ Branch 1 (15→51) not taken.
✓ Branch 2 (16→17) taken 9 times.
✗ Branch 3 (16→43) not taken.
9 std::filesystem::create_directories(output_dir);
33
34 // define the validator
35
1/2
✓ Branch 0 (19→20) taken 9 times.
✗ Branch 1 (19→51) not taken.
9 auto vdor = iguana::AlgorithmFactory::Create(vdor_name);
36
2/4
✓ Branch 0 (20→21) taken 9 times.
✗ Branch 1 (20→22) not taken.
✓ Branch 2 (22→23) taken 9 times.
✗ Branch 3 (22→47) not taken.
9 dynamic_cast<iguana::Validator*>(vdor.get())->SetOutputDirectory(output_dir);
37
4/10
✓ Branch 0 (23→24) taken 9 times.
✗ Branch 1 (23→25) not taken.
✓ Branch 2 (25→26) taken 9 times.
✗ Branch 3 (25→47) not taken.
✓ Branch 4 (26→27) taken 9 times.
✗ Branch 5 (26→45) not taken.
✓ Branch 6 (28→29) taken 9 times.
✗ Branch 7 (28→47) not taken.
✗ Branch 8 (47→48) not taken.
✗ Branch 9 (47→50) not taken.
27 vdor->SetOption("log", verbose ? "trace" : "info");
38
39 // event loop
40
1/2
✓ Branch 0 (28→29) taken 9 times.
✗ Branch 1 (28→47) not taken.
9 vdor->Start(banks);
41 int it_ev = 0;
42
5/8
✓ Branch 0 (29→30) taken 9009 times.
✗ Branch 1 (29→47) not taken.
✓ Branch 2 (30→31) taken 9009 times.
✗ Branch 3 (30→34) not taken.
✓ Branch 4 (31→32) taken 9009 times.
✗ Branch 5 (31→33) not taken.
✓ Branch 6 (32→33) taken 9000 times.
✓ Branch 7 (32→34) taken 9 times.
9009 while(reader.next(banks) && (num_events == 0 || it_ev++ < num_events)) {
43
1/2
✓ Branch 0 (33→29) taken 9000 times.
✗ Branch 1 (33→47) not taken.
9000 vdor->Run(banks);
44 }
45
1/2
✓ Branch 0 (34→35) taken 9 times.
✗ Branch 1 (34→47) not taken.
9 vdor->Stop();
46 return 0;
47 9 }
48