Compare commits

...

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

11 changed files with 566 additions and 139 deletions

58
.gitignore vendored
View File

@ -1,2 +1,56 @@
SOURCES/tevent-0.16.0.tar.gz
SOURCES/tevent.keyring
tevent-0.9.8.tar.gz
/tevent-0.9.10.tar.gz
/tevent-0.9.11.tar.gz
/tevent-0.9.13.tar.gz
/tevent-0.9.14.tar.gz
/tevent-0.9.15.tar.gz
/tevent-0.9.16.tar.gz
/tevent-0.9.17.tar.gz
/tevent-0.9.18.tar.gz
/tevent-0.9.19.tar.gz
/tevent-0.9.20.tar.gz
/tevent-0.9.21.tar.gz
/tevent-0.9.22.tar.gz
/tevent-0.9.23.tar.gz
/tevent-0.9.24.tar.gz
/tevent-0.9.25.tar.gz
/tevent-0.9.26.tar.gz
/tevent-0.9.28.tar.gz
/tevent-0.9.29.tar.gz
/tevent-0.9.30.tar.gz
/tevent-0.9.31.tar.gz
/tevent-0.9.32.tar.gz
/tevent-0.9.33.tar.gz
/tevent-0.9.34.tar.gz
/tevent-0.9.35.tar.gz
/tevent-0.9.36.tar.gz
/tevent-0.9.37.tar.gz
/tevent-0.9.38.tar.gz
/tevent-0.9.39.tar.gz
/tevent-0.10.0.tar.gz
/tevent-0.10.1.tar.gz
/tevent-0.10.2.tar.gz
/tevent-0.10.1.tar.asc
/tevent-0.10.2.tar.asc
/tevent-0.11.0.tar.gz
/tevent-0.11.0.tar.asc
/tevent-0.12.0.tar.asc
/tevent-0.12.0.tar.gz
/tevent-0.12.1.tar.gz
/tevent-0.12.1.tar.asc
/tevent-0.13.0.tar.gz
/tevent-0.13.0.tar.asc
/tevent-0.14.0.tar.gz
/tevent-0.14.0.tar.asc
/tevent-0.14.1.tar.gz
/tevent-0.14.1.tar.asc
/tevent-0.15.0.tar.gz
/tevent-0.15.0.tar.asc
/tevent-0.16.0.tar.gz
/tevent-0.16.0.tar.asc
/tevent-0.16.1.tar.gz
/tevent-0.16.1.tar.asc
/tevent-0.16.2.tar.gz
/tevent-0.16.2.tar.asc
/tevent-0.17.1.tar.asc
/tevent-0.17.1.tar.gz

View File

@ -1,11 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iQEzBAABCgAdFiEEkUejOXGVGO6QEby1R5ORYRMIQCUFAmUs8V4ACgkQR5ORYRMI
QCWl4gf+NmjfvovCjcT8chpjSQakKh8TjS5Shb0Z9HN6VFGsFovDtyiChx4CjmrK
iHdVuS7PdeAcXOo6Y0nlpFcYl4Yo0MJWe+xrUIpT7OSq4jQW50pBv77QMEmCPSew
LJY/SMuMDCIlsD6BWfVav3SU2w0CL6iSBT4db1x+HDr8yjmZf40N8SaIu94NjSpE
ayKXlQxHiq8yT11fAg/MFl5RyCXHixgw7Ylzm7zGYxQB5ftUUaqCXgJcefBil1xs
fhChO+t2Rpb81fBhpgofLv1gcdUraBORfFHJLzOE+XSMnS229k88LyBsGOja9gpK
TvrMY9lzEwZXKvTwupFa74mKb7I0ng==
=863s
-----END PGP SIGNATURE-----

View File

