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
Conversation
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>
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__) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
tests/test_util_file.expected.Darwin
Outdated
@@ -0,0 +1,35 @@ | |||
OK: json_object_from_fd(./valid.json)={ "foo": 123 } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
@hawicz feel free to disagree with/comment on any of my approaches :) |
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 |
There was a problem hiding this comment.
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.
ack, wait a sec, this break the tests ALL the time. :( |
when you said about the configure option [instead of the #ifdef APPLE define ] I assumed you have something against so, yeah, the 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] ] we can insist a bit more on this there is one element that may crop up later [from the LEDE/OpenWrt/Embedded side of things] ; |
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. |
… it on OSX) always include the _json_c_strerror function but only enable it with a flag during tests.
… it on OSX) always include the _json_c_strerror function but only enable it with a flag during tests.
Seems some failing tests have piled up, due to a missing
set -e
test_util_file
test ; the issue is that Apple linkers don't allow to overridestrerror
and this seems to be locked down on travis-ci.org [ for security reasons I assume ] ; I tried some solutions from the web (like here: http://tlrobinson.net/blog/2007/12/overriding-library-functions-in-mac-os-x-the-easy-way-dyld_insert_libraries/) ; patches can be checked out here: https://github.com/commodo/json-c/commit/49ed91eb39d96ac625553843ba2c02018f601964 & https://github.com/commodo/json-c/commit/ca13901e0c37a9885fbc665c638185f0ef1c804f ; so, trying to force the test'sstrerror
did not work for me ; they worked locally, but not on travis ; I gave up [ after a few hours ] and resumed to go by checking specific output only for Darwintest_locale
: not sure if the fix is sane ; seems thatsetlocale()
actually changes the locale on Apple, while theuselocale()
function does not ;Signed-off-by: Alexandru Ardelean ardeleanalex@gmail.com