[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Wed Jul 7 05:55:02 UTC 2021
The branch, master has been updated
via ced1d018ce1 Add editorconfig config file
via de4e8a1af95 tevent: bump the version number to 0.11.0
via 683c44a79f0 tevent: add event trace api
via fc9dd8ce9f0 tevent: add custom tag to events
via 5203e70ada0 tevent: add support for cmocka unit tests
via 740a217264f third_party:cmocka: Fix build when used in lib/tevent
from 00bab5b3c82 smbXsrv_{open,session,tcon}: protect smbXsrv_{open,session,tcon}_global_traverse_fn against invalid records
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ced1d018ce1957633d8defe3597fbb5eba32ca17
Author: Andreas Schneider <asn at samba.org>
Date: Sun Jul 4 20:06:04 2021 +0200
Add editorconfig config file
See https://editorconfig.org/ for details.
(neo)vim: https://github.com/editorconfig/editorconfig-vim
emacs: https://github.com/editorconfig/editorconfig-emacs
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Wed Jul 7 05:54:16 UTC 2021 on sn-devel-184
commit de4e8a1af9564f6056f9af90867c2f013449051c
Author: Pavel Březina <pbrezina at redhat.com>
Date: Mon May 31 14:58:19 2021 +0200
tevent: bump the version number to 0.11.0
* Other minor build fixes.
* Add custom tag to events
* Add event trace api
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Pavel Březina <pbrezina at redhat.com>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 683c44a79f09550a59e99606c9c80304666604a0
Author: Pavel Březina <pbrezina at redhat.com>
Date: Tue Jun 1 14:10:05 2021 +0200
tevent: add event trace api
Adds new tracing API to trace fd, timer, signal and immediate events
on specific trace points: attach, before handler and dettach.
This can be used in combination with the event tag to keep track
of the currently executed event for purpose of debugging.
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Pavel Březina <pbrezina at redhat.com>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit fc9dd8ce9f0ae2a7ae972035e56c4c4f9028e261
Author: Pavel Březina <pbrezina at redhat.com>
Date: Tue Jun 1 13:57:45 2021 +0200
tevent: add custom tag to events
Adds a new API to set and get an uint64_t tag on fd, timer, signal and
immediate events. This can be used to assign a unique and known id to
the event to allow easy tracking of such event.
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Pavel Březina <pbrezina at redhat.com>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 5203e70ada0d5727591e80a11f941828a0bbadda
Author: Pavel Březina <pbrezina at redhat.com>
Date: Thu Jun 3 13:05:46 2021 +0200
tevent: add support for cmocka unit tests
This adds a placeholder for new cmocka tests for tevent. Tests
are added in individual commits.
Signed-off-by: Pavel Březina <pbrezina at redhat.com>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 740a217264f10c5f3a9ecac8aab8727e45ff885d
Author: Andreas Schneider <asn at samba.org>
Date: Tue Jun 8 14:29:06 2021 +0200
third_party:cmocka: Fix build when used in lib/tevent
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
.editorconfig | 33 +
.../ABI/{tevent-0.10.2.sigs => tevent-0.11.0.sigs} | 20 +
lib/tevent/tests/test_tevent_tag.c | 212 ++++
lib/tevent/tests/test_tevent_trace.c | 1065 ++++++++++++++++++++
lib/tevent/tevent.c | 4 +
lib/tevent/tevent.h | 213 ++++
lib/tevent/tevent_debug.c | 139 ++-
lib/tevent/tevent_fd.c | 22 +
lib/tevent/tevent_immediate.c | 51 +
lib/tevent/tevent_internal.h | 51 +-
lib/tevent/tevent_signal.c | 21 +
lib/tevent/tevent_timed.c | 32 +-
lib/tevent/wscript | 41 +-
third_party/cmocka/wscript | 2 +
14 files changed, 1892 insertions(+), 14 deletions(-)
create mode 100644 .editorconfig
copy lib/tevent/ABI/{tevent-0.10.2.sigs => tevent-0.11.0.sigs} (85%)
create mode 100644 lib/tevent/tests/test_tevent_tag.c
create mode 100644 lib/tevent/tests/test_tevent_trace.c
Changeset truncated at 500 lines:
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000000..118f88807ea
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,33 @@
+root = true
+
+[*]
+charset = utf-8
+max_line_length = 80
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = false
+
+[*.{c,h,idl}]
+indent_style = tab
+indent_size = 8
+tab_width = 8
+
+[*.{py,sh}]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
+[*.{pl,pm}]
+indent_style = tab
+indent_size = 8
+tab_width = 8
+
+[wscript*]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
+[source4/heimdal/**.{c,h}]
+indent_style = space
+indent_size = 4
+tab_width = 4
diff --git a/lib/tevent/ABI/tevent-0.10.2.sigs b/lib/tevent/ABI/tevent-0.11.0.sigs
similarity index 85%
copy from lib/tevent/ABI/tevent-0.10.2.sigs
copy to lib/tevent/ABI/tevent-0.11.0.sigs
index f6227db5c93..e64007e0516 100644
--- a/lib/tevent/ABI/tevent-0.10.2.sigs
+++ b/lib/tevent/ABI/tevent-0.11.0.sigs
@@ -54,10 +54,18 @@ tevent_context_is_wrapper: bool (struct tevent_context *)
tevent_context_same_loop: bool (struct tevent_context *, struct tevent_context *)
tevent_debug: void (struct tevent_context *, enum tevent_debug_level, const char *, ...)
tevent_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_fd_get_tag: uint64_t (const struct tevent_fd *)
tevent_fd_set_auto_close: void (struct tevent_fd *)
tevent_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_fd_set_tag: void (struct tevent_fd *, uint64_t)
tevent_get_trace_callback: void (struct tevent_context *, tevent_trace_callback_t *, void *)
+tevent_get_trace_fd_callback: void (struct tevent_context *, tevent_trace_fd_callback_t *, void *)
+tevent_get_trace_immediate_callback: void (struct tevent_context *, tevent_trace_immediate_callback_t *, void *)
+tevent_get_trace_signal_callback: void (struct tevent_context *, tevent_trace_signal_callback_t *, void *)
+tevent_get_trace_timer_callback: void (struct tevent_context *, tevent_trace_timer_callback_t *, void *)
+tevent_immediate_get_tag: uint64_t (const struct tevent_immediate *)
+tevent_immediate_set_tag: void (struct tevent_immediate *, uint64_t)
tevent_loop_allow_nesting: void (struct tevent_context *)
tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
tevent_num_signals: size_t (void)
@@ -108,10 +116,18 @@ tevent_set_debug: int (struct tevent_context *, void (*)(void *, enum tevent_deb
tevent_set_debug_stderr: int (struct tevent_context *)
tevent_set_default_backend: void (const char *)
tevent_set_trace_callback: void (struct tevent_context *, tevent_trace_callback_t, void *)
+tevent_set_trace_fd_callback: void (struct tevent_context *, tevent_trace_fd_callback_t, void *)
+tevent_set_trace_immediate_callback: void (struct tevent_context *, tevent_trace_immediate_callback_t, void *)
+tevent_set_trace_signal_callback: void (struct tevent_context *, tevent_trace_signal_callback_t, void *)
+tevent_set_trace_timer_callback: void (struct tevent_context *, tevent_trace_timer_callback_t, void *)
+tevent_signal_get_tag: uint64_t (const struct tevent_signal *)
+tevent_signal_set_tag: void (struct tevent_signal *, uint64_t)
tevent_signal_support: bool (struct tevent_context *)
tevent_thread_proxy_create: struct tevent_thread_proxy *(struct tevent_context *)
tevent_thread_proxy_schedule: void (struct tevent_thread_proxy *, struct tevent_immediate **, tevent_immediate_handler_t, void *)
tevent_threaded_context_create: struct tevent_threaded_context *(TALLOC_CTX *, struct tevent_context *)
+tevent_timer_get_tag: uint64_t (const struct tevent_timer *)
+tevent_timer_set_tag: void (struct tevent_timer *, uint64_t)
tevent_timeval_add: struct timeval (const struct timeval *, uint32_t, uint32_t)
tevent_timeval_compare: int (const struct timeval *, const struct timeval *)
tevent_timeval_current: struct timeval (void)
@@ -120,7 +136,11 @@ tevent_timeval_is_zero: bool (const struct timeval *)
tevent_timeval_set: struct timeval (uint32_t, uint32_t)
tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *)
tevent_timeval_zero: struct timeval (void)
+tevent_trace_fd_callback: void (struct tevent_context *, struct tevent_fd *, enum tevent_event_trace_point)
+tevent_trace_immediate_callback: void (struct tevent_context *, struct tevent_immediate *, enum tevent_event_trace_point)
tevent_trace_point_callback: void (struct tevent_context *, enum tevent_trace_point)
+tevent_trace_signal_callback: void (struct tevent_context *, struct tevent_signal *, enum tevent_event_trace_point)
+tevent_trace_timer_callback: void (struct tevent_context *, struct tevent_timer *, enum tevent_event_trace_point)
tevent_update_timer: void (struct tevent_timer *, struct timeval)
tevent_wakeup_recv: bool (struct tevent_req *)
tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval)
diff --git a/lib/tevent/tests/test_tevent_tag.c b/lib/tevent/tests/test_tevent_tag.c
new file mode 100644
index 00000000000..ce64d3c396e
--- /dev/null
+++ b/lib/tevent/tests/test_tevent_tag.c
@@ -0,0 +1,212 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * testing of some tevent_req aspects
+ *
+ * Copyright (C) Pavel Březina <pbrezina at redhat.com> 2021
+ *
+ * ** NOTE! The following LGPL license applies to the tevent
+ * ** library. This does NOT imply that all of Samba is released
+ * ** under the LGPL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <signal.h>
+
+#include <talloc.h>
+#include <tevent.h>
+#include <cmocka.h>
+
+static void fd_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags,
+ void *private_data)
+{
+ /* Dummy handler. Just return. */
+ return;
+}
+
+static void timer_handler(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
+ /* Dummy handler. Just return. */
+ return;
+}
+
+static void signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ /* Dummy handler. Just return. */
+ return;
+}
+
+static void immediate_handler(struct tevent_context *ctx,
+ struct tevent_immediate *im,
+ void *private_data)
+{
+ /* Dummy handler. Just return. */
+ return;
+}
+
+static int test_setup(void **state)
+{
+ struct tevent_context *ev;
+
+ ev = tevent_context_init(NULL);
+ assert_non_null(ev);
+
+ *state = ev;
+ return 0;
+}
+
+static int test_teardown(void **state)
+{
+ struct tevent_context *ev = (struct tevent_context *)(*state);
+ talloc_free(ev);
+ return 0;
+}
+
+static void test_fd_tag(void **state)
+{
+ struct tevent_context *ev = (struct tevent_context *)(*state);
+ struct tevent_fd *fde;
+ uint64_t tag;
+
+ fde = tevent_add_fd(ev, ev, 0, TEVENT_FD_READ, fd_handler, NULL);
+ assert_non_null(fde);
+
+ tag = tevent_fd_get_tag(fde);
+ assert_int_equal(0, tag);
+
+ tevent_fd_set_tag(fde, 1);
+ tag = tevent_fd_get_tag(fde);
+ assert_int_equal(1, tag);
+
+ tevent_re_initialise(ev);
+
+ tag = tevent_fd_get_tag(fde);
+ assert_int_equal(1, tag);
+
+ TALLOC_FREE(fde);
+}
+
+static void test_timer_tag(void **state)
+{
+ struct tevent_context *ev = (struct tevent_context *)(*state);
+ struct tevent_timer *te;
+ struct timeval next;
+ uint64_t tag;
+
+ next = tevent_timeval_current();
+ te = tevent_add_timer(ev, ev, next, timer_handler, NULL);
+ assert_non_null(te);
+
+ tag = tevent_timer_get_tag(te);
+ assert_int_equal(0, tag);
+
+ tevent_timer_set_tag(te, 1);
+ tag = tevent_timer_get_tag(te);
+ assert_int_equal(1, tag);
+
+ next = tevent_timeval_current();
+ tevent_update_timer(te, next);
+
+ tag = tevent_timer_get_tag(te);
+ assert_int_equal(1, tag);
+
+ tevent_re_initialise(ev);
+
+ tag = tevent_timer_get_tag(te);
+ assert_int_equal(1, tag);
+
+ TALLOC_FREE(te);
+}
+
+static void test_signal_tag(void **state)
+{
+ struct tevent_context *ev = (struct tevent_context *)(*state);
+ struct tevent_signal *se;
+ uint64_t tag;
+
+ se = tevent_add_signal(ev, ev, SIGUSR1, 0, signal_handler, NULL);
+ assert_non_null(se);
+
+ tag = tevent_signal_get_tag(se);
+ assert_int_equal(0, tag);
+
+ tevent_signal_set_tag(se, 1);
+ tag = tevent_signal_get_tag(se);
+ assert_int_equal(1, tag);
+
+ tevent_re_initialise(ev);
+
+ tag = tevent_signal_get_tag(se);
+ assert_int_equal(1, tag);
+
+ TALLOC_FREE(se);
+}
+
+static void test_immediate_tag(void **state)
+{
+ struct tevent_context *ev = (struct tevent_context *)(*state);
+ struct tevent_immediate *im;
+ uint64_t tag;
+
+ im = tevent_create_immediate(ev);
+ assert_non_null(im);
+
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(0, tag);
+
+ tevent_immediate_set_tag(im, 1);
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(1, tag);
+
+ tevent_schedule_immediate(im, ev, immediate_handler, NULL);
+
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(1, tag);
+
+ tevent_re_initialise(ev);
+
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(1, tag);
+
+ TALLOC_FREE(im);
+}
+
+int main(int argc, char **argv)
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_fd_tag, test_setup, test_teardown),
+ cmocka_unit_test_setup_teardown(test_timer_tag, test_setup, test_teardown),
+ cmocka_unit_test_setup_teardown(test_signal_tag, test_setup, test_teardown),
+ cmocka_unit_test_setup_teardown(test_immediate_tag, test_setup, test_teardown),
+ };
+
+ cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}
diff --git a/lib/tevent/tests/test_tevent_trace.c b/lib/tevent/tests/test_tevent_trace.c
new file mode 100644
index 00000000000..e9d26f9ceba
--- /dev/null
+++ b/lib/tevent/tests/test_tevent_trace.c
@@ -0,0 +1,1065 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * testing of some tevent_req aspects
+ *
+ * Copyright (C) Pavel Březina <pbrezina at redhat.com> 2021
+ *
+ * ** NOTE! The following LGPL license applies to the tevent
+ * ** library. This does NOT imply that all of Samba is released
+ * ** under the LGPL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <talloc.h>
+#include <tevent.h>
+#include <cmocka.h>
+
+struct test_ctx {
+ struct tevent_context *ev;
+
+ bool handler_skipped;
+ bool reattach_reset;
+
+ uint64_t (*get_tag)(const void *event);
+ void (*set_tag)(void *event, uint64_t tag);
+ uint64_t current_tag;
+
+ bool attach;
+ bool before_handler;
+ bool handler_called;
+ bool detach;
+};
+
+static void fd_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_fd_get_tag(fde);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+ return;
+}
+
+static void timer_handler(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_timer_get_tag(te);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+ return;
+}
+
+static void signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_signal_get_tag(se);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+ return;
+}
+
+static void immediate_handler(struct tevent_context *ctx,
+ struct tevent_immediate *im,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_immediate_get_tag(im);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+ return;
+}
+
+static void immediate_handler_reschedule(struct tevent_context *ctx,
+ struct tevent_immediate *im,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_immediate_get_tag(im);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+
+ assert_false(tctx->reattach_reset);
+ tctx->reattach_reset = true;
+ tevent_schedule_immediate(im, tctx->ev, immediate_handler, tctx);
+ assert_false(tctx->reattach_reset);
+ assert_false(tctx->handler_skipped);
+ assert_true(tctx->attach);
+ assert_false(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ assert_int_not_equal(tag, tctx->current_tag);
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(tag, tctx->current_tag);
+
+ tctx->handler_skipped = true;
+ tctx->reattach_reset = true;
+ tevent_schedule_immediate(im, tctx->ev, immediate_handler, tctx);
+ assert_false(tctx->reattach_reset);
+ assert_false(tctx->handler_skipped);
+ assert_true(tctx->attach);
+ assert_false(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ assert_int_not_equal(tag, tctx->current_tag);
+ tag = tevent_immediate_get_tag(im);
+ assert_int_equal(tag, tctx->current_tag);
+}
+
+static void fd_handler_free(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags,
+ void *private_data)
+{
+ struct test_ctx *tctx = (struct test_ctx *)private_data;
+ uint64_t tag = tevent_fd_get_tag(fde);
+ assert_true(tctx->attach);
+ assert_true(tctx->before_handler);
+ assert_false(tctx->handler_called);
+ assert_false(tctx->detach);
+ tctx->handler_called = true;
+ assert_int_equal(tag, tctx->current_tag);
+ TALLOC_FREE(fde);
+ assert_true(tctx->detach);
+ return;
+}
+
+static void timer_handler_free(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
--
Samba Shared Repository
More information about the samba-cvs
mailing list