28 Commits

Author SHA1 Message Date
Tyler Erickson
3723b182db bug: Fixing runtime issue with test_util_file.c in Windows
Windows was failing tests due to how the Windows API works with some of the calls used.
When opening and reading a file O_BINARY is needed otherwise it fails for size checks. This is due to how Windows handles newlines and counts between text and binary mode file reads.

Also fixed is the test for /dev/null.
In Windows, this fails, but crashes due to a missing return statement when it cannot open this file.
I also tried telling windows to open the special file NUL, however that leads to a CRT crash later in the test that cannot be stopped and will always fail. Rather than fail a test that Windows will always fail, it has been disabled in that specific case.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
2025-10-20 12:10:57 -06:00
Rosen Penev
66f7869219 rename WIN32 to _WIN32
The latter is the proper macro defined by Windows headers.

Fixes compilation under at least clang-cl which mandates function
declarations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-02-07 18:06:55 -08:00
Eric Haszlakiewicz
d0f32a5a43 Stop linking a copy of _json_c_strerror() (strerror_override.c) into the tests.
That hasn't been needed since since commit 6068d3f, which changed that code to
 check an env var instead ("_JSON_C_STRERROR_ENABLE").
Fixes issue #812, about dup symbols in static builds with clang.
2023-03-28 23:08:39 +00:00
Khem Raj
6eca65617a Fix build with clang-15+
Fixes
json_util.c:63:35: error: a function declaration without a prototype is deprecated in all versions of C [-We
rror,-Wstrict-prototypes]
const char *json_util_get_last_err()
                                  ^
                                   void

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-08-13 20:47:20 -07:00
Eric Haszlakiewicz
5282e73600 Entirely drop mode bits from open(O_RDONLY) to avoid warnings on certain platforms. Fixes issue #779. 2022-07-26 23:43:30 +00:00
Eric Haszlakiewicz
49c3721a5a Unset NDEBUG so assert() is enabled in all tests. One more fix there when building with -DCMAKE_BUILD_TYPE=release. 2022-05-30 15:39:54 +00:00
Eric Haszlakiewicz
6068d3f6d1 Change the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead of using a variable, so we don't need to export it. 2020-07-04 18:58:00 +00:00
David McCann
add7b13a9a Improved support for IBM operating systems
Fix compiler errors and warnings when building on IBM operating systems such as AIX and IBM i.
2020-05-14 15:39:35 +01:00
dota17
b14363ae32 remove unsuitable case 2020-04-15 20:06:12 +08:00
dota17
2876fcc137 clang-format two test_util_file.c and test_object_iterator.c 2020-04-14 10:15:27 +08:00
chenguoping
8096125618 Increased the test coverage of json_util.c from 76% to 90.3%. 2020-04-14 10:10:47 +08:00
Björn Esser
5e699f7f73 Be verbose on failing json_c_version test. 2020-04-11 21:09:31 +02:00
Björn Esser
d47fb12e85 Test coverage for json_c_version. 2020-04-11 12:33:59 +02:00
dota17
8b162c4b89 clang-format the files 2020-04-03 11:39:30 +08:00
Eric Haszlakiewicz
41f434e89f Fix test_util_file for VS2013 too, but skip all the tests for anything older than that because the limitations are too inconvenient. 2019-11-23 23:55:04 -05:00
Eric Haszlakiewicz
b99be9cf4e Fix up the test_util_file test for builds on Windows VS2015. 2019-11-23 23:14:24 -05:00
Eric Haszlakiewicz
7f30afc6e5 Fix some Windows compile issues, add JSON_EXPORT's, fix bogus character escapes, define __func__ and omit unistd.h if needed. 2019-11-23 20:31:14 -05:00
Eric Haszlakiewicz
baed9983b3 Add a json_object_from_fd_ex() function, to allow the max nesting depth to be specified. 2019-11-10 00:14:44 -05:00
Eric Haszlakiewicz
fcad0ec015 PR #336: since we can't use function overriding (due to problems with it on
OSX) always include the _json_c_strerror function but only enable it with a flag
 during tests.
2017-07-15 07:12:44 -07:00
Alexandru Ardelean
fb72160caf build: make strerror() override-able
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>
2017-07-13 10:27:24 +03:00
Alexandru Ardelean
7b9432d564 tests: fix leak in test_util_file ; found by cppcheck
Which now seems to fail the build.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-07-13 09:05:13 +03:00
Eric Haszlakiewicz
e8e574fbe4 Issue #161: add a json_object_to_fd() function. 2017-06-18 18:44:45 +00:00
Eric Haszlakiewicz
9a64fd7d55 Issue #300: Use %p instead of %lx in test_util_file since some platforms' pointers are larger than "unsigned long".
Also, there's no need to worry about output consistency here, since it'll be
 different anyway due to different pointer values.
2017-02-05 04:38:53 +00:00
Eric Haszlakiewicz
0fcf1d1ae7 Fix memory leak and inconsistent output (due to varying fd numbers) in test_util_file. 2016-08-20 23:06:22 -04:00
Nicola Spanti (RyDroid)
8215c0ac0e Very minor changes to some tests 2016-08-13 00:53:33 +02:00
Eric Haszlakiewicz
7d637362b7 Linux's %p format doesn't return "0x0" for NULL pointers, so switch to using %lx for consistency. 2016-07-30 15:09:51 -04:00
Eric Haszlakiewicz
2b255d0ebf Fix absolute paths in test_util_file that vary depending on where it is run. 2016-06-27 04:30:10 +00:00
Eric Haszlakiewicz
29ef73f21d Issue #189: Eliminate use of MC_ERROR from json_util.c, and add a json_util_get_last_err() function to retrieve the error for those callers that care about it.
Add tests and descriptions for the functions in json_util.c
2016-06-26 02:20:33 +00:00