#include <cerrno>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#include <sys/wait.h>
#include <unistd.h>
#include <cstring>
#include "boost/version.hpp"
#include "boost/filesystem/convenience.hpp"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/RegexMatch.h"
#include "FWCore/Utilities/interface/TestHelper.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
Go to the source code of this file.
|
int | do_work (int argc, char *argv[], char **env) |
|
int | ptomaine (int argc, char *argv[], char **env) |
|
int | run_script (std::string const &shell, std::string const &script) |
|
◆ do_work()
int do_work |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
char ** |
env |
|
) |
| |
Definition at line 58 of file TestHelper.cc.
59 bf::path currentPath(bf::initial_path().
string());
62 std::cout <<
"Usage: " <<
argv[0] <<
" shell subdir script1 script2 ... scriptN\n\n"
63 <<
"where shell is the path+shell (e.g., /bin/bash) intended to run the scripts\n"
64 <<
"and subdir is the subsystem/package/subdir in which the scripts are found\n"
65 <<
"(e.g., FWCore/Utilities/test)\n"
68 std::cout <<
"Current directory is: " << currentPath.string() <<
'\n';
71 for (
int i = 0;
env[
i] !=
nullptr; ++
i)
78 char const* goodDirectory =
"[A-Za-z0-9/_.-]+";
80 for (
int i = 0;
i <
argc; ++
i) {
87 std::cout <<
"Current directory is: " << currentPath.string() <<
'\n';
90 char const* topdir = std::getenv(
"SCRAMRT_LOCALRT");
92 topdir = std::getenv(
"LOCALRT");
95 std::cerr <<
"Invalid top directory '" << topdir <<
"'" << std::endl;
98 }
catch (std::runtime_error
const&
e) {
99 std::cerr <<
"Invalid top directory '" << topdir <<
"'" << std::endl;
104 char const* arch = std::getenv(
"SCRAM_ARCH");
109 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 47
110 std::string maybe_arch = exepath.parent_path().filename().string();
112 std::string maybe_arch = exepath.branch_path().leaf();
114 if (setenv(
"SCRAM_ARCH", maybe_arch.c_str(), 1) != 0) {
115 std::cerr <<
"SCRAM_ARCH not set and attempt to set it failed\n";
118 arch = std::getenv(
"SCRAM_ARCH");
124 std::cerr <<
"Neither SCRAMRT_LOCALRT nor LOCALRT is defined" << std::endl;
130 std::cerr <<
"Invalid test directory '" <<
argv[2] <<
"'" << std::endl;
133 }
catch (std::runtime_error
const&
e) {
134 std::cerr <<
"Invalid test directory '" <<
argv[2] <<
"'" << std::endl;
149 std::cout <<
"topdir is: " << topdir <<
'\n';
150 std::cout <<
"testdir is: " << testdir <<
'\n';
151 std::cout <<
"tmpdir is: " << tmpdir <<
'\n';
152 std::cout <<
"testbin is: " << testbin <<
'\n';
154 if (setenv(
"LOCAL_TEST_DIR", testdir.c_str(), 1) != 0) {
155 std::cerr <<
"Could not set LOCAL_TEST_DIR to " << testdir << std::endl;
158 if (setenv(
"LOCAL_TMP_DIR", tmpdir.c_str(), 1) != 0) {
159 std::cerr <<
"Could not set LOCAL_TMP_DIR to " << tmpdir << std::endl;
162 if (setenv(
"LOCAL_TOP_DIR", topdir, 1) != 0) {
163 std::cerr <<
"Could not set LOCAL_TOP_DIR to " << topdir << std::endl;
166 if (setenv(
"LOCAL_TEST_BIN", testbin.c_str(), 1) != 0) {
167 std::cerr <<
"Could not set LOCAL_TEST_BIN to " << testbin << std::endl;
173 for (
int i = 3;
i <
argc && rc == 0; ++
i) {
175 scriptname +=
argv[
i];
176 std::cout <<
"Running script: " << scriptname << std::endl;
180 std::cout <<
"status = " << rc << std::endl;
181 return rc == 0 ? 0 : -1;
References dir2webdir::argc, cmsBatch::argv, beam_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, MillePedeFileConverter_cfg::e, web.browse_db::env, mps_fire::i, castor_dqm_sourceclient_file_cfg::path, run_script(), fileinputsource_cfi::shell, AlCaHLTBitMon_QueryRunRegistry::string, and edm::untaintString().
Referenced by ptomaine().
◆ ptomaine()
int ptomaine |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
char ** |
env |
|
) |
| |
◆ run_script()
int run_script |
( |
std::string const & |
shell, |
|
|
std::string const & |
script |
|
) |
| |