Skip to content
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

unittests: add fletcher* tests #4938

Merged
merged 4 commits into from
Apr 12, 2016

Conversation

LudwigKnuepfer
Copy link
Member

The fletcher32 checksum does not match what the tool referenced in the fletcher16 test produces. I guess this is due to a common (I looked at various implementations on GitHub et al) implementation deviation where 8 bit words are summed instead of 16 bit words.

@LudwigKnuepfer LudwigKnuepfer added Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 1, 2016
@miri64 miri64 removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 1, 2016
@miri64
Copy link
Member

miri64 commented Mar 1, 2016

Travis is already overloaded as is. Please don't set the CI label before it was ACK'd

}

{
/* XXX: not verified with externa implementation yet */
Copy link
Member

Choose a reason for hiding this comment

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

externa?

@LudwigKnuepfer LudwigKnuepfer force-pushed the pr/fletcher-unittest branch 2 times, most recently from 8ef0d25 to be5cbfd Compare March 5, 2016 21:55
uint16_t expect = 0xFFFF;

TEST_ASSERT(calc_and_compare_checksum(buf, sizeof(buf) - 1, expect));
}
Copy link
Member

Choose a reason for hiding this comment

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

What kind of syntax is this? Why does this function have more than one assert?

Copy link
Member Author

Choose a reason for hiding this comment

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

Syntax is C I hope.

The function has several asserts because it tests several values.

Copy link
Member

Choose a reason for hiding this comment

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

Should be several functions then.

Copy link
Member

Choose a reason for hiding this comment

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

And I still don't get the purpose of the additional curly brackets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will split once the test logic is acknowledged

Copy link
Member Author

Choose a reason for hiding this comment

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

And I still don't get the purpose of the additional curly brackets.

Scoping in order to reuse the variable name. I.e. readability.

Copy link
Member

Choose a reason for hiding this comment

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

Will split once the test logic is acknowledged

I think this is done now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, will tend to shortly.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@LudwigKnuepfer
Copy link
Member Author

@gebart - can you ACK the logic?

0x00, 0x00, 0x00, 0x00,
0x1A, 0x1A, 0x1A, 0x1A,
};
uint32_t expect = fletcher32((const uint16_t *) buf0, sizeof(buf0)/2);
Copy link
Member

Choose a reason for hiding this comment

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

/ sizeof(uint16_t) instead of /2

@jnohlgard
Copy link
Member

ACK for the logic. I'm missing the precomputed expected value for fletcher32, but at least there's a TODO note there.

@jnohlgard
Copy link
Member

Tested on native and mulle, tests pass, I guess that's good.

@jnohlgard
Copy link
Member

One minor comment regarding literal 2, see above. You may squash immediately

@jnohlgard jnohlgard added this to the Release 2016.04 milestone Mar 19, 2016
@jnohlgard jnohlgard added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 19, 2016
@LudwigKnuepfer
Copy link
Member Author

I'm missing the precomputed expected value for fletcher32

Like outlined in the PR description I had trouble finding a good reference. Your old PR only has 16 bit reference values as well... I guess I could add a test for a known reference value that this implementation has produced, so we at least know it does not change.

@jnohlgard
Copy link
Member

btw, I just realized that it might be a good idea for the fletcher tests to have a test input vector which accumulates enough to "wrap around" the modulo part of the algorithm. The current test vector is quite short and containing small numbers, could you make another test vector which is longer and with some greater numbers.

https://en.wikipedia.org/wiki/Fletcher%27s_checksum#cite_note-3

If you want we can merge this now and add another test vector in a separate PR.

@jnohlgard jnohlgard added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 6, 2016
@jnohlgard
Copy link
Member

ping @LudwigKnuepfer

please squash

@LudwigKnuepfer
Copy link
Member Author

@gebart should I squash without addressing the comments first?

@LudwigKnuepfer
Copy link
Member Author

Just squashed the old fixup commit - may be merged as is.

I side-changed the same style "problem" in crc16-ccitt while I was at it.

@jnohlgard
Copy link
Member

OK, let's merge this.

@jnohlgard jnohlgard merged commit 690b505 into RIOT-OS:master Apr 12, 2016
@jnohlgard
Copy link
Member

Added an issue as a reminder to update the tests with more input vectors to improve coverage of the algorithm

@LudwigKnuepfer LudwigKnuepfer deleted the pr/fletcher-unittest branch April 12, 2016 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants