MCPcopy Create free account
hub / github.com/apache/mesos / SetUp

Method SetUp

3rdparty/libprocess/src/tests/process_tests.cpp:835–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833{
834protected:
835 void SetUp() override
836 {
837 // Spawn a process to coordinate with the subprocess (test-linkee).
838 // The `test-linkee` will send us a message when it has finished
839 // initializing and is itself ready to receive messages.
840 MessageEventProcess coordinator;
841 spawn(coordinator);
842
843 Future<Message> message;
844 EXPECT_CALL(coordinator, consume_(_))
845 .WillOnce(FutureArg<0>(&message));
846
847 // TODO(andschwa): Clean this up so that `BUILD_DIR` has the correct
848 // separator at compilation time.
849#ifdef __WINDOWS__
850 const std::string buildDir = strings::replace(BUILD_DIR, "/", "\\");
851#else
852 const std::string buildDir = BUILD_DIR;
853#endif // __WINDOWS__
854
855#ifdef __WINDOWS__
856 constexpr char LINKEENAME[] = "test-linkee.exe";
857#else
858 constexpr char LINKEENAME[] = "test-linkee";
859#endif // __WINDOWS__
860
861 const std::string linkeePath = path::join(buildDir, LINKEENAME);
862 ASSERT_TRUE(os::exists(linkeePath));
863
864 // NOTE: Because of the differences between Windows and POSIX
865 // shells when interpreting quotes, we use the second form of
866 // `subprocess` to call `test-linkee` directly with a set of
867 // arguments, rather than through the shell.
868 Try<Subprocess> s = process::subprocess(
869 linkeePath, {linkeePath, stringify(coordinator.self())});
870 ASSERT_SOME(s);
871 linkee = s.get();
872
873 // Wait until the subprocess sends us a message.
874 AWAIT_ASSERT_READY(message);
875
876 // Save the PID of the linkee.
877 pid = message->from;
878
879 terminate(coordinator);
880 wait(coordinator);
881 }
882
883 // Helper method to quickly reap the `linkee`.
884 // Subprocesses are reaped (via a non-blocking `waitpid` call) on

Callers

nothing calls this directly

Calls 10

replaceFunction · 0.85
spawnFunction · 0.50
joinFunction · 0.50
existsFunction · 0.50
subprocessFunction · 0.50
stringifyClass · 0.50
terminateFunction · 0.50
waitFunction · 0.50
selfMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected