Skip to content

Commit

Permalink
Update from 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator committed Oct 24, 2021
1 parent 85374e8 commit b826817
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 43 deletions.
69 changes: 45 additions & 24 deletions materials/instructions_for_testing.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
# Instructions for running tests.

In addition to testing for correct output data, the autotest system will
check your program and its source code for the style:

* **Style tests.** To check how much the beauty of your code matches
for example, you can test your code using the script ```materials/linters/cpplint.py```.
The ```materials/linters``` folder also contains the ```CPPLINT.cfg``` file, which contains
the necessary filters-settings for the style test. The script works in such a way that this
configuration file extends its action to all files that lie with it in the directory
or in the directories below. So in order for these settings to apply to your source code files,
copy ```CPPLINT. cfg``` to the ```src``` folder. \
\
To run the script, run the following command: \
```python3 materials/linters/cpplint.py --extensions=c src/sourcefile_name.c``` \
\
Important! To run, you need python version 3. Check the installed version on
you can download the version using the command ```python3 --version```.
To download python3, enter one of the following commands in the terminal: \
```brew install python3``` \
or if you have root rights (for Ubuntu / Linux Mint / Debian) \
```sudo apt install python3```

* Also, be very careful with memory leaks! The testing system checks for this as well.
# Instructions for running tests.

In addition to testing for correct output data, the autotest system will
check your program and its source code for the following points:

* **Style tests.** To check how much the beauty of your code matches
for example, you can test your code using the script ```materials/linters/cpplint.py```.
The ```materials/linters``` folder also contains the ```CPPLINT.cfg``` file, which contains
the necessary filters-settings for the style test. The script works in such a way that this
configuration file extends its action to all files that lie with it in the directory
or in the directories below. So in order for these settings to apply to your source code files,
copy ```CPPLINT. cfg``` to the ```src``` folder. \
\
To run the script, run the following command: \
```python3 materials/linters/cpplint.py --extensions=c src/sourcefile_name.c``` \
\
Important! To run, you need python version 3. Check the installed version on
you can download the version using the command ```python3 --version```.
To download python3, enter one of the following commands in the terminal: \
```brew install python3``` \
or if you have root rights (for Ubuntu / Linux Mint / Debian) \
```sudo apt install python3```


* **Test for correct operation with memory.** When writing C programs, it is very important to watch for memory leaks. To do this the _valgrind_ utility is quite often used in Unix-like operating systems. However OS X has some troubles with valgrind support, so it is possible to use _leaks_ utility instead. Go into we will not discuss the mechanism of their operation now - if you are interested, you can read about it on Google.

To run your executable file using this utility, type in the terminal: \
```leaks -atExit -- ./main.out | grep LEAK:```

Pay your attention that there is ```| grep LEAK:``` command. We use it to short leaks output to see only lines with leaks if they are there. If you want to see the whole output, just remove this command.

When you run your executable file using _leaks_ you may see an error:
>dyld: could not load inserted library ‘/usr/local/lib/libLeaksAtExit.dylib’ because image not found
It’s because _leaks_ did not find _libLeaksAtExit.dylib_ library. \
You need to type the following commands in this case.
```sh
cd /usr/local/lib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib
```

_Additionally:_ \
Use the ```-exclude``` option of _leaks_ to filter out leaks in functions with known memory leaks.
This option helps reduce the amount of extra information reported by _leaks_.

58 changes: 39 additions & 19 deletions materials/instructions_for_testing_rus.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
# Инструкция по запуску тестов.

Помимо тестов на корректные выходные данные система автотестирования будет
проверять вашу программу и ее исходный код на стиль:

* **Стилевые тесты.** Чтобы проверить, насколько красота вашего кода соответствует
стандартам, вы можете протестировать ваш код с помощью скрипта ```materials/linters/cpplint.py```. В папке ```materials/linters``` также лежит файл ```CPPLINT.cfg```, который содержит необходимые фильтры-настройки для стилевого теста. Скрипт работает таким образом, что данный конфигурационный файл распространяет свое действие на все файлы, которые лежат с ним в директории или в директориях ниже. Поэтому, чтобы данные настройки применились к вашим файлам с исходным кодом, скопируйте ```CPPLINT.cfg``` в папку src. \
\
Чтобы запустить скрипт, выполните следующую команду: \
```python3 materials/linters/cpplint.py --extensions=c src/sourcefile_name.c``` \
\
Важно! Для запуска вам необходим python версии 3. Проверить установленную на
компьютере версию можно с помощью команды ```python3 --version```
Чтобы скачать python3, введите в терминал одну из следующих команд: \
```brew install python3``` \
или, если у вас есть root-права (для Ubuntu / Linux Mint / Debian) \
```sudo apt install python3```

* Так же будьте очень внимательны с утечками памяти! Тестирующая система проверяет и на это.
# Инструкция по запуску тестов.

Помимо тестов на корректные выходные данные система автотестирования будет
проверять вашу программу и ее исходный код по следующим пунктам:

* **Стилевые тесты.** Чтобы проверить, насколько красота вашего кода соответствует
стандартам, вы можете протестировать ваш код с помощью скрипта ```materials/linters/cpplint.py```. В папке ```materials/linters``` также лежит файл ```CPPLINT.cfg```, который содержит необходимые фильтры-настройки для стилевого теста. Скрипт работает таким образом, что данный конфигурационный файл распространяет свое действие на все файлы, которые лежат с ним в директории или в директориях ниже. Поэтому, чтобы данные настройки применились к вашим файлам с исходным кодом, скопируйте ```CPPLINT.cfg``` в папку src. \
\
Чтобы запустить скрипт, выполните следующую команду: \
```python3 materials/linters/cpplint.py --extensions=c src/sourcefile_name.c``` \
\
Важно! Для запуска вам необходим python версии 3. Проверить установленную на
компьютере версию можно с помощью команды ```python3 --version```
Чтобы скачать python3, введите в терминал одну из следующих команд: \
```brew install python3``` \
или, если у вас есть root-права (для Ubuntu / Linux Mint / Debian) \
```sudo apt install python3```


* **Тест на корректную работу с памятью.** При написании C-программ очень важно следить за утечками памяти. Для этого в Unix-подобных операционных системах довольно часто используют утилиту _valgrind_. Однако, на OS X имеются проблемы с поддержкой valgrind, поэтому вместо нее можно использовать утилиту _leaks_. Вдаваться в механизм работы этих утилит мы сейчас не будем - если интересно, можете почитать в гугле.

Чтобы запустить ваш исполняемый файл с помощью этой утилиты, наберите в терминале: \
```leaks -atExit -- ./main.out | grep LEAK:```

Обратите внимание на команду ```| grep LEAK:```. Мы используем ее для короткого вывода, чтобы видеть только линии с утечками, если они есть. Если вы хотите увидеть весь вывод, просто удалите эту команду.

При запуске исполняемого файла с помощью _leaks_ может появиться сообщение об ошибке:
>dyld: could not load inserted library ‘/usr/local/lib/libLeaksAtExit.dylib’ because image not found
Ошибка возникает из-за того, что _leaks_ не может найти библиотеку _libLeaksAtExit.dylib_. \
В этом случае вам необходимо ввести следующие команды:
```sh
cd /usr/local/lib
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib
```

_Дополнительно:_ \
Используйте флаг ```-exclude``` утилиты _leaks_ для того, чтобы отфильтровать утечки в функциях, где известно об утечках памяти. Этот флаг позволяет уменьшить количество посторонней информации, сообщаемой _leaks_.

0 comments on commit b826817

Please sign in to comment.