aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-15 13:55:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-15 13:55:09 +0100
commit293ea2757b49fd5348c14b2fb178a2dcddced1f7 (patch)
treeb165dbb258e887d5167933cdf820e9310eefcc18 /test
parent555b81de0bc69d3b542d05fadb8a5f2b786bc9e0 (diff)
downloadrspamd-293ea2757b49fd5348c14b2fb178a2dcddced1f7.tar.gz
rspamd-293ea2757b49fd5348c14b2fb178a2dcddced1f7.zip
Add comparasion for rcl vs jansson.
Fix some issues in jansson memory management.
Diffstat (limited to 'test')
-rw-r--r--test/rspamd_rcl_test.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/test/rspamd_rcl_test.c b/test/rspamd_rcl_test.c
index 2a93169a6..778340890 100644
--- a/test/rspamd_rcl_test.c
+++ b/test/rspamd_rcl_test.c
@@ -21,9 +21,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../src/config.h"
-#include "../src/rcl/rcl.h"
-#include "../src/main.h"
+#include "config.h"
+#include "rcl/rcl.h"
+#include "main.h"
+#include "json/jansson.h"
#include "tests.h"
const gchar *rcl_test_valid[] = {
@@ -105,6 +106,8 @@ rspamd_rcl_test_func (void)
GError *err = NULL;
struct timespec start, end;
gdouble seconds;
+ json_t *json;
+ json_error_t jerr;
cur = rcl_test_valid;
while (*cur != NULL) {
@@ -162,14 +165,32 @@ rspamd_rcl_test_func (void)
g_assert_no_error (err);
clock_gettime (CLOCK_MONOTONIC, &end);
seconds = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.;
- msg_info ("parsed json in %.4f seconds", seconds);
+ msg_info ("rcl: parsed json in %.4f seconds", seconds);
/* Test config emitting */
clock_gettime (CLOCK_MONOTONIC, &start);
emitted = rspamd_cl_object_emit (obj, RSPAMD_CL_EMIT_CONFIG);
g_assert (emitted != NULL);
clock_gettime (CLOCK_MONOTONIC, &end);
seconds = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.;
- msg_info ("emitted object in %.4f seconds", seconds);
+ msg_info ("rcl: emitted object in %.4f seconds", seconds);
rspamd_cl_parser_free (parser);
rspamd_cl_obj_unref (obj);
+ g_free (emitted);
+
+ clock_gettime (CLOCK_MONOTONIC, &start);
+ json = json_load_file ("./rcl_test.json", &jerr);
+ g_assert (json != NULL);
+ clock_gettime (CLOCK_MONOTONIC, &end);
+ seconds = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.;
+ msg_info ("jansson: parsed json in %.4f seconds", seconds);
+
+ clock_gettime (CLOCK_MONOTONIC, &start);
+ emitted = json_dumps (json, 0);
+ g_assert (emitted != NULL);
+ clock_gettime (CLOCK_MONOTONIC, &end);
+ seconds = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.;
+ msg_info ("jansson: emitted object in %.4f seconds", seconds);
+
+ //json_decref (json);
+ g_free (emitted);
}