Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BP][634] Clean examples #17940

Merged
merged 16 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/root-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ jobs:
with:
build-directory: /Users/sftnight/ROOT-CI/src/

- name: Set up curl CA bundle for Davix to work with https
run: 'echo SSL_CERT_FILE=/opt/local/share/curl/curl-ca-bundle.crt >> $GITHUB_ENV'

- name: Pull Request Build
if: github.event_name == 'pull_request'
env:
Expand Down
3 changes: 3 additions & 0 deletions io/io/test/TFileTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ void TestReadWithoutGlobalRegistrationIfPossible(const char *fname)
}

// https://github.com/root-project/root/issues/10742
#ifndef R__WIN32
// We prefer not to read remotely files from Windows, if possible
TEST(TFile, ReadWithoutGlobalRegistrationWeb)
{
const auto webFile = "http://root.cern/files/h1/dstarmb.root";
Expand All @@ -136,6 +138,7 @@ TEST(TFile, ReadWithoutGlobalRegistrationNet)
const auto netFile = "root://eospublic.cern.ch//eos/root-eos/h1/dstarmb.root";
TestReadWithoutGlobalRegistrationIfPossible(netFile);
}
#endif

// https://github.com/root-project/root/issues/16189
TEST(TFile, k630forwardCompatibility)
Expand Down
16 changes: 13 additions & 3 deletions net/davix/src/RRawFileDavix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

#include "ROOT/RRawFileDavix.hxx"

#include <TEnv.h>
#include <TError.h>
#include "utils.h"

#include <memory>
#include <stdexcept>
Expand All @@ -28,14 +30,22 @@ namespace ROOT {
namespace Internal {

struct RDavixFileDes {
RDavixFileDes() : fd(nullptr), pos(&ctx) {}

RDavixFileDes() : fd(nullptr), pos(&ctx)
{
// CA Check
const auto ca_check_local_str = gEnv->GetValue("Davix.GSI.CACheck", (const char *)"y");
bool ca_check_local = isno(ca_check_local_str);
pars.setSSLCAcheck(ca_check_local);
}
RDavixFileDes(const RDavixFileDes &) = delete;
RDavixFileDes &operator=(const RDavixFileDes &) = delete;
~RDavixFileDes() = default;

DAVIX_FD *fd;
Davix::Context ctx;
Davix::DavPosix pos;
Davix::RequestParams pars;
};

} // namespace Internal
Expand All @@ -62,7 +72,7 @@ std::uint64_t ROOT::Internal::RRawFileDavix::GetSizeImpl()
{
struct stat buf;
Davix::DavixError *err = nullptr;
if (fFileDes->pos.stat(nullptr, fUrl, &buf, &err) == -1) {
if (fFileDes->pos.stat(&fFileDes->pars, fUrl, &buf, &err) == -1) {
throw std::runtime_error("Cannot determine size of '" + fUrl + "', error: " + err->getErrMsg());
}
return buf.st_size;
Expand All @@ -71,7 +81,7 @@ std::uint64_t ROOT::Internal::RRawFileDavix::GetSizeImpl()
void ROOT::Internal::RRawFileDavix::OpenImpl()
{
Davix::DavixError *err = nullptr;
fFileDes->fd = fFileDes->pos.open(nullptr, fUrl, O_RDONLY, &err);
fFileDes->fd = fFileDes->pos.open(&fFileDes->pars, fUrl, O_RDONLY, &err);
if (fFileDes->fd == nullptr) {
throw std::runtime_error("Cannot open '" + fUrl + "', error: " + err->getErrMsg());
}
Expand Down
11 changes: 1 addition & 10 deletions net/davix/src/TDavixFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "TBase64.h"
#include "TVirtualPerfStats.h"
#include "TDavixFileInternal.h"
#include "utils.h"
#include "snprintf.h"

#include <cerrno>
Expand Down Expand Up @@ -89,16 +90,6 @@ ROOT::Experimental::RLogChannel &TDavixLogChannel()

////////////////////////////////////////////////////////////////////////////////

bool isno(const char *str)
{
if (!str) return false;

if (!strcmp(str, "n") || !strcmp(str, "no") || !strcmp(str, "0") || !strcmp(str, "false")) return true;

return false;

}

bool strToBool(const char *str, bool defvalue) {
if(!str) return defvalue;

Expand Down
20 changes: 20 additions & 0 deletions net/davix/src/utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*************************************************************************
* Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#include <string>

inline bool isno(const char *str)
{
if (!str)
return false;

if (!strcmp(str, "n") || !strcmp(str, "no") || !strcmp(str, "0") || !strcmp(str, "false"))
return true;

return false;
}
16 changes: 10 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,20 @@ if(geom)
FAILREGEX "FAILED|Error in")

#--stressGeometry------------------------------------------------------------------------------------
ROOT_EXECUTABLE(stressGeometry stressGeometry.cxx LIBRARIES Geom Tree GenVector Gpad)
ROOT_ADD_TEST(test-stressgeometry COMMAND stressGeometry -b FAILREGEX "FAILED|Error in" LABELS longtest)
ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx
FAILREGEX "FAILED|Error in" DEPENDS test-stressgeometry LABELS longtest)
if (NOT MSVC) # Prevents the access to the web, which could happen through https
ROOT_EXECUTABLE(stressGeometry stressGeometry.cxx LIBRARIES Geom Tree GenVector Gpad)
ROOT_ADD_TEST(test-stressgeometry COMMAND stressGeometry -b FAILREGEX "FAILED|Error in" LABELS longtest)
ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx
FAILREGEX "FAILED|Error in" DEPENDS test-stressgeometry LABELS longtest)
endif()
endif()

#--stressLinear------------------------------------------------------------------------------------
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linearIO.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
ROOT_EXECUTABLE(stressLinear stressLinear.cxx LIBRARIES Matrix Hist RIO)
ROOT_ADD_TEST(test-stresslinear COMMAND stressLinear FAILREGEX "FAILED|Error in" LABELS longtest)
ROOT_ADD_TEST(test-stresslinear-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressLinear.cxx
FAILREGEX "FAILED|Error in" DEPENDS test-stresslinear LABELS longtest)
FAILREGEX "FAILED|Error in" LABELS longtest)

#--stressGraphics------------------------------------------------------------------------------------
if(ROOT_opengl_FOUND)
Expand Down Expand Up @@ -195,10 +198,11 @@ if(ROOT_opengl_FOUND)
endif()

#--stressHistogram------------------------------------------------------------------------------------
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.5.18.00.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
ROOT_EXECUTABLE(stressHistogram stressHistogram.cxx LIBRARIES Hist RIO)
ROOT_ADD_TEST(test-stresshistogram COMMAND stressHistogram FAILREGEX "FAILED|Error in" LABELS longtest)
ROOT_ADD_TEST(test-stresshistogram-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.cxx
FAILREGEX "FAILED|Error in" DEPENDS test-stresshistogram )
FAILREGEX "FAILED|Error in")

