diff --git a/content/assignments/memory-allocator/README.md b/content/assignments/memory-allocator/README.md index 5e7f03a4e4..02ebb39886 100644 --- a/content/assignments/memory-allocator/README.md +++ b/content/assignments/memory-allocator/README.md @@ -23,7 +23,7 @@ The test suite consists of `.c` files that will be dynamically linked to your li You can find the sources in the `tests/snippets/` directory. The results of the previous will also be stored in `tests/snippets/` and the reference files are in the `tests/ref/` directory. -The automated checking is performed using `run-tests.py`. +The automated checking is performed using `run_tests.py`. It runs each test and compares the syscalls made by the `os_*` functions with the reference file, providing a diff if the test failed. ## API @@ -180,9 +180,39 @@ gcc -shared -o libosmem.so osmem.o helpers.o ../utils/printf.o ## Testing and Grading -The testing is automated and performed with the `run-tests.py` script from the `tests/` directory. +Testing is automated. +Tests are located in the `tests/` directory: -Before running `run-tests.py`, you first have to build `libosmem.so` in the `src/` directory and generate the test binaries in `tests/snippets`. +```console +student@so:~/.../mem-alloc/tests$ ls -F +Makefile grade.sh@ ref/ run_tests.py snippets/ +``` + +To test and grade your assignment solution, enter the `tests/` directory and run `grade.sh`. +Note that this requires linters being available. +The easiest is to use a Docker-based setup with everything installed, as shown in the section ["Running the Linters"](#running-the-linters). +When using `grade.sh` you will get grades for correctness (maximum `90` points) and for coding style (maximum `10` points). +A successful run will provide you an output ending with: + +```console +### GRADE + + +Checker: 90/ 90 +Style: 10/ 10 +Total: 100/100 + + +### STYLE SUMMARY + + +``` + +### Running the Checker + +To run only the checker, use the `run_tests.py` script from the `tests/` directory. + +Before running `run_tests.py`, you first have to build `libosmem.so` in the `src/` directory and generate the test binaries in `tests/snippets`. You can do so using the all-in-one `Makefile` rule from `tests/`: `make check`. ```console @@ -243,29 +273,45 @@ test-all ........................ passed ... 5 Total: 90/100 ``` -**NOTE:** By default, `run-test.py` checks for memory leaks, which can be time-consuming. -To speed up testing, use the `-d` flag or `make check-fast` to skip memory leak checks, but remember to run `make check` before submitting your assignment to ensure it meets all criteria. +**NOTE:** By default, `run_tests.py` checks for memory leaks, which can be time-consuming. +To speed up testing, use the `-d` flag or `make check-fast` to skip memory leak checks. + +### Running the Linters + +To run the linters, use the `make lint` command in the `tests/` directory. +Note that the linters have to be installed on your system: [`checkpatch.pl`](https://.com/torvalds/linux/blob/master/scripts/checkpatch.pl), [`cpplint`](https://github.com/cpplint/cpplint), [`shellcheck`](https://www.shellcheck.net/) with certain configuration options. +It's easiest to run them in a Docker-based setup with everything configured: + +```console +student@so:~/.../mem-alloc/tests$ make lint +[...] +cd .. && checkpatch.pl -f checker/*.sh tests/*.sh +[...] +cd .. && cpplint --recursive src/ tests/ checker/ +[...] +cd .. && shellcheck checker/*.sh tests/*.sh +``` ### Debugging -`run-tests.py` uses `ltrace` to capture all the libcalls and syscalls performed. +`run_tests.py` uses `ltrace` to capture all the libcalls and syscalls performed. The output of `ltrace` is formatted to show only top level library calls and nested system calls. For consistency, the heap start and addresses returned by `mmap()` are replaced with labels. Every other address is displayed as `