@ -1,156 +1,133 @@
%if 0%{?fedora} || 0%{?rhel} > 7
%bcond_without python3
%else
%bcond_with python3
%endif
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 0.16.1-2
- Bump release for June 2024 mass rebuild
%global talloc_version 2.4.1
* Mon Jan 29 2024 Guenther Deschner <gdeschner@redhat.com> - 0.16.1-1
- rhbz#2260956 - libtevent-0.16.1 is available
Name: libtevent
Version: 0.16.0
Release: 0%{?dist}
Summary: The tevent library
License: LGPL-3.0-or-later
URL: http://tevent.samba.org/
Source0: http://samba.org/ftp/tevent/tevent-%{version}.tar.gz
Source1: http://samba.org/ftp/tevent/tevent-%{version}.tar.asc
# gpg2 --no-default-keyring --keyring ./tevent.keyring --recv-keys 9147A339719518EE9011BCB54793916113084025
Source2: tevent.keyring
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
# Patches
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
BuildRequires: docbook-style-xsl
BuildRequires: doxygen
BuildRequires: gcc
BuildRequires: gnupg2
BuildRequires: libcmocka-devel >= 1.1.3
BuildRequires: libtalloc-devel >= %{talloc_version}
BuildRequires: libxslt
BuildRequires: make
%if %{with python3}
BuildRequires: python3-devel
BuildRequires: python3-talloc-devel >= %{talloc_version}
#endif with python
%endif
* Fri Oct 27 2023 Andreas Schneider <asn@redhat.com> - 0.16.0-1
- Update to version 0.16.0
- resolves: rhbz#2244376
Provides: bundled(libreplace)
Obsoletes: python2-tevent < 0.10.0-1
* Mon Aug 07 2023 Guenther Deschner <gdeschner@redhat.com> - 0.15.0-1
- rhbz#2224332 - libtevent-0.15.0 is available
%description
Tevent is an event system based on the talloc memory management library.
Tevent has support for many event types, including timers, signals, and
the classic file descriptor events.
Tevent also provide helpers to deal with asynchronous code providing the
tevent_req (Tevent Request) functions.
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
%package devel
Summary: Developer tools for the Tevent library
Requires: libtevent%{?_isa} = %{version}-%{release}
Requires: libtalloc-devel%{?_isa} >= %{talloc_version}
* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 0.14.1-2
- Rebuilt for Python 3.12
%description devel
Header files needed to develop programs that link against the Tevent library.
* Thu Feb 23 2023 Pavel Filipenský <pfilipen@redhat.com> -0.14.1-1
- SPDX migration
* Thu Feb 16 2023 Guenther Deschner <gdeschner@redhat.com> - 0.14.1-1
- rhbz#2166867 - libtevent-0.14.1 is available
%if %{with python3}
%package -n python3-tevent
Summary: Python 3 bindings for the Tevent library
Requires: libtevent%{?_isa} = %{version}-%{release}
* Fri Jan 20 2023 Andreas Schneider <asn@redhat.com> - 0.14.0-1
- Update to version 0.14.0
%{?python_provide:%python_provide python3-tevent}
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
%description -n python3-tevent
Python 3 bindings for libtevent
#endif with python
%endif
* Mon Aug 08 2022 Guenther Deschner <gdeschner@redhat.com> - 0.13.0-1
- rhbz#2114634 - libtevent-0.13.0 is available
%prep
zcat %{SOURCE0} | gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} -
%autosetup -n tevent-%{version} -p1
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
%build
%configure --disable-rpath \
--bundled-libraries=NONE \
--builtin-libraries=replace
* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 0.12.1-2
- Rebuilt for Python 3.11
%make_build
doxygen doxy.config
%check
%make_build check
%install
%make_install
# Install API docs
rm -f doc/man/man3/todo*
install -d -m0755 %{buildroot}%{_mandir}
cp -a doc/man/man3 %{buildroot}%{_mandir}
%files
%{_libdir}/libtevent.so.*
%files devel
%{_includedir}/tevent.h
%{_libdir}/libtevent.so
%{_libdir}/pkgconfig/tevent.pc
%{_mandir}/man3/tevent*.gz
%if %{with python3}
%files -n python3-tevent
%{python3_sitearch}/tevent.py
%{python3_sitearch}/__pycache__/tevent.*
%{python3_sitearch}/_tevent.cpython*.so
%endif
%ldconfig_scriptlets
%changelog
* Fri Nov 17 2023 Pavel Filipenský <pfilipen@redhat.com> - 0.16.0-0
- resolves: RHEL-16504 - update to version 0.16.0
* Tue Jun 06 2023 Pavel Filipenský <pfilipen@redhat.com> - 0.14.1-3
- resolves: rhbz#2190425 - Rebuild to trigger distrobaker sync
* Wed May 24 2023 Pavel Filipenský <pfilipen@redhat.com> - 0.14.1-2
- resolves: rhbz#2190425 - Add missing tests to fix osci.brew-build.tier0.functional
* Thu May 18 2023 Pavel Filipenský <pfilipen@redhat.com> - 0.14.1-1
- resolves: rhbz#2190425 Update to version 0.14.1
* Mon Oct 24 2022 Andreas Schneider <asn@redhat.com> - 0.13.0-1
- resolves: rhbz#2132055 - Update to version 0.13.0
* Fri Jun 10 2022 Andreas Schneider <asn@redhat.com> - 0.12.1-1
- Update to version 0.12.1
- resolves: rhbz#2095120
* Mon May 02 2022 Pavel Filipenský <pfilipen@redhat.com> - 0.12.0-0
- resolves: rhbz#2077485 - Update to version 0.12.0
- Update to version 0.12.0
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.11.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.11.0-1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Jul 09 2021 Andreas Schneider <asn@redhat.com> - 0.11.0-0
- resolves: rhbz#1980346 - Update to version 0.11.0
- Update to version 0.11.0
* Tue Jun 2 2020 Isaac Boukris <iboukris@redhat.com> - 0.10.2-2
- Resolves: #1817563 - Upgrade tevent to 0.10.2 version for samba
* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.10.2-8
- Rebuilt for Python 3.10
* Tue Nov 26 2019 Isaac Boukris <iboukris@redhat.com> - 0.10.0-2
- Resolves: #1754421 - Upgrade tevent to 0.10.0 version for samba
- Related: #1754421 - Fix sssd tests (tevent)
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Apr 30 2019 Jakub Hrozek <jhrozek@redhat.com>
- Remove the python2 subpackages on upgrade
- Resolves: #1567139 - libtevent: Drop Python 2 subpackage from RHEL 8
* Thu Oct 22 2020 Andreas Schneider <asn@redhat.com> - 0.10.2-6
- Spec file cleanup and improvements
* Wed Apr 24 2019 Jakub Hrozek <jhrozek@redhat.com> - 0.9.39-1
- Resolves: #1684580 - Rebase libtevent to version 0.9.36 for Samba
- Resolves: #1597318 - libtevent uses Python 2 to build
- Resolves: #1567139 - libtevent: Drop Python 2 subpackage from RHEL 8
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Sep 20 2018 Jakub Hrozek <jhrozek@redhat.com> - 0.9.37-2
- Resolves: #1624138 - Review annocheck distro flag failures in libtevent
* Mon Jul 13 2020 Tom Stellard <tstellar@redhat.com> - 0.10.2-4
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.10.2-3
- Rebuilt for Python 3.9
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Wed Jan 22 2020 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.10.2-1
- rhbz#1749005 - libtevent-0.10.2 is available
* Wed Sep 11 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.10.1-1
- rhbz#1749005 - libtevent-0.10.1 is available
* Mon Aug 26 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.10.0-1
- rhbz#1691300 - libtevent-0.10.0 is available
- rhbz#1737644 - libldb, libtalloc, libtevent, libtdb: Remove Python 2 subpackages from Fedora 31+
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.39-5
- Rebuilt for Python 3.8
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.39-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Jun 14 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.9.39-3
- rhbz#1718113 - samba fail to build with Python 3.8
AttributeError: module 'time' has no attribute 'clock'
* Mon Jun 03 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.9.39-2
- rhbz#1711638 - fails to build with Python 3.8.0a4
* Tue Feb 26 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.9.39-1
- rhbz#1683186 - New upstream release 0.9.39
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.38-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Jan 17 2019 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.9.38-1
- New upstream release 0.9.38
* Fri Jul 13 2018 Jakub Hrozek <jhrozek@redhat.com> - 0.9.37-2
- Drop the unneeded ABI hide patch
* Thu Jul 12 2018 Jakub Hrozek <jhrozek@redhat.com> - 0.9.37-1
- New upstream release 0.9.37
- Use RHEL_ALLOW_PYTHON2_FOR_BUILD=1 for build
- Use %%{__python2}, not "python", as the Python2 interpreter
- Apply a patch to hide local ABI symbols to avoid issues with new binutils
- Patch the waf script to explicitly call python2 as "env python" doesn't
yield py2 anymore
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.9.36-3
- Rebuilt for Python 3.7
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.9.36-2
- Rebuilt for Python 3.7
* Mon Feb 26 2018 Lukas Slebodnik <lslebodn@fedoraproject.org> - 0.9.36-1
- rhbz#1548613 New upstream release 0.9.36

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

