Francois Gouget a écrit :
On Fri, 29 Mar 2002, Eric Pouech wrote: For the parameter testing I was thinking of storing the expected argv parameters in environment variables. Then, we need a way to tell the child to do specific tests (maybe one more environment variable) and it would then compare the contents of the environment variables with what it got.
But since we do not control the main/WinMain, we would have to rely on getmainargs or __argv, __argp tricks (which means parts of the test may only be possible in msvcrt).
I don't follow you... we got access to main (what is missing is just letting the test procs access argc/argv pair
The approach above would probably not work testing environment variable passing. So alternately, since the two share the same code, you could instruct the child to expect to receive the data corresponding to global array 5.
anyway, since the test program is a CUI, the proposed scheme doesn't test either the WinMain part only the argc/argv part of main (the rest of the parsing is either in msvcrt or shell32 (for the unicode part))
I decided to let the parent do the checking because: - you don't know what the stdout of the child will be (and if you'll be able to get the results on the console) - make process depends on result of the parent for success/failure
anyway, any test would be compare data (or behavior) from parent and child which means that you need a way to pass data from one to the other for the reason explained above, I think it's better to let the parent do the final testing.
anyway, it may show that the child being only the same process as the parent with different arguments fails for: - CUI and GUI testing - independance of crt0
as I said, I choose the temp file because it's independent of any of the other bits (I mainly use the unix C lib) other ways would include: - env variables (but you may have limitations on the length of the var...) - registry (that would be, in term of coding, much more cleaner, but would require handle inheritance for testing the process creation...) - shared mem... so, a mechanism used by two processes. so I'd rather test the process creation first, and then the IPC mechanisms
A+