Fix nmsgtool compiler warning when building without rdkafka/json-c#181
Fix nmsgtool compiler warning when building without rdkafka/json-c#181
Conversation
| fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n", | ||
| argv_program); | ||
| #endif /* HAVE_JSON_C */ | ||
| exit(EXIT_FAILURE); |
There was a problem hiding this comment.
It's a bit weird, but these calls to exit() must be kept here for internal consistency with the rest of the helper functions that also call exit(1) in the event of an error... it's done a million places in src/io.c ...
| fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n", | ||
| argv_program); | ||
| #endif /* HAVE_JSON_C */ | ||
| exit(EXIT_FAILURE); |
There was a problem hiding this comment.
I added back the exit(EXIT_FAILURE) for both.
| examples/print_version | ||
|
|
||
|
|
||
| AM_TESTS_ENVIRONMENT = export USE_JSON="$(use_json_c)"; |
There was a problem hiding this comment.
Why is this line necessary, considering we run the following assignment in shell tests (and have HAVE_JSON_C in the C tests):
USE_JSON="@use_json_c@"
There was a problem hiding this comment.
Shell tests with a template .sh.in works without problem using USE_JSON="@use_json_c@", the variables are replaced at ./configure stage. The problem is that there are at least two tests (tests/test-kicker.sh, tests/test-sample.sh) that do not have template, and therefore the only way to access the value of use_json_c in the same way is by generating an ENV variable.
However, a good alternative could be to use the variable in all shell tests.
Removed guards around function calls, which was causing unused function warning.
Tests were failing when json-c was disabled because they unconditionally called json-related functions that weren't available. This PR adds conditional test execution by exporting a
USE_JSONvariable from the build system and wrapping all json-dependent operations in conditionals across all tests. When json-c is disabled, tests now execute no-op commands followed by check calls to properly register as passing rather than failing on unavailable functions.