100
libtevent.spec Normal file
View File

@ -0,0 +1,100 @@
%global talloc_version 2.4.3
Name: libtevent
Version: 0.17.1
Release: %autorelease -b 100
Summary: The tevent library
License: LGPL-3.0-or-later
URL: http://tevent.samba.org/
Source0: http://samba.org/ftp/tevent/tevent-%{version}.tar.gz
Source1: http://samba.org/ftp/tevent/tevent-%{version}.tar.asc
# gpg2 --no-default-keyring --keyring ./tevent.keyring --recv-keys 9147A339719518EE9011BCB54793916113084025
Source2: tevent.keyring
# Patches
BuildRequires: docbook-style-xsl
BuildRequires: doxygen
BuildRequires: gcc
BuildRequires: gnupg2
BuildRequires: libcmocka-devel >= 1.1.3
BuildRequires: libtalloc-devel >= %{talloc_version}
BuildRequires: libxslt
BuildRequires: make
BuildRequires: python3-devel
BuildRequires: python3-talloc-devel >= %{talloc_version}
Provides: bundled(libreplace)
Obsoletes: python2-tevent < 0.10.0-1
%description
Tevent is an event system based on the talloc memory management library.
Tevent has support for many event types, including timers, signals, and
the classic file descriptor events.
Tevent also provide helpers to deal with asynchronous code providing the
tevent_req (Tevent Request) functions.
%package devel
Summary: Developer tools for the Tevent library
Requires: libtevent%{?_isa} = %{version}-%{release}
Requires: libtalloc-devel%{?_isa} >= %{talloc_version}
%description devel
Header files needed to develop programs that link against the Tevent library.
%package -n python3-tevent
Summary: Python 3 bindings for the Tevent library
Requires: libtevent%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python3-tevent}
%description -n python3-tevent
Python 3 bindings for libtevent
%prep
zcat %{SOURCE0} | gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} -
%autosetup -n tevent-%{version} -p1
%build
# workaround https://gitlab.com/ita1024/waf/-/issues/2472
export PYTHONARCHDIR=%{python3_sitearch}
%configure --disable-rpath \
--bundled-libraries=NONE \
--builtin-libraries=replace
%make_build
doxygen doxy.config
%check
%make_build check
%install
%make_install
# Install API docs
rm -f doc/man/man3/todo*
install -d -m0755 %{buildroot}%{_mandir}
cp -a doc/man/man3 %{buildroot}%{_mandir}
%files
%license LICENSE
%{_libdir}/libtevent.so.*
%files devel
%{_includedir}/tevent.h
%{_libdir}/libtevent.so
%{_libdir}/pkgconfig/tevent.pc
%{_mandir}/man3/tevent*.gz
%files -n python3-tevent
%{python3_sitearch}/tevent.py
%{python3_sitearch}/__pycache__/tevent.*
%{python3_sitearch}/_tevent.cpython*.so
%ldconfig_scriptlets
%changelog
%autochangelog

