Skip to content

Hw2#3

Open
Elderly-AI wants to merge 42 commits intomasterfrom
HW2
Open

Hw2#3
Elderly-AI wants to merge 42 commits intomasterfrom
HW2

Conversation

@Elderly-AI
Copy link
Copy Markdown
Owner

No description provided.

@Elderly-AI Elderly-AI requested a review from leshiy1295 October 26, 2019 10:19
addons:
apt:
packages:
- valgrind
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valfrind на CI выдал большое количество ошибок

- gcc --coverage -g -Wall -Wextra -std=c11 fork_test.c -L. -lfork_patterns -lpatterns -o fork_test
- LD_LIBRARY_PATH="." time ./test
- LD_LIBRARY_PATH="." time ./fork_test
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cpplint --filter=-readability,-whitespace,-legal/copyright,-build *.c *.h ; fi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чтобы не копировать if постоянно - можно было бы вынести в отдельный скрипт

}
}

pid_t *pid = (pid_t *)malloc(core_count * sizeof(pid_t));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что если malloc вернёт ошибку?


for (size_t c = 0; c < array_size; ++c) {
if (array[c] == NULL) {
exit(EINVAL);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

делать exit внутри цикла - моветон

}

if (pid[c] == 0) {
close(fd[0]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стоило вынести обработку в отдельную функцию

@@ -0,0 +1,11 @@
//#include "patterns.h"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем нужен этот комментарий?

диграфов :(; в противном случае переписка признается пессимистичной.
*/

#define SIZE_T_LINE_LENGTH 128
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

код этой тестирующей программы практически ничем не отличается от предыдущей тестирующей программы


size_t read_array(char ***array, const char *file_name);

bool emotion_test(const char **array, const size_t array_size,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заголовочный файл должен быть единым для обеих библиотек
конкретная реализация должна выбираться на этапе линковки

char **array;
size_t array_size = 0;

array_size = read_array(&array, "test1.txt");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

из названий файлов непонятно, какой они окраски :)

  • стоило не копировать код, а разбить все тесты на позитивные/негативные (например, разбив их на подпапки или заведя доп. конфигурационный файл).

free(array);

array_size = read_array(&array, "test2.txt");
assert(!emotion_test((const char **)array, array_size, ":)", ":("));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это интеграционные тесты
стоило также добавить юнит-тесты на отдельные функции - например, подсчёта точного числа диграмм

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants