test: Replace "/proc/self/exe" with path to test binary
When tests are run under valgrind, /proc/self/exe points to valgrind, not to the test binary. This results in failures for tests that need to fork processes. Fix it by replacing "/proc/self/exe" with the path to the test binary. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
b24d9c4413
commit
59002a9e9d
5 changed files with 7 additions and 8 deletions
|
@ -180,7 +180,7 @@ protected:
|
|||
}
|
||||
|
||||
/* Test size(). */
|
||||
file.setFileName("/proc/self/exe");
|
||||
file.setFileName(self());
|
||||
|
||||
if (file.size() >= 0) {
|
||||
cerr << "File has valid size before open" << endl;
|
||||
|
@ -277,7 +277,7 @@ protected:
|
|||
file.close();
|
||||
|
||||
/* Test mapping and unmapping. */
|
||||
file.setFileName("/proc/self/exe");
|
||||
file.setFileName(self());
|
||||
file.open(File::OpenModeFlag::ReadOnly);
|
||||
|
||||
Span<uint8_t> data = file.map();
|
||||
|
|
|
@ -209,8 +209,7 @@ protected:
|
|||
|
||||
if (!pid_) {
|
||||
std::string arg = std::to_string(fd);
|
||||
execl("/proc/self/exe", "/proc/self/exe",
|
||||
arg.c_str(), nullptr);
|
||||
execl(self().c_str(), self().c_str(), arg.c_str(), nullptr);
|
||||
|
||||
/* Only get here if exec fails. */
|
||||
exit(TestFail);
|
||||
|
@ -464,7 +463,7 @@ private:
|
|||
|
||||
int prepareFDs(IPCUnixSocket::Payload *message, unsigned int num)
|
||||
{
|
||||
int fd = open("/proc/self/exe", O_RDONLY);
|
||||
int fd = open(self().c_str(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ protected:
|
|||
|
||||
int run()
|
||||
{
|
||||
ipc_ = std::make_unique<IPCPipeUnixSocket>("", "/proc/self/exe");
|
||||
ipc_ = std::make_unique<IPCPipeUnixSocket>("", self().c_str());
|
||||
if (!ipc_->isConnected()) {
|
||||
cerr << "Failed to create IPCPipe" << endl;
|
||||
return TestFail;
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
vector<std::string> args;
|
||||
args.push_back(to_string(exitCode));
|
||||
args.push_back(to_string(num_));
|
||||
int ret = proc_.start("/proc/self/exe", args);
|
||||
int ret = proc_.start(self(), args);
|
||||
if (ret) {
|
||||
cerr << "failed to start process" << endl;
|
||||
return TestFail;
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
proc_.kill();
|
||||
|
||||
/* Test starting the process and retrieving the exit code. */
|
||||
int ret = proc_.start("/proc/self/exe", args);
|
||||
int ret = proc_.start(self(), args);
|
||||
if (ret) {
|
||||
cerr << "failed to start process" << endl;
|
||||
return TestFail;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue