So im working on making an automated test for some code. There is an executable run from the command line called “cmdLineProc”.
Im making my test programs in C++ (not using Python or that cos theres an API we use that speeds these tests up).
The command line arguments are made in the test as strings and passed to a function that uses CreateProcess to run cmdLineProc..
This works fine. I can call cmdLineProc and it works and the tests pass. But only when theres not an error returned.
When testing I obv need to check that things are failing when they are supposed to as well. in these cases cmdLineProc returns an error value.
So if i run cmdLineProc on the command line with parameters that will make it fail, i get a message saying “Error, Failed: -3” where -3 is an error code.
But when i run this through the C++ test using CreateProcess I get a problem. The CreateProcess just fails and returns -1, the code to say it failed. It gives no indication of why it failed.
I use GetExitCodeProcess to get the termination status of the cmdLineProc.
Anyone know if its possible to get the error value from cmdLineProc returned back using this method? If not does anyone know how i might go about implementing this?
GetExitCodeProcess returns the exit code of the run process. If you see another error displayed when you run the program then the created process is simply writing another error to stdout.
In that case you’ll have to parse the output of the created process.
You can see how that is done here.