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

pkg: add cn-cbor CBOR implementation plus unit tests #8467

Merged
merged 2 commits into from Mar 16, 2018

Conversation

lorenz9314
Copy link
Contributor

Contribution description

Adds the CBOR implementation cn-cbor to RIOT including unit tests. The test cases have been partially taken from cn-cbors original unit tests.

Issues/PRs references

The package itself has been taken from #8025, commits 772e877, fd7b6ab and ae2c180

@lorenz9314 lorenz9314 closed this Jan 27, 2018
@lorenz9314 lorenz9314 reopened this Jan 27, 2018
@smlng smlng added Area: tests Area: tests and testing framework Area: pkg Area: External package ports State: waiting for other PR State: The PR requires another PR to be merged first labels Feb 6, 2018
@smlng smlng requested a review from kaspar030 February 6, 2018 08:30
@kaspar030 kaspar030 changed the title add cn-cbor CBOR implementation plus unit tests pkg: add cn-cbor CBOR implementation plus unit tests Feb 6, 2018
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

I'm wondering, for the unittests you used "cncbor", while the package is called "cn-cbor" (with dash). IMO we should stick with one version of the naming. The former is shorter, but cabo himself put the dash in there...

* @file
* @brief Unit tests for pkg cn-cbor.
*
* @author Lorenz Hüther
Copy link
Contributor

Choose a reason for hiding this comment

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

if possible, please add email addresses

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine with me, I've got to ask Mathias first though.

} buffer_t;

typedef struct cbor_failure
{
Copy link
Contributor

Choose a reason for hiding this comment

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

opening brace goes one line up, like done for buffr_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be fixed!

cn_cbor_error err;
} cbor_failure;

cn_cbor *cbor;
Copy link
Contributor

Choose a reason for hiding this comment

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

if these variables are only used in this file, please make them static.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

@@ -0,0 +1,42 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

with the unittests in place, I think the test is not needed anymore...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, noted!

Copy link
Contributor

Choose a reason for hiding this comment

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

still here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, seems so. let me check...

@kaspar030
Copy link
Contributor

@lorenz9314 Thanks for taking over!

This is almost good to go, only minor issues.

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

Please prepend the unittests commit with "tests/unittests: "

&inv));

for (offs = 0; offs < sizeof(tests) / sizeof(cbor_failure); offs++) {
TEST_ASSERT(parse_hex(tests[offs].hex));
Copy link
Contributor

Choose a reason for hiding this comment

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

indent is off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be corrected...

@lorenz9314
Copy link
Contributor Author

@kaspar030
Thanks for the feedback! Regarding the missing dash in cncbor I completely forgot I did that. The reason was that the build would mysteriously fail if a second dash was present. Simply removing it was a quick fix as I had different priorities at the time. I must admit I have not looked into why that would be in great detail after that.

@vincent-d vincent-d removed the State: waiting for other PR State: The PR requires another PR to be merged first label Feb 27, 2018
@emmanuelsearch
Copy link
Member

@lorenz9314 what's the status on this? Looks like we're close to green?

@lorenz9314
Copy link
Contributor Author

@emmanuelsearch Pretty much ready on my side as well, however I am still unable to rename the tests to tests-cn-cbor as this causes sthe build to fail during linking. I pushed the changes, but like I said, no luck with the name.

@emmanuelsearch
Copy link
Member

@kaspar030 @bergzand any clues how to fix this issue?

@@ -0,0 +1,10 @@
APPLICATION = pkg_cn-cbor
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this line, it is redundant

@@ -0,0 +1,42 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

still here?

@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 6, 2018
@jnohlgard
Copy link
Member

You can not have a dash in the unit test name because of c function naming rules. Name the directory tests-cn_cbor and it should work.

@lorenz9314
Copy link
Contributor Author

@gebart Alright, done. Thanks!

@emmanuelsearch
Copy link
Member

@lorenz9314 seems like squashing would make sense at this point?

@lorenz9314
Copy link
Contributor Author

@emmanuelsearch Done...

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

Minor things left. Feel free to directly squash.

.PHONY: all

all: git-download
@cp Makefile.cn-cbor $(PKG_BUILDDIR)/src/Makefile
Copy link
Contributor

Choose a reason for hiding this comment

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

please drop this line and directly use this Makefile in the next, like:

"$(MAKE)" -C $(PKG_BUILDDIR)/src -f $(CURDIR)/Makefile.cn-cbor

unsigned char *pntr;
} buffer_t;

typedef struct cbor_failure {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove the cbor_failure after "struct".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright!

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

ACK! Thanks for your patience. ;)

@lorenz9314
Copy link
Contributor Author

@kaspar030 Likewise!

@emmanuelsearch emmanuelsearch merged commit a367e37 into RIOT-OS:master Mar 16, 2018
@nmeum nmeum mentioned this pull request Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pkg Area: External package ports 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.

None yet

6 participants