Page MenuHomeFreeBSD

ping: add tests of the Internet checksum function
ClosedPublic

Authored by jansucan on Aug 20 2019, 1:20 PM.

Details

Summary

Add tests of the Internet checksum function

Submitted by: Ján Sučan <sucanjan@gmail.com>
Sponsored by: Google LLC (Google Summer of Code 2019)

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jansucan created this revision.Aug 20 2019, 1:20 PM
asomers requested changes to this revision.Aug 20 2019, 3:49 PM

Don't forget to add an entry to etc/mtree/BSD.tests.dist

sbin/ping/tests/in_cksum_test.c
89 ↗(On Diff #61041)

This doesn't guarantee that the array will be unaligned. It merely doesn't guarantee that it will be aligned. Better to declare an array that's aligned, then compute the checksum starting from the second byte. That way you'll know it's unaligned.

This revision now requires changes to proceed.Aug 20 2019, 3:49 PM
jansucan updated this revision to Diff 61053.Aug 20 2019, 4:21 PM

Add an entry to etc/mtree/BSD.tests.dist.

Ensure an unaligned data by starting from the second byte of an aligned data buffer.

jansucan added inline comments.Aug 20 2019, 4:22 PM
sbin/ping/tests/in_cksum_test.c
89 ↗(On Diff #61041)

Thanks. It has been fixed.

asomers added inline comments.Aug 20 2019, 4:31 PM
sbin/ping/tests/in_cksum_test.c
93 ↗(On Diff #61053)

But now the second argument is wrong. Shouldn't it be nitems(data) - 1?

jansucan updated this revision to Diff 61054.Aug 20 2019, 4:34 PM

Correct unaligned data buffer size.

jansucan added inline comments.Aug 20 2019, 4:37 PM
sbin/ping/tests/in_cksum_test.c
93 ↗(On Diff #61053)

You're right. Thanks. I'm editing too many diffs at once.

asomers added inline comments.Aug 20 2019, 5:03 PM
sbin/ping/tests/Makefile
6 ↗(On Diff #61054)

Here's a footgun you didn't know about: WARNS is by default set to 6 for libraries and binaries, but 0 for tests. You need to set it explicitly.

jansucan updated this revision to Diff 61056.Aug 20 2019, 5:35 PM

Set WARNS to 6 explicitly for tests.

jansucan added inline comments.Aug 20 2019, 5:36 PM
sbin/ping/tests/Makefile
6 ↗(On Diff #61054)

Fixed.

asomers accepted this revision.Aug 20 2019, 9:57 PM
This revision is now accepted and ready to land.Aug 20 2019, 9:57 PM
This revision was automatically updated to reflect the committed changes.