diff options
author | Robert Guo <robert.guo@10gen.com> | 2016-12-05 10:37:54 -0500 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2017-01-10 11:13:47 -0500 |
commit | 8478c3b4f7c2e2e8804ca4f5a3847b07a71fd9b3 (patch) | |
tree | a262a463b1a1beff454b65fb2e151d573712dd09 /src/mongo/shell/shell_utils_launcher.cpp | |
parent | d4a7012d56ecfdc12a83775f9b68d14bfe260868 (diff) | |
download | mongo-8478c3b4f7c2e2e8804ca4f5a3847b07a71fd9b3.tar.gz |
SERVER-22348 propagate binary paths from resmoke to MongoRunner
Diffstat (limited to 'src/mongo/shell/shell_utils_launcher.cpp')
-rw-r--r-- | src/mongo/shell/shell_utils_launcher.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index 55ee501c10a..8c1efb65a2d 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -260,24 +260,29 @@ void ProgramOutputMultiplexer::clear() { } ProgramRunner::ProgramRunner(const BSONObj& args, const BSONObj& env) { - verify(!args.isEmpty()); + uassert(ErrorCodes::FailedToParse, + "cannot pass an empty argument to ProgramRunner", + !args.isEmpty()); string program(args.firstElement().valuestrsafe()); - verify(!program.empty()); + uassert(ErrorCodes::FailedToParse, + "invalid program name passed to ProgramRunner", + !program.empty()); boost::filesystem::path programPath = findProgram(program); + boost::filesystem::path programName = programPath.stem(); string prefix("mongod-"); - bool isMongodProgram = - string("mongod") == program || program.compare(0, prefix.size(), prefix) == 0; + bool isMongodProgram = string("mongod") == programName || + programName.string().compare(0, prefix.size(), prefix) == 0; prefix = "mongos-"; - bool isMongosProgram = - string("mongos") == program || program.compare(0, prefix.size(), prefix) == 0; + bool isMongosProgram = string("mongos") == programName || + programName.string().compare(0, prefix.size(), prefix) == 0; if (isMongodProgram) { _name = "d"; } else if (isMongosProgram) { _name = "s"; - } else if (program == "mongobridge") { + } else if (programName == "mongobridge") { _name = "b"; } else { _name = "sh"; @@ -356,7 +361,7 @@ ProgramRunner::ProgramRunner(const BSONObj& args, const BSONObj& env) { ++environEntry; } #endif - bool needsPort = isMongodProgram || isMongosProgram || (program == "mongobridge"); + bool needsPort = isMongodProgram || isMongosProgram || (programName == "mongobridge"); if (!needsPort) { _port = -1; } @@ -475,6 +480,11 @@ boost::filesystem::path ProgramRunner::findProgram(const string& prog) { } #endif + // The file could exist if it is specified as a full path. + if (p.is_absolute() && boost::filesystem::exists(p)) { + return p; + } + // Check if the binary exists in the current working directory boost::filesystem::path t = boost::filesystem::current_path() / p; if (boost::filesystem::exists(t)) { |