#include <cerrno>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#include <sys/wait.h>
#include <unistd.h>
#include <cstring>
#include "boost/filesystem/convenience.hpp"
#include "boost/filesystem/path.hpp"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/TestHelper.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 (const std::string &shell, const std::string &script) |
|
int do_work |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
char ** |
env |
|
) |
| |
Definition at line 67 of file TestHelper.cc.
References python::arch, ExpressReco_HICollisions_FallBack::cerr, gather_cfg::cout, i, path(), and run_script().
Referenced by ptomaine().
69 bf::path currentPath(bf::initial_path().
string(), bf::no_check);
73 std::cout <<
"Usage: " << argv[0] <<
" shell subdir script1 script2 ... scriptN\n\n"
74 <<
"where shell is the path+shell (e.g., /bin/bash) intended to run the scripts\n"
75 <<
"and subdir is the subsystem/package/subdir in which the scripts are found\n"
76 <<
"(e.g., FWCore/Utilities/test)\n"
79 std::cout <<
"Current directory is: " << currentPath.native_directory_string() <<
'\n';
82 for (
int i = 0; env[
i] != 0; ++
i)
std::cout << env[
i] <<
'\n';
84 std::cout <<
"Executable name: " << argv[0] <<
'\n';
88 for (
int i = 0;
i < argc; ++
i)
90 std::cout <<
"argument " <<
i <<
": " << argv[
i] <<
'\n';
94 std::string shell(argv[1]);
95 std::cerr <<
"shell is: " << shell <<
'\n';
97 std::cout <<
"Current directory is: " << currentPath.native_directory_string() <<
'\n';
100 const char* topdir = getenv(
"SCRAMRT_LOCALRT");
101 if (!topdir) topdir = getenv(
"LOCALRT");
103 const char*
arch = getenv(
"SCRAM_ARCH");
108 bf::path exepath(argv[0], bf::no_check);
109 std::string maybe_arch = exepath.branch_path().leaf();
110 if (setenv(
"SCRAM_ARCH", maybe_arch.c_str(), 1) != 0)
112 std::cerr <<
"SCRAM_ARCH not set and attempt to set it failed\n";
115 arch = getenv(
"SCRAM_ARCH");
122 std::cout <<
"Neither SCRAMRT_LOCALRT nor LOCALRT is not defined" << std::endl;;
127 std::string testdir(topdir); testdir +=
"/src/"; testdir += argv[2];
128 std::string tmpdir(topdir); tmpdir+=
"/tmp/"; tmpdir+=
arch;
129 std::string testbin(topdir); testbin+=
"/test/"; testbin+=
arch;
131 std::cout <<
"topdir is: " << topdir <<
'\n';
132 std::cout <<
"testdir is: " << testdir <<
'\n';
133 std::cout <<
"tmpdir is: " << tmpdir <<
'\n';
134 std::cout <<
"testbin is: " << testbin <<
'\n';
137 if (setenv(
"LOCAL_TEST_DIR",testdir.c_str(),1)!=0)
139 std::cerr <<
"Could not set LOCAL_TEST_DIR to " << testdir << std::endl;;
142 if (setenv(
"LOCAL_TMP_DIR",tmpdir.c_str(),1)!=0)
144 std::cerr <<
"Could not set LOCAL_TMP_DIR to " << tmpdir << std::endl;;
147 if (setenv(
"LOCAL_TOP_DIR",topdir,1)!=0)
149 std::cerr <<
"Could not set LOCAL_TOP_DIR to " << topdir << std::endl;;
152 if (setenv(
"LOCAL_TEST_BIN",testbin.c_str(),1)!=0)
154 std::cerr <<
"Could not set LOCAL_TEST_BIN to " << testbin << std::endl;;
160 for(
int i=3;
i<argc && rc==0; ++
i)
162 std::string scriptname(testdir);
163 scriptname += argv[
i];
164 std::cout <<
"Running script: " << scriptname << std::endl;
168 std::cout <<
"status = " << rc << std::endl;;
169 return rc == 0 ? 0 : -1;
int run_script(const std::string &shell, const std::string &script)
int ptomaine |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
char ** |
env |
|
) |
| |
int run_script |
( |
const std::string & |
shell, |
|
|
const std::string & |
script |
|
) |
| |