Commit Graph

9 Commits (347b65df921341bde83a54309ad3be5e56e59d23)

Author SHA1 Message Date
nirenjan 347b65df92 Override `time` from libc
Prior to this change, there were spurious build failures seen in Github
CI, especially on macOS builds, where one test out of ~2000 would fail
randomly. After adding an option to display the diagnostics, it was
determined that the failure was only in the tests that included the
timestamp. This was because the time call was returning different values
between `test_setup` and `pinelog_log_message`. Even though they may
have been called milliseconds apart, the time skew was enough to have a
1 second difference between the two returned values.

This change overrides the `time` method from libc, and returns a static
value. With this change, CI should work fine regardless of how slow the
tests run.
2021-11-11 07:02:21 -08:00
nirenjan 3be94a24ba Update logging library to include module and string buffer
This commit adds the following changes to pinelog:

- Optional buffer to write the message to prior to writing to the output
  stream. This reduces the likelihood of log messages from multiple
  threads interleaving due to multiple calls to fputs/fprintf, etc. The
  default is to still write directly to the output stream, but the
  integrator can add a define of PINELOG_BUFFER_SZ to the CFLAGS, and
  this will allow the application to log messages that are shorter than
  the above size, including the timestamp, level and backtrace if any.

- Optional module level logging. This allows more fine-grained
  debugging, where the application can control the log levels of the
  individual modules. By default, when modules are configured, they
  default to the global log level, but this can be overridden by the
  application.
2021-11-08 16:18:30 -08:00
nirenjan 5355a6ed8e Add noreturn attribute to tap_bailout
This change is necessary since clang warns on a missing noreturn
attribute.
2021-10-25 12:56:41 -07:00
nirenjan 349b2d6e86 Use an in-memory pipe for tests
Prior to this change, the test harness was creating a FIFO on disk using
`mkfifo`. This is really unnecessary, and we can use `pipe` instead to
create a pair of file descriptors corresponding to a FIFO in memory,
without having to go to disk at all.

This change creates the FIFO and sets it to non-blocking to emulate the
existing behavior.
2021-10-25 12:47:10 -07:00
nirenjan 0256807417 Use strrchr only if the compiler supports __builtin_strrchr 2021-08-25 14:16:53 -07:00
nirenjan 204aadead0 Use __builtin_strrchr to get file base name
Prior to this change, pinelog used __FILE__ in the backtrace call.
However, this has a limitation that if used in a build system with
sources in subdirectories and/or a separate build directory, the
relative path to the file is used, giving us a backtrace like this.

    ../../daemon/x52d_main.c:51

This change checks if the compiler supports the __builtin_strrchr to
compute the file basename at compile time. If the compiler does not
support it, it falls back to using __FILE__ directly. This should not be
an issue on a modern compiler like gcc or clang.
2021-08-25 12:11:53 -07:00
nirenjan a3eb2c03d7 Add method to close output stream and reset to default 2021-07-16 08:29:11 -07:00
nirenjan fb9b51a130 Fix format-literal error in clang 2021-07-15 18:31:01 -07:00
nirenjan 10941defb2 Add test framework 2021-07-14 11:00:44 -07:00