Page MenuHomeFreeBSD

ping: add tests of the Internet checksum function
ClosedPublic

Authored by sucanjan_gmail.com 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

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 25976
Build 24531: arc lint + arc unit

Event Timeline

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

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

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

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

sbin/ping/tests/in_cksum_test.c
89

Thanks. It has been fixed.

asomers added inline comments.Aug 20 2019, 4:31 PM
sbin/ping/tests/in_cksum_test.c
94

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

Correct unaligned data buffer size.

sbin/ping/tests/in_cksum_test.c
94

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
7

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.

Set WARNS to 6 explicitly for tests.

sbin/ping/tests/Makefile
7

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.