Skip to content

Commit

Permalink
Merge pull request #27723 from smuzaffar/fix-ExpressionEvaluatorUnitTest
Browse files Browse the repository at this point in the history
Fix expression evaluator unit test
  • Loading branch information
cmsbuild authored Aug 11, 2019
2 parents 9db60f5 + d0fb95f commit c80860c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions CommonTools/Utils/src/ExpressionEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace {
return n1;
}

void remove(std::string const& name) {
std::string sfile = "/tmp/" + name + ".cc";
std::string ofile = "/tmp/" + name + ".so";
void remove(std::string const& name, std::string const& tmpDir = "/tmp") {
std::string sfile = tmpDir + "/" + name + ".cc";
std::string ofile = tmpDir + "/" + name + ".so";

std::string rm = "rm -f ";
rm += sfile + ' ' + ofile;
Expand All @@ -55,13 +55,13 @@ namespace reco {
pch += "/src/precompile.h";
std::string quote("\"");

std::string sfile = "/tmp/" + m_name + ".cc";
std::string ofile = "/tmp/" + m_name + ".so";

auto arch = edm::getEnvironmentVariable("SCRAM_ARCH");
auto baseDir = edm::getEnvironmentVariable("CMSSW_BASE");
auto relDir = edm::getEnvironmentVariable("CMSSW_RELEASE_BASE");

std::string sfile = baseDir + "/tmp/" + m_name + ".cc";
std::string ofile = baseDir + "/tmp/" + m_name + ".so";

std::string incDir = "/include/" + arch + "/";
std::string cxxf;
{
Expand Down Expand Up @@ -144,16 +144,16 @@ namespace reco {

void* dl = dlopen(ofile.c_str(), RTLD_LAZY);
if (!dl) {
remove(m_name);
remove(m_name, baseDir + "/tmp");
throw cms::Exception("ExpressionEvaluator",
std::string("compilation/linking failed\n") + cpp + ss + "dlerror " + dlerror());
return;
}

m_expr = dlsym(dl, factory.c_str());
remove(m_name);
remove(m_name, baseDir + "/tmp");
}

ExpressionEvaluator::~ExpressionEvaluator() { remove(m_name); }
ExpressionEvaluator::~ExpressionEvaluator() { remove(m_name, edm::getEnvironmentVariable("CMSSW_BASE") + "/tmp"); }

} // namespace reco
2 changes: 1 addition & 1 deletion CommonTools/Utils/test/ExpressionEvaluatorUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main() {
}

try {
std::string cut = "bool operator()(int i, int j) override { return i<10&& j<5; }";
std::string cut = "bool operator()(int i, int j) const override { return i<10&& j<5; }";
auto const& mcut =
*reco_expressionEvaluator("CommonTools/Utils", SINGLE_ARG(reco::genericExpression<bool, int, int>), cut);
std::cout << mcut(2, 7) << ' ' << mcut(3, 4) << std::endl;
Expand Down

0 comments on commit c80860c

Please sign in to comment.