diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-22 13:13:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-22 13:13:41 +0100 |
commit | c20b2f1b973a01590855af6dd384a320ad8773e5 (patch) | |
tree | ea219d9456516dea7c3be1683d58b1e058a9efe4 /test/rspamd_async_test.c | |
parent | 57c21062f261eb595f8e64cd32d7df9604b7e754 (diff) | |
parent | 28e34a75931d363e7e85619368fa5c43f606e7d9 (diff) | |
download | rspamd-c20b2f1b973a01590855af6dd384a320ad8773e5.tar.gz rspamd-c20b2f1b973a01590855af6dd384a320ad8773e5.zip |
Merge pull request #2931 from rspamd/libev-migration
[Project] Migrate to libev
Diffstat (limited to 'test/rspamd_async_test.c')
-rw-r--r-- | test/rspamd_async_test.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/test/rspamd_async_test.c b/test/rspamd_async_test.c deleted file mode 100644 index 5ac71a4da..000000000 --- a/test/rspamd_async_test.c +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright 2016 Vsevolod Stakhov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "config.h" -#include "rspamd.h" -#include "aio_event.h" -#include "unix-std.h" - -extern struct event_base *base; - -static void -aio_read_cb (gint fd, gint res, gsize len, gpointer data, gpointer ud) -{ - guchar *p = data; - guint i; - - g_assert (res > 0); - - g_assert (len == BUFSIZ); - for (i = 0; i < len; i ++) { - g_assert (p[i] == 0xef); - } - - event_base_loopbreak (base); -} - -static void -aio_write_cb (gint fd, gint res, gsize len, gpointer data, gpointer ud) -{ - struct aio_context *aio_ctx = ud; - gchar *testbuf; - - g_assert (res > 0); - - g_assert (posix_memalign ((void **)&testbuf, 512, BUFSIZ) == 0); - - g_assert (rspamd_aio_read (fd, testbuf, BUFSIZ, 0, aio_ctx, aio_read_cb, aio_ctx) != -1); -} - -void -rspamd_async_test_func () -{ - struct aio_context *aio_ctx; - gchar *tmpfile; - static gchar testbuf[BUFSIZ]; - gint fd, afd, ret; - - aio_ctx = rspamd_aio_init (base); - - g_assert (aio_ctx != NULL); - - fd = g_file_open_tmp ("raXXXXXX", &tmpfile, NULL); - g_assert (fd != -1); - - afd = rspamd_aio_open (aio_ctx, tmpfile, O_RDWR); - g_assert (fd != -1); - - /* Write some data */ - memset (testbuf, 0xef, sizeof (testbuf)); - ret = rspamd_aio_write (afd, testbuf, sizeof (testbuf), 0, aio_ctx, aio_write_cb, aio_ctx); - g_assert (ret != -1); - - event_base_loop (base, 0); - - close (afd); - close (fd); - unlink (tmpfile); -} |