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

test_sodium fails: libsodium sets errno even if it doesn't fail #2370

Closed
mrvn opened this issue Mar 16, 2017 · 6 comments
Closed

test_sodium fails: libsodium sets errno even if it doesn't fail #2370

mrvn opened this issue Mar 16, 2017 · 6 comments

Comments

@mrvn
Copy link
Contributor

mrvn commented Mar 16, 2017

In test_sodium zmq_curve_keypair() is called and then zmq_errno() is checked. This works fine with the built-in tweetnacl but can fail with libsodium. What happens is this:

...
access("/dev/arandom", R_OK)            = -1 ENOENT (No such file or directory)
access("/dev/urandom", R_OK)            = 0
open("/dev/urandom", O_RDONLY)          = 3
...
test_sodium: tests/test_sodium.cpp:43: void test__zmq_curve_keypair__always__success(): Assertion `zmq_errno () == 0' failed.

libsodium does not reset the errno to 0 so it remains ENOENT even though everything works just fine.

What that means is that errno is meaningless unless the return code actually indicates an error and should not be checked in the testcase.

@bluca
Copy link
Member

bluca commented Mar 16, 2017

Perhaps then zmq_curve_keypair should return the return value of crypto_box_keypair and then the errno check can be removed. Could you please send a PR to fix it?

@mrvn
Copy link
Contributor Author

mrvn commented Mar 16, 2017

It already checks the return value:

assert (rc == 0);
assert (zmq_errno () == 0);

It's just the second assert that fails.

@bluca
Copy link
Member

bluca commented Mar 16, 2017

I mean inside the zmq_curve_keypair function itself - if you check, it just always return 0, so assert (rc == 0) can never catch any error

@mrvn
Copy link
Contributor Author

mrvn commented Mar 16, 2017

That makes more sense. let me try.

@bluca
Copy link
Member

bluca commented Mar 16, 2017

Thanks!

@bluca
Copy link
Member

bluca commented Mar 16, 2017

Fixed by #2372

@bluca bluca closed this as completed Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants