#include <cerrno>
#include <cstdlib>
#include <exception>
#include <filesystem>
#include <iostream>
#include <string>
#include <sys/wait.h>
#include <unistd.h>
#include <cstring>
#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 56 of file TestHelper.cc.
57 bf::path currentPath(bf::current_path().
string());
60 std::cout <<
"Usage: " <<
argv[0] <<
" shell subdir script1 script2 ... scriptN\n\n"
61 <<
"where shell is the path+shell (e.g., /bin/bash) intended to run the scripts\n"
62 <<
"and subdir is the subsystem/package/subdir in which the scripts are found\n"
63 <<
"(e.g., FWCore/Utilities/test)\n"
66 std::cout <<
"Current directory is: " << currentPath.string() <<
'\n';
69 for (
int i = 0;
env[
i] !=
nullptr; ++
i)
76 char const* goodDirectory =
"[A-Za-z0-9/_.-]+";
78 for (
int i = 0;
i <
argc; ++
i) {
85 std::cout <<
"Current directory is: " << currentPath.string() <<
'\n';
88 char const* topdir = std::getenv(
"SCRAMRT_LOCALRT");
90 topdir = std::getenv(
"LOCALRT");
93 std::cerr <<
"Invalid top directory '" << topdir <<
"'" << std::endl;
96 }
catch (std::runtime_error
const&
e) {
97 std::cerr <<
"Invalid top directory '" << topdir <<
"'" << std::endl;
102 char const* arch = std::getenv(
"SCRAM_ARCH");
107 std::string maybe_arch = exepath.parent_path().filename().string();
109 if (setenv(
"SCRAM_ARCH", maybe_arch.c_str(), 1) != 0) {
110 std::cerr <<
"SCRAM_ARCH not set and attempt to set it failed\n";
113 arch = std::getenv(
"SCRAM_ARCH");
119 std::cerr <<
"Neither SCRAMRT_LOCALRT nor LOCALRT is defined" << std::endl;
125 std::cerr <<
"Invalid test directory '" <<
argv[2] <<
"'" << std::endl;
128 }
catch (std::runtime_error
const&
e) {
129 std::cerr <<
"Invalid test directory '" <<
argv[2] <<
"'" << std::endl;
144 std::cout <<
"topdir is: " << topdir <<
'\n';
145 std::cout <<
"testdir is: " << testdir <<
'\n';
146 std::cout <<
"tmpdir is: " << tmpdir <<
'\n';
147 std::cout <<
"testbin is: " << testbin <<
'\n';
149 if (setenv(
"LOCAL_TEST_DIR", testdir.c_str(), 1) != 0) {
150 std::cerr <<
"Could not set LOCAL_TEST_DIR to " << testdir << std::endl;
153 if (setenv(
"LOCAL_TMP_DIR", tmpdir.c_str(), 1) != 0) {
154 std::cerr <<
"Could not set LOCAL_TMP_DIR to " << tmpdir << std::endl;
157 if (setenv(
"LOCAL_TOP_DIR", topdir, 1) != 0) {
158 std::cerr <<
"Could not set LOCAL_TOP_DIR to " << topdir << std::endl;
161 if (setenv(
"LOCAL_TEST_BIN", testbin.c_str(), 1) != 0) {
162 std::cerr <<
"Could not set LOCAL_TEST_BIN to " << testbin << std::endl;
168 for (
int i = 3;
i <
argc && rc == 0; ++
i) {
170 scriptname +=
argv[
i];
171 std::cout <<
"Running script: " << scriptname << std::endl;
175 std::cout <<
"status = " << rc << std::endl;
176 return rc == 0 ? 0 : -1;
References dir2webdir::argc, cmsBatch::argv, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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 |
|
) |
| |