2
sources Normal file
View File

@ -0,0 +1,2 @@
SHA512 (tevent-0.17.1.tar.asc) = 3bffc88c1a5dd9857078c1b9b9cbfde77132b9e1cf98a9af1a7d2f88f4b26f504bb6c7a86a2e0f656fe3d0d875209bb2392be0d84986c090ef89716598b42d20
SHA512 (tevent-0.17.1.tar.gz) = 781f8aced9ad135e64ce3953a013434feb84a6945ccfbce58a6ff21cb3da48af1e32324a5a950a55256a02545c2e1808a4cd8b209a3f970375347c8b390df258

View File

@ -0,0 +1,46 @@
# SPDX-License-Identifier: LGPL-2.1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/libtevent
# Description: Test if libtevent working ok
# Author: Susant Sahani<susant@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/libtevent
export TESTVERSION=1.0
OBJS = test-libtevent.c
CFLAG = -Wall -g3
CC = gcc
LIBS = -ltevent -ltalloc -lpthread
test-libtevent:${OBJ}
${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
run: test-libtevent
./runtest.sh
clean:
-rm -f *~ test-libtevent
.c.o:
${CC} ${CFLAGS} ${INCLUDES} -c $<
CC = gcc
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani<susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test libtevent works ok" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: libtevent" >> $(METADATA)
@echo "Requires: libtevent libtevent-devel" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RedHat Linux 8" >> $(METADATA)
rhts-lint $(METADATA)

34
tests/sanity-tests/runtest.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of libtevent
# Description: Tests for libtevent
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libtevent"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp test-libtevent /usr/bin/"
rlPhaseEnd
rlPhaseStartTest
rlLog "Starting libtevent tests ..."
rlRun "/usr/bin/test-libtevent"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/test-libtevent"
rlLog "libtevent tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,207 @@
#include <stdio.h>
#include <unistd.h>
#include <tevent.h>
#include <sys/time.h>
#include <signal.h>
#include <assert.h>
#include <pthread.h>
struct state {
struct timeval endtime;
int counter;
TALLOC_CTX *ctx;
};
struct info_struct {
int counter;
};
static void callback(struct tevent_context *ev, struct tevent_timer *tim,
struct timeval current_time, void *private_data) {
struct state *data = talloc_get_type_abort(private_data, struct state);
struct tevent_timer *time_event;
struct timeval schedule;
data->counter += 1;
if (tevent_timeval_compare(&current_time, &(data->endtime)) < 0) {
schedule = tevent_timeval_current_ofs(1, 0);
time_event = tevent_add_timer(ev, data->ctx, schedule, callback, data);
assert(time_event);
}
}
int test_tevent_timer(void) {
struct tevent_context *event_ctx;
struct tevent_timer *time_event;
struct timeval schedule;
struct state *data;
TALLOC_CTX *mem_ctx;
assert((mem_ctx = talloc_new(NULL)));
assert((event_ctx = tevent_context_init(mem_ctx)));
assert((data = talloc(mem_ctx, struct state)));
schedule = tevent_timeval_current_ofs(1, 0);
data->endtime = tevent_timeval_add(&schedule, 2, 0);
data->ctx = mem_ctx;
data->counter = 0;
time_event = tevent_add_timer(event_ctx, mem_ctx, schedule, callback, data);
tevent_loop_wait(event_ctx);
assert(data->counter == 3);
talloc_free(mem_ctx);
}
static void foo(struct tevent_context *ev, struct tevent_immediate *im, void *private_data) {
struct info_struct *data = talloc_get_type_abort(private_data, struct info_struct);
data->counter++;
}
int test_tevent_immediate(void) {
struct tevent_context *event_ctx;
struct tevent_immediate *im;
struct info_struct *data;
TALLOC_CTX *mem_ctx;
assert((mem_ctx = talloc_new(NULL)));
event_ctx = tevent_context_init(mem_ctx);
assert((data = talloc(mem_ctx, struct info_struct)));
data->counter = 0;
assert((im = tevent_create_immediate(mem_ctx)));
tevent_schedule_immediate(im, event_ctx, foo, data);
tevent_loop_wait(event_ctx);
assert(data->counter == 1);
talloc_free(mem_ctx);
return 0;
}
int signal_data;
static void handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) {
signal_data = 1;
}
int test_tevent_signal(void) {
struct tevent_context *event_ctx;
struct tevent_signal *sig;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_new(NULL);
assert(mem_ctx);
event_ctx = tevent_context_init(mem_ctx);
assert(event_ctx);
if (tevent_signal_support(event_ctx)) {
sig = tevent_add_signal(event_ctx, mem_ctx, SIGINT, 0, handler, NULL);
assert(sig);
tevent_loop_once(event_ctx);
}
talloc_free(mem_ctx);
}
struct foo_state {
int x;
};
struct testA {
int y;
};
static void foo_done(struct tevent_req *req) {
struct foo_state *a = tevent_req_data(req, struct foo_state);
struct testA *b = tevent_req_callback_data(req, struct testA);
struct testA *c = (struct testA *) tevent_req_callback_data_void(req);
assert(a->x == 10);
assert(b->y == 9);
assert(c->y == 9);
printf("a->x: %d\n", a->x);
printf("b->y: %d\n", b->y);
printf("c->y: %d\n", c->y);
}
struct tevent_req * foo_send(TALLOC_CTX *mem_ctx, struct tevent_context *event_ctx) {
struct tevent_req *req;
struct foo_state *state;
printf("_send\n");
req = tevent_req_create(event_ctx, &state, struct foo_state);
state->x = 10;
return req;
}
static void run(struct tevent_context *ev, struct tevent_timer *te,
struct timeval current_time, void *private_data) {
struct tevent_req *req;
struct testA *tmp = talloc(ev, struct testA);
tmp->y = 9;
req = foo_send(ev, ev);
tevent_req_set_callback(req, foo_done, tmp);
tevent_req_done(req);
}
int test_event_data(void) {
struct tevent_context *event_ctx;
struct tevent_timer *time_event;
struct testA *data;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_new(NULL);
assert(mem_ctx);
event_ctx = tevent_context_init(mem_ctx);
assert(event_ctx);
data = talloc(mem_ctx, struct testA);
data->y = 11;
time_event = tevent_add_timer(event_ctx,
mem_ctx,
tevent_timeval_current(),
run,
data);
assert(time_event);
tevent_loop_once(event_ctx);
talloc_free(mem_ctx);
return 0;
}
int main() {
pid_t pid, ppid;
int r;
test_tevent_timer();
test_tevent_immediate();
/* signal test */
ppid = getpid();
if((pid = fork()) == 0) {
sleep(1);
kill(ppid, SIGINT);
exit(0);
} else {
test_tevent_signal();
}
assert(signal_data == 1);
test_event_data();
}

12
tests/tests.yml Normal file
View File

@ -0,0 +1,12 @@
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- sanity-tests
required_packages:
- libtevent
- libtevent-devel
- glibc
- gcc

BIN
tevent.keyring Normal file

Binary file not shown.