afsocket: Only build the tests if SSL is enabled

The tests require SSL support enabled, and compilation fails if it is
not present. Only build and run them when SSL support is available.

Reported-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
driver: Fix a memory leak in log_driver_free()

After freeing up the members of self->plugins, free self->plugins itself
too.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
json: Added json-c as git submodule
run-id: Fixed run_id_is_same_run functionality.

The test and the code was obviously bad.

Signed-off-by: Tusa Viktor <tusavik@gmail.com>
Merge pull request #70 from talien/f/run-id-is-same-run-fix

run-id: Fixed run_id_is_same_run functionality.
libtest: Added library for persist-related functions in tests.

This lib covers common tasks for creating/restarting/destroying
PersistState objects.

Also refactored test to use persist_lib provided functions.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
persist-state: Refactor and extend some PersistEntry-related functions.

Added persist_state_remove_entry.

Removing an entry from persist-state sets its in_use value to zero.
At next open of persist_state, this entry will be purged.
Merge pull request #66 from talien/f/json-submodule

json: Added json-c as git submodule
Merge pull request #63 from algernon/merge/h/make-check-without-openssl

afsocket: Only build the tests if SSL is enabled
Merge pull request #64 from algernon/merge/h/driver-plugin-leak-fix

driver: Fix a memory leak in log_driver_free()
Merge pull request #71 from talien/f/persist-refactor-and-libtest

F/persist refactor and libtest
logmsg: Do not use NULL template_options parameter for log_macro_expand.

In case of time-related macros, it uses the members of the
LogTemplateOptions* structure, but it results in a NULL pointer
dereference. Instead of spraying the log_macro_expand code with NULL checks,
we pass an initialized options structure to the function, and wrap it
in the log_macro_expand_simple function.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
contrib: Add a Valgrind suppression file

When debugging memory leaks in syslog-ng, there are a couple of known
false positives, or leaks we do not care about (such as OpenSSL
initialisers and such). To silence those, a suppression file was
created. Simply add a --suppressions=/path/to/valgrind/syslog-ng.supp to
the Valgrind command line, and there will be so much less noise.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Merge pull request #69 from algernon/merge/f/valgrind-suppress

contrib: Add a Valgrind suppression file
persist-state: Clean up the temporary file upon destroy

When destroying a persist state, unlink the temporary file too, as to
not leave junk behind. Added test cases for both the commit() +
destroy() and the cancel() + destroy() cases. With this fixed, the
persist files created during make check need not be in CLEANFILES.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Makefile: Fix make dist in certain edge cases

Due to the way internal modules were built, if both mongodb and
libmongo-client was disabled, make dist failed. When amqp was explicitly
disabled, make dist failed.

The reason being, we use a dummy.c to trigger building the bundled
libraries, but the dummy.c files were not created if mongodb/amqp were
disabled. Now we create them anyway, just don't recurse into the
directory when the module is disabled.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Merge pull request #74 from algernon/merge/h/distcheck-dummy-fix

Makefile: Fix make dist in certain edge cases
Merge pull request #73 from algernon/merge/h/persist-state-destroy-cleanup

persist-state: Clean up the temporary file upon destroy
nvtable: fix an NV registry corruption in the unit tests

nv_registry_add_alias() used the passed in pointer to the alias verbatim,
without copying it.  However the unit test program generated alias names
dynamically, e.g.  editing the memory area that was used to store the hash
table key.

Since this wasn't intuitive at all, this patch changes the code so that the
key in the NV registry is now always duplicated before insertion.

Signed-off-by: Igor Ippolitov <iippolitov@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg: Add a cfg_load_config() function

This new function can be used to load configuration from memory, instead
of a file, which is a boon for writing tests.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>