#--stressGUI---------------------------------------------------------------------------------------
if(ROOT_asimage_FOUND)
Expand Down
Binary file added test/linearIO.root
Binary file not shown.
Binary file added test/stressHistogram.5.18.00.root
Binary file not shown.
44 changes: 25 additions & 19 deletions test/stressHistogram.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
#include <random>
#include <cassert>

#ifdef __CLING__
const auto tmp_root_file_name = "tmp_hist_interpreted.root";
#else
const auto tmp_root_file_name = "tmp_hist.root";
#endif

using std::ostringstream, std::cout, std::endl, std::string;

const unsigned int __DRAW__ = 0;
Expand Down Expand Up @@ -132,7 +138,7 @@ enum RefFileEnum {

const int refFileOption = 1;
TFile * refFile = 0;
const char* refFileName = "http://root.cern/files/stressHistogram.5.18.00.root";
const char* refFileName = "./stressHistogram.5.18.00.root";

TRandom2 r;
// set to zero if want to run different numbers every time
Expand Down Expand Up @@ -2956,11 +2962,11 @@ bool testWriteRead1D()
h1->Fill(value, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
h1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );

bool ret = equals("Read/Write Hist 1D", h1, h2, cmpOptStats);
Expand All @@ -2984,11 +2990,11 @@ bool testWriteReadVar1D()
h1->Fill(value, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
h1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );

bool ret = equals("Read/Write VarH 1D", h1, h2, cmpOptStats);
Expand All @@ -3008,11 +3014,11 @@ bool testWriteReadProfile1D()
p1->Fill(x, y, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
p1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TProfile* p2 = static_cast<TProfile*> ( f2.Get("wr1D_p1") );

bool ret = equals("Read/Write Prof 1D", p1, p2, cmpOptStats);
Expand All @@ -3035,11 +3041,11 @@ bool testWriteReadProfileVar1D()
p1->Fill(x, y, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
p1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TProfile* p2 = static_cast<TProfile*> ( f2.Get("wr1D_p1") );

bool ret = equals("Read/Write VarP 1D", p1, p2, cmpOptStats);
Expand All @@ -3063,11 +3069,11 @@ bool testWriteRead2D()
h1->Fill(x, y, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
h1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TH2D* h2 = static_cast<TH2D*> ( f2.Get("wr2D_h1") );

bool ret = equals("Read/Write Hist 2D", h1, h2, cmpOptStats);
Expand All @@ -3090,11 +3096,11 @@ bool testWriteReadProfile2D()
p1->Fill(x, y, z, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
p1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TProfile2D* p2 = static_cast<TProfile2D*> ( f2.Get("wr2D_p1") );

bool ret = equals("Read/Write Prof 2D", p1, p2, cmpOptStats);
Expand All @@ -3120,11 +3126,11 @@ bool testWriteRead3D()
h1->Fill(x, y, z, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
h1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TH3D* h2 = static_cast<TH3D*> ( f2.Get("wr3D_h1") );

bool ret = equals("Read/Write Hist 3D", h1, h2, cmpOptStats);
Expand All @@ -3149,11 +3155,11 @@ bool testWriteReadProfile3D()
p1->Fill(x, y, z, t, 1.0);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
p1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
TProfile3D* p2 = static_cast<TProfile3D*> ( f2.Get("wr3D_p1") );

// In this particular case the statistics are not checked. The
Expand Down Expand Up @@ -3188,11 +3194,11 @@ bool testWriteReadHn()
s1->Fill(points);
}

TFile f("tmpHist.root", "RECREATE");
TFile f(tmp_root_file_name, "RECREATE");
s1->Write();
f.Close();

TFile f2("tmpHist.root");
TFile f2(tmp_root_file_name);
HIST* s2 = static_cast<HIST*> ( f2.Get("wrS-s1") );

bool ret = equals(TString::Format("Read/Write Hist %s", HIST::Class()->GetName()), s1, s2, cmpOptStats);
Expand Down
Loading
Loading