Frage

I have my own Boost Test Runner where I pass the arguments to unit_test_main like this:

char *myargs[] = {"", "--log_level=test_suite", "report_level=detailed", "output_format=xml", "--run_test=my_manual_test_suite1,my_manual_test_suite2"};

The test suites are picked up, the test cases are executed. However, at the end of my program execution, I get a memory corruption. Is there a reason why?

My test runner is a single cpp file which houses all the test cases and also the unit_test_main.

EDIT: I forgot to add there is no corruption if I pass the arguments from outside my program. This is weird.

War es hilfreich?

Lösung

Can you share some more code? I want to see the difference you made in passing the arguments locally vs. passing them from outside the program.

EDIT:

Ok, I think I got the problem. When you pass in arguments from outside they are laid out sequentially. For example lets say you call test.exe --log_level=all --run_test=mt1. The address of the first arg is 0x10000, say. Then the address of the next arg --log_level=all begins at 0x10009 and so on. When you string up the argv yourself, this is not the case. So my suggestion would be to lay the arguments sequentially like above and give it a try.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top