New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More fixed_width ints and incorporating file_saving_test.c #1025
Conversation
auto_tests/file_saving_test.c
Outdated
|
||
size_t written_value = fwrite(cipher, sizeof(*cipher), size, f); | ||
printf("written written_value = %u of %u\n", (unsigned)written_value, (unsigned)size); | ||
printf("written written_value = %u of %u\n", (uint16_t)written_value, (uint16_t)size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid sized-int in printf calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops
auto_tests/encryptsave_test.c
Outdated
|
||
Suite *encryptsave = encryptsave_suite(); | ||
SRunner *test_runner = srunner_create(encryptsave); | ||
|
||
int number_failed = 0; | ||
uint8_t number_failed = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just get rid of the SRunner stuff. That's just old compat stuff. Now we just call the test function directly (and we shouldn't use START_TEST anymore, just declare a static function manually).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was never quite sure what SRunner does tbqh. Is my HEAD now equivalent?
63f1cad
to
3917c41
Compare
auto_tests/encryptsave_test.c
Outdated
@@ -43,22 +43,21 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
} | |||
} | |||
|
|||
START_TEST(test_known_kdf) | |||
static void test_known_kdf() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_known_kdf(void)
auto_tests/file_saving_test.c
Outdated
fseek(f, 0, SEEK_SET); | ||
|
||
uint8_t *cipher = (uint8_t *)malloc(size); | ||
uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); | ||
size_t read_value = fread(cipher, sizeof(*cipher), size, f); | ||
printf("read read_vavue = %u of %ld\n", (unsigned)read_value, size); | ||
printf("Read read_vavue = %u of %ld\n", (uint8_t)read_value, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo cast.
auto_tests/file_transfer_test.c
Outdated
if (!(filename_length == sizeof("Gentoo.exe") && memcmp(filename, "Gentoo.exe", sizeof("Gentoo.exe")) == 0)) { | ||
ck_abort_msg("Bad filename"); | ||
} | ||
ck_assert_msg((filename_length == sizeof("Gentoo.exe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer () is now redundant.
auto_tests/file_transfer_test.c
Outdated
if (sending_pos != position) { | ||
ck_abort_msg("Bad position %llu", (unsigned long long)position); | ||
} | ||
ck_assert_msg(sending_pos == position, "bad position %llu", (unsigned long long) position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%llu
is not supported on windows. Change to %lu
and cast to unsigned long
.
auto_tests/file_transfer_test.c
Outdated
ck_abort_msg("Could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length); | ||
} | ||
ck_assert_msg(tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error), | ||
"Could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase "could".
auto_tests/file_transfer_test.c
Outdated
++sending_num; | ||
sending_pos += length; | ||
|
||
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK, "Wrong error code"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase "wrong".
auto_tests/file_transfer_test.c
Outdated
&& file_accepted == 1, | ||
"Something went wrong in file transfer %u %u %u %u %u %u %lu %lu %lu", | ||
sendf_ok, file_recv, totalf_size == file_size, size_recv == file_size, sending_pos == size_recv, | ||
file_accepted == 1, (unsigned long) totalf_size, (unsigned long) size_recv, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space after the cast (did you do this or did astyle?).
auto_tests/file_transfer_test.c
Outdated
@@ -297,7 +266,7 @@ static void file_transfer_test(void) | |||
(unsigned long)totalf_size, (unsigned long)size_recv, | |||
(unsigned long)sending_pos); | |||
|
|||
printf("100MiB file sent in %llu seconds\n", time(nullptr) - f_time); | |||
printf("100MiB file sent in %lu seconds\n", time(nullptr) - f_time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cast the result of the subtraction to unsigned long
.
auto_tests/file_transfer_test.c
Outdated
&& sending_pos == size_recv && file_accepted == 1, | ||
"something went wrong in file transfer %u %u %u %u %u %u %u %llu %llu %llu %llu", sendf_ok, file_recv, | ||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1, | ||
(unsigned long long) totalf_size, (unsigned long long) file_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space after cast.
auto_tests/file_transfer_test.c
Outdated
@@ -413,3 +372,4 @@ int main(void) | |||
file_transfer_test(); | |||
return 0; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra empty line.
c6adc24
to
6397e17
Compare
👍? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work, thanks! Only one comment, then it's ready to be merged.
Reviewable status: complete! 1 of 1 LGTMs obtained
auto_tests/file_transfer_test.c, line 50 at r2 (raw file):
Previously, iphydf wrote…
The outer () is now redundant.
It's still redundant. I didn't mean the inner (), I meant the outer (). Please put the inner ones back, we currently have that as a standard. We may change that once we use a better code formatter than astyle.
7635758
to
ffa038f
Compare
dun |
The file_saving_test.c was not included in the cmake list and thus was ignored by travis and "make check". I found this out while introducing ck_assert_msg into the integration test. Furthermore, removed some variable width integers from encryptsave_test.c, and the SRunner utilization. Implemmented ck_assert_msg, reorganized some loops, and removed some longs in file_transfer_test.c.
The file_saving_test.c was not included in the cmake list
and thus was ignored by travis and "make check". I found this
out while introducing ck_assert_msg into the integration test.
Also removed some variable width integers from encryptsave_test.c
and implemented ck_assert_msg, reorganized some loops,
and removed some longs in file_transfer_test.c.
This change is