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

34 Views Asked by At

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]
0

There are 0 best solutions below