1

When I pass in the -p option I get the error

-p doesn't work on this platform, as it is lacking fork.

But then when I add test code for fork() I have no problem

#include <iostream>

#include "CppUTest/CommandLineTestRunner.h"
#include "MemoryLeakDetectorNewMacros.h"

int main(int argc, char** argv)
{
    pid_t pid = fork();

    if (pid < 0) {
        printf("Fork failed\n");
        return 1;
    }

    if (pid == 0) {
        printf("This is the child process. PID=%d\n", getpid());
    } else {
        printf("This is the parent process. PID=%d, Child PID=%d\n", getpid(), pid);
        int ret = 0;    
        //ret = CommandLineTestRunner::RunAllTests(argc, argv);
    }
    return 0;
}

This is the parent process. PID=17605, Child PID=17606 This is the child process. PID=17606

$ sudo apt list | grep cpputest

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

cpputest/jammy,now 4.0-2 all [installed]
libcpputest-dev/jammy,now 4.0-2 amd64 [installed,automatic]
Bob
  • 4,576
  • 7
  • 39
  • 107
  • 2
    Looks like [`check_cxx_symbol_exists(fork "unistd.h" CPPUTEST_HAVE_FORK)`](https://github.com/cpputest/cpputest/blob/b6d4341f8fa382014563c6f15a7a07607c6bf888/CMakeLists.txt#L109) is probably failing – Alan Birtles May 30 '23 at 17:35

0 Answers0