Previous: Determining Test Coverage, Up: Advanced Features



4.9 Test Logging

Check supports an operation to log the results of a test run. To use test logging, call the srunner_set_log() function with the name of the log file you wish to create:

     
     SRunner *sr;
     sr = srunner_create (make_s1_suite ());
     srunner_add_suite (sr, make_s2_suite ());
     srunner_set_log (sr, "test.log");
     srunner_run_all (sr, CK_NORMAL);

In this example, Check will write the results of the run to test.log. The print_mode argument to srunner_run_all() is ignored during test logging; the log will contain a result entry, organized by suite, for every test run. Here is an example of test log output:

     
     Running suite S1 
     ex_log_output.c:8:P:Core:test_pass: Test passed
     ex_log_output.c:14:F:Core:test_fail: Failure
     ex_log_output.c:18:E:Core:test_exit: (after this point) Early exit
     with return value 1
     Running suite S2 
     ex_log_output.c:26:P:Core:test_pass2: Test passed
     Results for all suites run:
     50%: Checks: 4, Failures: 1, Errors: 1