CbmRoot
Loading...
Searching...
No Matches
services/qa/Application.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI/VECC, Darmstadt/Kolkata
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Souvik Chattopadhyay[committer], Sergei Zharko */
4
5#include "Application.h"
6
7#include <boost/filesystem.hpp>
8
9#include <iostream>
10#include <map>
11#include <memory>
12#include <sstream>
13
16{
17 ETestType compareType = opt.GetCompare();
18 std::vector<std::string> names = opt.GetNames();
19
22 fCurrentDir = boost::filesystem::current_path().string();
23
24 auto pChecker = std::make_unique<cbm::qa::checker::Core>();
25 pChecker->RegisterOutFile(fOutputFileName.c_str());
26 pChecker->SetFromYAML(fConfigFileName.c_str());
27
28 if (compareType == ETestType::Commit) {
29 Citest(names, opt.GetBuilddir());
30 for (const std::string& name : names) {
31
32 std::string label = name.substr(0, 9);
33
34 pChecker->AddVersion(label.c_str(), label.c_str());
35 }
36 }
37 else if (compareType == ETestType::Weekly) {
38 for (const std::string& name : names) {
39
40 pChecker->AddVersion(name.c_str(), name.c_str());
41 }
42 }
43 else {
44 std::cerr << "Unknown compare type: NotDefined" << std::endl;
45 }
46
47 pChecker->Process(opt.GetOption().c_str());
48}
49
55void Application::Citest(const std::vector<std::string>& names, std::string builddir)
56{
57 std::ostringstream cmd;
58 const char* vmworkdir = getenv("VMWORKDIR");
59 if (vmworkdir != nullptr) {
60 cmd << vmworkdir << "/macro/qa/run_ctest_commit.sh";
61
62 for (const auto& name : names) {
63 cmd << " " << name;
64 }
65
66 if (!builddir.empty()) {
67 cmd << " --build_dir " << builddir;
68 }
69
70 std::string currentDir = fCurrentDir;
71 cmd << " --current_dir " << currentDir;
72
73 std::string finalCmd = cmd.str();
74 std::cout << "Executing: " << finalCmd << std::endl;
75
76 int ret = system(finalCmd.c_str());
77 if (ret != 0) {
78 std::cerr << "Script failed with return code: " << ret << std::endl;
79 return;
80 }
81 }
82 else {
83 std::cerr << "VMWORKDIR not set in environment!" << std::endl;
84 return;
85 }
86}
Class to parse and store command-line arguments.
const std::string & GetOutput() const
Returns the output ROOT file path.
const std::vector< std::string > & GetNames() const
Returns the list of commit hashes or week numbers.
const std::string & GetOption() const
Returns the option for comparison and canvas handling.
ETestType GetCompare() const
Returns the selected comparison type.
const std::string & GetConfig() const
Returns the YAML configuration file path.
const std::string & GetBuilddir() const
Returns the CBMROOT build directory path.
std::string fConfigFileName
Configuration file name.
std::string fOutputFileName
Output file name.
void Citest(const std::vector< std::string > &names, std::string builddir="")
Executes ctest for a given list of commit hashes or week numbers.
std::string fCurrentDir
Current working directory.
Application(ProgramOptions const &opt)
Standard constructor, initialize the application.
@ Commit
Commit-based comparision mode.
@ Weekly
Weekly test comparision mode.