Valgrind

Valgrind can detect memory problems that are common in C and C++ programs and which can lead to program crashes and unpredictable behavior. Valgrind grader checks that no such errors were found in the code.

Memory leaks checked by Valgrind are detected with the following command:

valgrind --leak-check=full EXECUTABLE

The executable program should be compiled in debug mode, then the error messages are more understandable. For a more comprehensive list of possible errors and their causes, see <https://valgrind.org/docs/manual/mc-manual.html#mc-manual.errormsgs>_

To emulate the Valgrind grader and its method for testing students’ code, follow the procedure outlined below. The grader initiates the process by preparing a test file:

echo testread \"integration-compulsory/test-00-compulsory-in.txt\" \"integration-compulsory/test-00-compulsory-out.txt\" > valgrind_test.txt

Then it runs the following test with the executable ”prg1”:

valgrind --leak-check=full ./prg1 valgrind_test.txt  >./program_out.txt 2>./program_err.txt; cat program_err.txt

The standard output is directed to a file program_out.txt, errors to the file program_err.txt. The error file is also printed for the user to check, if any errors, the Valgrind grader will not pass.

Any Valgrind error will halve the points or drop them to 200p, i.e., max(half, 200p).

A+ esittää tässä kohdassa tehtävän palautuslomakkeen.

Posting submission...