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

tests: fix tests in travis-ci.org #336

Merged
merged 7 commits into from Jul 14, 2017
Merged

tests: fix tests in travis-ci.org #336

merged 7 commits into from Jul 14, 2017

Conversation

commodo
Copy link
Contributor

@commodo commodo commented Jul 10, 2017

Seems some failing tests have piled up, due to a missing set -e

Signed-off-by: Alexandru Ardelean ardeleanalex@gmail.com

Seems that test1 is failing, but travis is not catching it.
Likely, this is because the `cppcheck` returns success
and we need to bail on the `make check` step.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
More code compression/de-duplication.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
@commodo
Copy link
Contributor Author

commodo commented Jul 11, 2017

re-spinned to latest master;

json_tokener.c Outdated
@@ -239,7 +239,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
{
struct json_object *obj = NULL;
char c = '\1';
#ifdef HAVE_USELOCALE
#if defined(HAVE_USELOCALE) && !defined(__APPLE__)
Copy link
Member

Choose a reason for hiding this comment

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

If there's some problem with uselocale or duplocale then the configure test should be adjusted to check for that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@@ -0,0 +1,35 @@
OK: json_object_from_fd(./valid.json)={ "foo": 123 }
Copy link
Member

Choose a reason for hiding this comment

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

Bleh, that sucks about not being able to replace strerror(), but rather than ending up with per-arch output files, let's instead s/strerror/_json_c_strerror/ and then have the tests replace that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack;
this will have to be done via a preprocessor #define at build time in .travis.yml ; or maybe via a special configure rule ;
because libjson-c is built first and that would link to strerror

i also thought about renaming strerror
wasn't sure what your thoughts/input would be

ugh... seems cppcheck is not packaged for OS X
And `set -e` exposes this.

And also `cppcheck` seems to exit with non-zero
exit codes by default [even if errs found].

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Which now seems to fail the build.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
On Apple this seems to fail the `test_locale` test,
which would imply that the `uselocale` function
does not behave as expected.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
If we want to override `strerror()` in libjson-c
to make tests consistent across platforms, we
need to do it build-wide as configure/build
option.

Apple linkers make it really hard to override functions
at link-time, and this seems to be locked down on travis-ci.org
[ for security reasons I assume ].
While I got it to work locally, it did not work
when running on travis.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
To get consistent output between Linux & OS X.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
@commodo
Copy link
Contributor Author

commodo commented Jul 13, 2017

@hawicz
re-spinned
for the strerror override, i chose the way of the "build option"

feel free to disagree with/comment on any of my approaches :)
i'm not completely sure that i chose the best approach[es] ;
well, maybe it's more of a preference thing ;
in which case, i prefer that your preference takes precedence ;

AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]])
AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]])
AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]])
AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])

case "${host_os}" in
Copy link
Member

Choose a reason for hiding this comment

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

Why should linux be the only OS allowed to use uselocale? When I said that the configure test needs to be adjusted I mean that it needs to actually check whether uselocale works. This is effectively just an obfuscated #ifdef APPLE.
I'm going to merge this PR since all the other changes look fine, but then I'm going to revert this piece and we'll need to approach it a different way.

@hawicz hawicz merged commit c0b7d76 into json-c:master Jul 14, 2017
@hawicz
Copy link
Member

hawicz commented Jul 14, 2017

ack, wait a sec, this break the tests ALL the time. :(
Having that work conditional on a special config option isn't going to work.

@commodo
Copy link
Contributor Author

commodo commented Jul 14, 2017

when you said about the configure option [instead of the #ifdef APPLE define ] I assumed you have something against #ifdef __PLATOFRM_DEFINES__ ;
the #ifdef APPLE seemed to shortest path to the fix

so, yeah, the uselocale function seems to behave differently on OS X than Linux [ at least in the test_locale test ]
for the setlocale I don't know what's different [if anything] between OS X & Linux

now, i'm also wondering whether it would have worked to fix the test [ add check #ifdef HAVE_USELOCALE #elsif HAVE_SETLOCALE [ same as in in libjson-c] ]
or, maybe that would have just hidden the issue ;

we can insist a bit more on this locale issue
to be honest, i'm just glad tests are back on track ; for me, the locale thing is a bit secondary atm ;
because i would like to get back to JSON patch [ first stop : json_deep_copy() ]
and i'm also thinking about checking into JSON schema later [will see]

there is one element that may crop up later [from the LEDE/OpenWrt/Embedded side of things] ;
some of the stuff that's being added now, grows the lib a bit ;
so, maybe i'll propose some --enable/--disable json-patch/pointer/schema/etc ;
but let's see about this when we get there ; it may not be needed ;

@commodo commodo deleted the fix-tests branch July 14, 2017 17:30
@hawicz
Copy link
Member

hawicz commented Jul 15, 2017

The configure test you added effectively is platform define, rather than a feature check. Whether you use #ifdef APPLE or #ifdef linux or ${host_os} = "linux" you have the same problem: it's only loosely related to the behavior that you're actually trying to adapt to

I'm working on fixing the tests now, since they are definitely not on track with these changes. If we can use the function override functionality, then _json_c_strerror just needs to always be used, with a flag to choose which output you get.

hawicz added a commit that referenced this pull request Jul 15, 2017
… it on OSX) always include the _json_c_strerror function but only enable it with a flag during tests.
hawicz added a commit that referenced this pull request Jul 15, 2017
… it on

OSX) always include the _json_c_strerror function but only enable it with a flag
 during tests.
hawicz added a commit that referenced this pull request Jul 28, 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

Successfully merging this pull request may close these issues.

None yet

2 participants