unit: added testutils.{h,c} to make the test cases short and understandable (fixes: #B-06841)

Signed-off-by: Peter Gyorko <gyorkop@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
unit: added test_skeleton.c (fixes: #B-06841)

Signed-off-by: Peter Gyorko <gyorkop@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
[test_msgsdata] testcase refactoring to use testutils

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
unit: extracted init_and_load_syslogformat/deinit() to msg_parse_lib.h (fixes: #B-06841)

Signed-off-by: Peter Gyorko <gyorkop@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
unit: reimplemented test_clone_logmsg unit test (fixes: #B-06841)

 * Added assert_guint16() to testutils.c.

Signed-off-by: Peter Gyorko <gyorkop@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_clone_logmsg: fixed minor things based on the review notes (fixes: #B-06841)

Signed-off-by: Peter Gyorko <gyorkop@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
[test_clone_logmsg]: extracting reusable functions to a separate library (fixes: #B-06841)

Signed-off-by: Attila Magyar <athos@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
[testutils]: assertion error messages made optional (fixes: #B-06841)

Signed-off-by: Attila Magyar <athos@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
[test_msgparse]: took the first steps of understanding and refactoring this monster (fixes: #B-06841)

    * Simplified testcase() by extracting assertions and small ugly-detail
      functions from it, which also resulted in lower redundancy around
      message serialization checks.
    * Merged many of the extracted functions with assertions refactored in
      test_clone_logmsg.

  Possible steps to continue:

    * By replacing TEST_ASSERT with more accurate assertion functions from
      testutils, we lost the capability of printing the actual testcase in
      case of failure. This could be solved for example by introducing a new
      functionality in testutils: to mark the beginning and the end of a
      testcase.
    * Many of the calls of testcase() are very similar, which may enable
      changing testcase() to accept a raw msg string, some parsing related
      options and an expected LogMessage object. Then
      test_log_messages_can_be_parsed() could be refactored to initialize an
      expected_log_message object once, then change separate fields on an
      incremental basis for each new test log message.
    * Introducing that expected_message object mentioned above would be even
      more useful since with slight changes in msg_parse_lib (e.g. extracting
      a function named assert_log_messages_equal_except_timestamps() from
      assert_log_messages_equal()) the assertions in the beginning of
      testcase() could be replaced by a simple assert_log_messages_equal()
      call.

Signed-off-by: Attila Magyar <athos@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
[testutils]: testcase details can be shown when an assertion fails (fixes: #B-06841)

    The new macro testcase_begin() accepts a printf()-style description
    template and an arbitrary number of arguments detailing the currently
    running testcase. The information gets stored in memory so it can be
    displayed on screen automatically when an assertion fails. Testcases marked
    by testcase_begin() must be closed with testcase_end()

Signed-off-by: Attila Magyar <athos@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_msgparse: fixed possible null deref

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>