CTests ctest.h has code that is not platform-agnostic. Also ctest sources use fopen() calls. Needs to be reworked.
@gapisback is already working on this.
Since Jan 25, 2022.
- Dominant language
- C
- Stars
- 732
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
This item was recognized during review of PR #212 by Alex. The points noted are:
One issue that you foresaw is that ctest.h doesn't adhere to our platform rules. I think that's out of scope, but we should open an issue and fix that.
About this chunk of code (which was inline in the .c code but macro'ized as a result of a review comment):
267 #define vfprintf_usermsg(fh, message) \
268 do { \
269 va_list varargs; \
270 va_start(varargs, message); \
271 vfprintf((fh), (message), varargs); \
272 va_end(varargs); \
273 } while (0)
274
... the remark was: There is platform_error_log for this and I believe a way to specify the handle as well.
Revisit whether the call to vfprintf() on L271 can be changed to use platform_error_log() as suggested.
I want to note that this file is not platform-agnostic as is. Specifically, it uses some stuff that doesn't fly on certain platforms on which Splinter is also ported:
#include <inttypes.h> /* intmax_t, uintmax_t, PRI* /
#include <stddef.h> / size_t */
That seems straightforward to change using our platform definitions and some sed. This is the only ctest code file, right? We should open an issue and audit this. We have a special poison.h header to check for compliance.
A similar issue recognized during review of PR #224 is the following usages of fopen(), that is now being seen commonly in all unit-test sources:
108 // clang-format off
109 CTEST_SETUP(splinter)
110 {
111 Platform_stdout_fh = fopen("/tmp/unit_test.stdout", "a+");
112 Platform_stderr_fh = fopen("/tmp/unit_test.stderr", "a+");
113
Such references to fopen() should be platform'ized, so we don't run the risk that such code will not link on platforms where this stdlib function may not be available.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.