diff --git a/.gitignore b/.gitignore index 5684048..00ef136 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,30 @@ /avocado-50.0.tar.gz /avocado-51.0.tar.gz /avocado-52.0.tar.gz +/avocado-52.1.tar.gz +/avocado-61.0.tar.gz +/avocado-62.0.tar.gz +/avocado-63.0.tar.gz +/avocado-64.0.tar.gz +/avocado-65.0.tar.gz +/avocado-66.0.tar.gz +/avocado-67.0.tar.gz +/avocado-68.0.tar.gz +/avocado-69.0.tar.gz +/avocado-70.0.tar.gz +/avocado-71.0.tar.gz +/avocado-72.0.tar.gz +/avocado-73.0.tar.gz +/avocado-74.0.tar.gz +/avocado-75.1.tar.gz +/avocado-76.0.tar.gz +/avocado-77.0.tar.gz +/avocado-78.0.tar.gz +/avocado-79.0.tar.gz +/avocado-80.0.tar.gz +/avocado-82.0.tar.gz +/avocado-92.0.tar.gz +/avocado-92.1.tar.gz +/avocado-92.1-python312.patch +/avocado-92.3.tar.gz +/avocado-112.0.tar.gz diff --git a/avocado-selftest-doublefree-disable.patch b/avocado-selftest-doublefree-disable.patch deleted file mode 100644 index 075de2b..0000000 --- a/avocado-selftest-doublefree-disable.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -r -u avocado-52.0.orig/selftests/functional/test_output.py avocado-52.0/selftests/functional/test_output.py ---- avocado-52.0.orig/selftests/functional/test_output.py 2017-06-26 19:26:48.000000000 -0500 -+++ avocado-52.0/selftests/functional/test_output.py 2017-08-09 07:40:41.636928188 -0500 -@@ -67,6 +67,7 @@ - def setUp(self): - self.tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__) - -+ @unittest.skip("Test is producing a false failure due to platform/compiler changes") - @unittest.skipIf(missing_binary('cc'), - "C compiler is required by the underlying doublefree.py test") - def test_output_doublefree(self): diff --git a/python-avocado.spec b/python-avocado.spec index fc9c075..8dd8cf4 100644 --- a/python-avocado.spec +++ b/python-avocado.spec @@ -1,6 +1,3 @@ -%global srcname avocado -%global pkgname avocado - # Conditional for release vs. snapshot builds. Set to 1 for release build. %if ! 0%{?rel_build:1} %global rel_build 1 @@ -8,361 +5,530 @@ # Settings used for build from snapshots. %if 0%{?rel_build} - %global gittar %{srcname}-%{version}.tar.gz + %global gitref %{version} + %global gittar avocado-%{version}.tar.gz %else %if ! 0%{?commit:1} - %global commit bb62fe5a1fa93ea6573da46556928af5041c1b7d + %global commit e4ede79f097dcc1dbd30e43ffe3b7daf52d2204d %endif %if ! 0%{?commit_date:1} - %global commit_date 20170626 + %global commit_date 20251010 %endif - %global shortcommit %(c=%{commit};echo ${c:0:7}) - %global gitrel .%{commit_date}git%{shortcommit} - %global gittar %{srcname}-%{shortcommit}.tar.gz + %global shortcommit %(c=%{commit};echo ${c:0:9}) + %global gitrel .%{commit_date}git%{shortcommit} + %global gitref %{commit} + %global gittar avocado-%{shortcommit}.tar.gz %endif # Selftests are provided but may need to be skipped because many of # the functional tests are time and resource sensitive and can # cause race conditions and random build failures. They are # enabled by default. -# However, selftests need to be disabled when libvirt is not available. -%global with_tests 1 -%if 0%{?rhel} - # libvirt is not available for all RHEL builder architectures - %global with_tests 0 +# You can disable them with rpmbuild ... --without tests +%bcond_without tests + +# Only Fedora 36 and later have a suitable python3-resutlsdb_api +# package +%if 0%{?fedora} >= 36 +%global with_resultsdb 1 +%else +%global with_resultsdb 0 %endif -Name: python-%{pkgname} -Version: 52.0 -Release: 3%{?gitrel}%{?dist} +Name: python-avocado +Version: 112.0 +Release: 1%{?gitrel}%{?dist} Summary: Framework with tools and libraries for Automated Testing -Group: Development/Tools # Found licenses: +# avocado/core/tapparser.py: MIT # avocado/utils/external/gdbmi_parser.py: MIT # avocado/utils/external/spark.py: MIT -# optional_plugins/html/avocado_result_html/resources/static/css/*: MIT -# optional_plugins/html/avocado_result_html/resources/static/js/*: MIT +# optional_plugins/html/avocado_result_html/templates/bootstrap.min.css: MIT +# optional_plugins/html/avocado_result_html/templates/bootstrap.min.js: MIT +# selftests/.data/jenkins-junit.xsd: MIT # Other files: GPLv2 and GPLv2+ -License: GPLv2 and MIT -URL: http://avocado-framework.github.io/ -%if 0%{?rel_build} -Source0: https://github.com/avocado-framework/%{srcname}/archive/%{version}.tar.gz#/%{gittar} -%else -Source0: https://github.com/avocado-framework/%{srcname}/archive/%{commit}.tar.gz#/%{gittar} -%endif -Patch0: avocado-selftest-doublefree-disable.patch +License: GPLv2+ and GPLv2 and MIT +URL: https://avocado-framework.github.io/ +Source0: https://github.com/avocado-framework/avocado/archive/%{gitref}/%{gittar} BuildArch: noarch -BuildRequires: fabric -BuildRequires: pystache -BuildRequires: python2-aexpect -BuildRequires: python2-devel -BuildRequires: python-docutils -BuildRequires: python-flexmock -BuildRequires: python-lxml -BuildRequires: python2-mock -BuildRequires: python-resultsdb_api -%if 0%{?with_tests} -BuildRequires: libvirt-python -BuildRequires: perl(TAP::Parser) -%if 0%{?rhel} -BuildRequires: python-yaml -%else -BuildRequires: python2-yaml -%endif -%endif - -%if 0%{?rhel} -BuildRequires: python-psutil -BuildRequires: python-requests -BuildRequires: python-setuptools -BuildRequires: python-sphinx -BuildRequires: python-stevedore -%else -BuildRequires: python2-psutil -BuildRequires: python2-requests -BuildRequires: python2-setuptools -BuildRequires: python2-sphinx -BuildRequires: python2-stevedore -%endif - -%if 0%{?el6} -BuildRequires: procps -BuildRequires: python-argparse -BuildRequires: python-importlib -BuildRequires: python-logutils -BuildRequires: python-unittest2 -%else +BuildRequires: kmod BuildRequires: procps-ng +BuildRequires: python3-devel +BuildRequires: python3-docutils +BuildRequires: python3-jinja2 +BuildRequires: python3-lxml +BuildRequires: python3-psutil +BuildRequires: python3-setuptools +%if ! 0%{?rhel} +BuildRequires: python-aexpect +%endif +%if %{with_resultsdb} +BuildRequires: python3-resultsdb_api +BuildRequires: python3-pycdlib %endif -# For some strange reason, fabric on Fedora 24 does not require the -# python-crypto package, but the fabric code always imports it. Newer -# fabric versions, such from Fedora 25 do conditional imports (try: -# from Crypto import Random; except: Random = None) and thus do not -# need this requirement. -%if 0%{?fedora} == 24 -BuildRequires: python-crypto +%if %{with tests} +BuildRequires: python3-jsonschema +%if ! 0%{?rhel} >= 9 +BuildRequires: genisoimage %endif - -%if 0%{?fedora} >= 25 -BuildRequires: kmod +BuildRequires: libcdio +BuildRequires: psmisc +%if ! 0%{?rhel} +BuildRequires: perl-Test-Harness +BuildRequires: python3-xmlschema +BuildRequires: ansible-core %endif -%if 0%{?rhel} >= 7 -BuildRequires: kmod +BuildRequires: glibc-all-langpacks +BuildRequires: python3-netifaces +BuildRequires: python3-yaml +BuildRequires: nmap-ncat +BuildRequires: gcc +BuildRequires: gdb +BuildRequires: gdb-gdbserver %endif +# with tests %description Avocado is a set of tools and libraries (what people call these days a framework) to perform automated testing. -%package -n python2-%{pkgname} +%prep +%setup -q -n avocado-%{gitref} +%if 0%{?rhel} +sed -e 's/"PyYAML>=4.2b2"/"PyYAML>=3.12"/' -i optional_plugins/varianter_yaml_to_mux/setup.py +%endif +%if 0%{?fedora} >= 42 +sed -e '/"markupsafe<3.0.0"/d' -i optional_plugins/html/setup.py +sed -e '/"markupsafe<3.0.0"/d' -i optional_plugins/ansible/setup.py +%endif + +%build +%py3_build +pushd optional_plugins/html + %py3_build +popd +%if %{with_resultsdb} +pushd optional_plugins/resultsdb + %py3_build +popd +%endif +pushd optional_plugins/varianter_yaml_to_mux + %py3_build +popd +pushd optional_plugins/golang + %py3_build +popd +%if ! 0%{?rhel} +pushd optional_plugins/ansible + %py3_build +popd +%endif +pushd optional_plugins/varianter_pict + %py3_build +popd +pushd optional_plugins/varianter_cit + %py3_build +popd +pushd optional_plugins/result_upload + %py3_build +popd +pushd optional_plugins/mail + %py3_build +popd +%if ! 0%{?rhel} +pushd optional_plugins/spawner_remote + %py3_build +popd +%endif +rst2man man/avocado.rst man/avocado.1 + +%install +%py3_install +for exe in \ + avocado \ + avocado-runner-noop \ + avocado-runner-dry-run \ + avocado-runner-exec-test \ + avocado-runner-python-unittest \ + avocado-runner-avocado-instrumented \ + avocado-runner-tap \ + avocado-runner-asset \ + avocado-runner-package \ + avocado-runner-pip \ + avocado-runner-podman-image \ + avocado-runner-sysinfo \ + avocado-runner-vmimage \ + avocado-external-runner \ + avocado-software-manager +do + mv %{buildroot}%{_bindir}/$exe %{buildroot}%{_bindir}/$exe-%{python3_version} + ln -s $exe-%{python3_version} %{buildroot}%{_bindir}/$exe-3 + ln -s $exe-%{python3_version} %{buildroot}%{_bindir}/$exe +done +# configuration is held at /etc/avocado only and part of the +# python-avocado-common package +rm -rf %{buildroot}%{python3_sitelib}/avocado/etc +# ditto for libexec files +rm -rf %{buildroot}%{python3_sitelib}/avocado/libexec +pushd optional_plugins/html + %py3_install +popd +%if %{with_resultsdb} +pushd optional_plugins/resultsdb + %py3_install +popd +%endif +pushd optional_plugins/varianter_yaml_to_mux + %py3_install +popd +pushd optional_plugins/golang + %py3_install +popd +%if ! 0%{?rhel} +pushd optional_plugins/ansible + %py3_install +popd +%endif +pushd optional_plugins/varianter_pict + %py3_install +popd +pushd optional_plugins/varianter_cit + %py3_install +popd +pushd optional_plugins/result_upload + %py3_install +popd +pushd optional_plugins/mail + %py3_install +popd +%if ! 0%{?rhel} +pushd optional_plugins/spawner_remote + %py3_install +popd +%endif +# cleanup plugin test cruft +rm -rf %{buildroot}%{python3_sitelib}/tests +mkdir -p %{buildroot}%{_sysconfdir}/avocado +cp -r avocado/etc/avocado/scripts %{buildroot}%{_sysconfdir}/avocado/scripts +cp -r avocado/etc/avocado/sysinfo %{buildroot}%{_sysconfdir}/avocado/sysinfo +mkdir -p %{buildroot}%{_libexecdir}/avocado +cp avocado/libexec/avocado-bash-utils %{buildroot}%{_libexecdir}/avocado/avocado-bash-utils +cp avocado/libexec/avocado_debug %{buildroot}%{_libexecdir}/avocado/avocado_debug +cp avocado/libexec/avocado_error %{buildroot}%{_libexecdir}/avocado/avocado_error +cp avocado/libexec/avocado_info %{buildroot}%{_libexecdir}/avocado/avocado_info +cp avocado/libexec/avocado_warn %{buildroot}%{_libexecdir}/avocado/avocado_warn +mkdir -p %{buildroot}%{_mandir}/man1 +install -m 0644 man/avocado.1 %{buildroot}%{_mandir}/man1/avocado.1 +mkdir -p %{buildroot}%{_pkgdocdir} +install -m 0644 README.rst %{buildroot}%{_pkgdocdir} +install -d -m 0755 %{buildroot}%{_sharedstatedir}/avocado/data +# place examples in documentation directory +install -d -m 0755 %{buildroot}%{_docdir}/avocado +cp -r examples/gdb-prerun-scripts %{buildroot}%{_docdir}/avocado/gdb-prerun-scripts +cp -r examples/plugins %{buildroot}%{_docdir}/avocado/plugins +cp -r examples/tests %{buildroot}%{_docdir}/avocado/tests +cp -r examples/varianter_cit %{buildroot}%{_docdir}/avocado/varianter_cit +cp -r examples/varianter_pict %{buildroot}%{_docdir}/avocado/varianter_pict +cp -r examples/yaml_to_mux %{buildroot}%{_docdir}/avocado/yaml_to_mux +mkdir -p %{buildroot}%{_datarootdir}/avocado +mv %{buildroot}%{python3_sitelib}/avocado/schemas %{buildroot}%{_datarootdir}/avocado +find %{buildroot}%{_docdir}/avocado -type f -name '*.py' -exec chmod -c -x {} ';' + +%if %{with tests} +%check + # LANG: to make the results predictable, we pin the language + # that is used during test execution. + # AVOCADO_CHECK_LEVEL: package build environments have the least + # amount of resources we have observed so far. Let's avoid tests that + # require too much resources or are time sensitive + PATH=%{buildroot}%{_bindir}:%{buildroot}%{_libexecdir}/avocado:$PATH \ + PYTHONPATH=%{buildroot}%{python3_sitelib}:. \ + LANG=en_US.UTF-8 \ + AVOCADO_CHECK_LEVEL=0 \ + %{python3} selftests/check.py --skip static-checks --disable-plugin-checks robot +%endif + + +%package -n python3-avocado Summary: %{summary} -License: GPLv2 and MIT -%{?python_provide:%python_provide python2-%{pkgname}} -Requires: fabric +Requires: python-avocado-common == %{version}-%{release} Requires: gdb Requires: gdb-gdbserver -Requires: pyliblzma -Requires: pystache -Requires: python2 - -%if 0%{?rhel} -Requires: python-requests -Requires: python-stevedore -%else -Requires: python2-requests -Requires: python2-stevedore -%endif - -%if 0%{?el6} -Requires: procps -Requires: python-argparse -Requires: python-importlib -Requires: python-logutils -Requires: python-unittest2 -%else Requires: procps-ng +%if ! 0%{?rhel} +Requires: python3-pycdlib %endif - -%description -n python2-%{pkgname} +%description -n python3-avocado Avocado is a set of tools and libraries (what people call these days a framework) to perform automated testing. - -%package -n python2-%{pkgname}-plugins-output-html -Summary: Avocado HTML report plugin -%{?python_provide:%python_provide python2-%{pkgname}-plugins-output-html} -Requires: python2-%{pkgname} == %{version}-%{release} -Requires: pystache - -%description -n python2-%{pkgname}-plugins-output-html -Adds to avocado the ability to generate an HTML report at every job results -directory. It also gives the user the ability to write a report on an -arbitrary filesystem location. - - -%package -n python2-%{pkgname}-plugins-runner-remote -Summary: Avocado Runner for Remote Execution -%{?python_provide:%python_provide python2-%{pkgname}-plugins-runner-remote} -Requires: python2-%{pkgname} == %{version}-%{release} -Requires: fabric -%if 0%{?fedora} == 24 -Requires: python-crypto -%endif - -%description -n python2-%{pkgname}-plugins-runner-remote -Allows Avocado to run jobs on a remote machine, by means of an SSH -connection. Avocado must be previously installed on the remote machine. - - -%package -n python2-%{pkgname}-plugins-runner-vm -Summary: Avocado Runner for libvirt VM Execution -%{?python_provide:%python_provide python2-%{pkgname}-plugins-runner-vm} -Requires: python2-%{pkgname} == %{version}-%{release} -Requires: python2-%{pkgname}-plugins-runner-remote == %{version}-%{release} -Requires: libvirt-python - -%description -n python2-%{pkgname}-plugins-runner-vm -Allows Avocado to run jobs on a libvirt based VM, by means of -interaction with a libvirt daemon and an SSH connection to the VM -itself. Avocado must be previously installed on the VM. - - -%package -n python2-%{pkgname}-plugins-runner-docker -Summary: Avocado Runner for Execution on Docker Containers -%{?python_provide:%python_provide python2-%{pkgname}-plugins-runner-docker} -Requires: python2-%{pkgname} == %{version}-%{release} -Requires: python2-%{pkgname}-plugins-runner-remote == %{version}-%{release} -Requires: python2-aexpect - -%description -n python2-%{pkgname}-plugins-runner-docker -Allows Avocado to run jobs on a Docker container by interacting with a -Docker daemon and attaching to the container itself. Avocado must -be previously installed on the container. - - -%package -n python2-%{pkgname}-plugins-resultsdb -Summary: Avocado plugin to propagate job results to ResultsDB -%{?python_provide:%python_provide python2-%{pkgname}-plugins-resultsdb} -Requires: python2-%{pkgname} == %{version}-%{release} -Requires: python-resultsdb_api - -%description -n python2-%{pkgname}-plugins-resultsdb -Allows Avocado to send job results directly to a ResultsDB -server. - - -%package -n python2-%{pkgname}-plugins-varianter-yaml-to-mux -Summary: Avocado plugin to generate variants out of yaml files -%{?python_provide:%python_provide python2-%{pkgname}-plugins-resultsdb} -Requires: python2-%{pkgname} == %{version}-%{release} -%if 0%{?rhel} -Requires: python-yaml -%else -Requires: python2-yaml -%endif - -%description -n python2-%{pkgname}-plugins-varianter-yaml-to-mux -Can be used to produce multiple test variants with test parameters -defined in a yaml file(s). - - -%package -n python-%{pkgname}-examples -Summary: Avocado Test Framework Example Tests -License: GPLv2 -# documentation does not require main package, but needs to be in lock-step if present -Conflicts: python-%{pkgname} < %{version}-%{release}, python-%{pkgname} > %{version}-%{release} - -%description -n python-%{pkgname}-examples -The set of example tests present in the upstream tree of the Avocado framework. -Some of them are used as functional tests of the framework, others serve as -examples of how to write tests on your own. - - -%prep -%if 0%{?rel_build} -%setup -q -n %{srcname}-%{version} -%else -%setup -q -n %{srcname}-%{commit} -%endif -%patch0 -p1 -# package plugins-runner-vm requires libvirt-python, but the RPM -# version of libvirt-python does not publish the egg info and this -# causes that dep to be attempted to be installed by pip -sed -e "s/'libvirt-python'//" -i optional_plugins/runner_vm/setup.py - -%build -%{__python2} setup.py build -pushd optional_plugins/html - %{__python2} setup.py build -popd -pushd optional_plugins/runner_remote - %{__python2} setup.py build -popd -pushd optional_plugins/runner_vm - %{__python2} setup.py build -popd -pushd optional_plugins/runner_docker - %{__python2} setup.py build -popd -pushd optional_plugins/resultsdb - %{__python2} setup.py build -popd -pushd optional_plugins/varianter_yaml_to_mux - %{__python2} setup.py build -popd -%{__make} man - -%install -%{__python2} setup.py install --root %{buildroot} --skip-build -pushd optional_plugins/html - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -pushd optional_plugins/runner_remote - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -pushd optional_plugins/runner_vm - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -pushd optional_plugins/runner_docker - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -pushd optional_plugins/resultsdb - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -pushd optional_plugins/varianter_yaml_to_mux - %{__python2} setup.py install --root %{buildroot} --skip-build -popd -%{__mkdir_p} %{buildroot}%{_mandir}/man1 -%{__install} -m 0644 man/avocado.1 %{buildroot}%{_mandir}/man1/avocado.1 -%{__install} -m 0644 man/avocado-rest-client.1 %{buildroot}%{_mandir}/man1/avocado-rest-client.1 -%{__install} -d -m 0755 %{buildroot}%{_sharedstatedir}/avocado/data -# relocate examples to documentation directory -%{__mkdir_p} %{buildroot}%{_docdir}/avocado -%{__mv} %{buildroot}%{_datadir}/avocado/tests %{buildroot}%{_docdir}/avocado/tests -%{__mv} %{buildroot}%{_datadir}/avocado/wrappers %{buildroot}%{_docdir}/avocado/wrappers -find %{buildroot}%{_docdir}/avocado -type f -name '*.py' -exec %{__chmod} -c -x {} ';' - - -%check -%if 0%{?with_tests} - %{__python2} setup.py develop --user - pushd optional_plugins/html - %{__python2} setup.py develop --user - popd - pushd optional_plugins/runner_remote - %{__python2} setup.py develop --user - popd - pushd optional_plugins/runner_vm - %{__python2} setup.py develop --user - popd - pushd optional_plugins/runner_docker - %{__python2} setup.py develop --user - popd - pushd optional_plugins/resultsdb - %{__python2} setup.py develop --user - popd - pushd optional_plugins/varianter_yaml_to_mux - %{__python2} setup.py develop --user - popd - # Package build environments have the least amount of resources - # we have observed so far. Let's avoid tests that require too - # much resources or are time sensitive. - AVOCADO_CHECK_LEVEL=0 selftests/run -%endif - - -%files -n python2-%{pkgname} +%files -n python3-avocado %license LICENSE -%doc README.rst +%{_pkgdocdir}/README.rst +%{python3_sitelib}/avocado/ +%{python3_sitelib}/avocado_framework-%{version}-py%{python3_version}.egg-info +%{_bindir}/avocado-%{python3_version} +%{_bindir}/avocado-3 +%{_bindir}/avocado +%{_bindir}/avocado-runner-noop-%{python3_version} +%{_bindir}/avocado-runner-noop-3 +%{_bindir}/avocado-runner-noop +%{_bindir}/avocado-runner-dry-run-%{python3_version} +%{_bindir}/avocado-runner-dry-run-3 +%{_bindir}/avocado-runner-dry-run +%{_bindir}/avocado-runner-exec-test-%{python3_version} +%{_bindir}/avocado-runner-exec-test-3 +%{_bindir}/avocado-runner-exec-test +%{_bindir}/avocado-runner-python-unittest-%{python3_version} +%{_bindir}/avocado-runner-python-unittest-3 +%{_bindir}/avocado-runner-python-unittest +%{_bindir}/avocado-runner-avocado-instrumented-%{python3_version} +%{_bindir}/avocado-runner-avocado-instrumented-3 +%{_bindir}/avocado-runner-avocado-instrumented +%{_bindir}/avocado-runner-tap-%{python3_version} +%{_bindir}/avocado-runner-tap-3 +%{_bindir}/avocado-runner-tap +%{_bindir}/avocado-runner-asset-%{python3_version} +%{_bindir}/avocado-runner-asset-3 +%{_bindir}/avocado-runner-asset +%{_bindir}/avocado-runner-package-%{python3_version} +%{_bindir}/avocado-runner-package-3 +%{_bindir}/avocado-runner-package +%{_bindir}/avocado-runner-pip-%{python3_version} +%{_bindir}/avocado-runner-pip-3 +%{_bindir}/avocado-runner-pip +%{_bindir}/avocado-runner-podman-image-%{python3_version} +%{_bindir}/avocado-runner-podman-image-3 +%{_bindir}/avocado-runner-podman-image +%{_bindir}/avocado-runner-sysinfo-%{python3_version} +%{_bindir}/avocado-runner-sysinfo-3 +%{_bindir}/avocado-runner-sysinfo +%{_bindir}/avocado-runner-vmimage-%{python3_version} +%{_bindir}/avocado-runner-vmimage-3 +%{_bindir}/avocado-runner-vmimage +%{_bindir}/avocado-software-manager-%{python3_version} +%{_bindir}/avocado-software-manager-3 +%{_bindir}/avocado-software-manager +%{_bindir}/avocado-external-runner-%{python3_version} +%{_bindir}/avocado-external-runner-3 +%{_bindir}/avocado-external-runner + + +%package -n python-avocado-common +Summary: Avocado common files +License: GPLv2+ + +%description -n python-avocado-common +Common files (such as configuration) for the Avocado Testing Framework. + +%files -n python-avocado-common +%license LICENSE +%{_mandir}/man1/avocado.1.gz +%dir %{_docdir}/avocado +%dir %{_sharedstatedir}/avocado %dir %{_sysconfdir}/avocado -%dir %{_sysconfdir}/avocado/conf.d %dir %{_sysconfdir}/avocado/sysinfo %dir %{_sysconfdir}/avocado/scripts %dir %{_sysconfdir}/avocado/scripts/job %dir %{_sysconfdir}/avocado/scripts/job/pre.d %dir %{_sysconfdir}/avocado/scripts/job/post.d -%config(noreplace) %{_sysconfdir}/avocado/avocado.conf -%config(noreplace) %{_sysconfdir}/avocado/conf.d/gdb.conf +%dir %{_sharedstatedir}/avocado/data +%dir %{_datarootdir}/avocado +%dir %{_datarootdir}/avocado/schemas +%{_datarootdir}/avocado/schemas/* %config(noreplace) %{_sysconfdir}/avocado/sysinfo/commands %config(noreplace) %{_sysconfdir}/avocado/sysinfo/files %config(noreplace) %{_sysconfdir}/avocado/sysinfo/profilers -%{_sysconfdir}/avocado/conf.d/README %{_sysconfdir}/avocado/scripts/job/pre.d/README %{_sysconfdir}/avocado/scripts/job/post.d/README -%{python2_sitelib}/avocado/ -%{python2_sitelib}/avocado_framework-%{version}-py%{python2_version}.egg-info -%{_bindir}/avocado -%{_bindir}/avocado-rest-client -%{_mandir}/man1/avocado.1.gz -%{_mandir}/man1/avocado-rest-client.1.gz -%dir %{_sharedstatedir}/avocado + + +%package -n python3-avocado-plugins-output-html +Summary: Avocado HTML report plugin +License: GPLv2+ and MIT +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-output-html +Adds to avocado the ability to generate an HTML report at every job results +directory. It also gives the user the ability to write a report on an +arbitrary filesystem location. + +%files -n python3-avocado-plugins-output-html +%{python3_sitelib}/avocado_result_html/ +%{python3_sitelib}/avocado_framework_plugin_result_html-%{version}-py%{python3_version}.egg-info + + +%if %{with_resultsdb} +%package -n python3-avocado-plugins-resultsdb +Summary: Avocado plugin to propagate job results to ResultsDB +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-resultsdb +Allows Avocado to send job results directly to a ResultsDB +server. + +%files -n python3-avocado-plugins-resultsdb +%{python3_sitelib}/avocado_resultsdb/ +%{python3_sitelib}/avocado_framework_plugin_resultsdb-%{version}-py%{python3_version}.egg-info +%endif +# with_resultsdb + + +%package -n python3-avocado-plugins-varianter-yaml-to-mux +Summary: Avocado plugin to generate variants out of yaml files +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-varianter-yaml-to-mux +Can be used to produce multiple test variants with test parameters +defined in a yaml file(s). + +%files -n python3-avocado-plugins-varianter-yaml-to-mux +%{python3_sitelib}/avocado_varianter_yaml_to_mux/ +%{python3_sitelib}/avocado_framework_plugin_varianter_yaml_to_mux-%{version}-py%{python3_version}.egg-info + + +%package -n python3-avocado-plugins-golang +Summary: Avocado plugin for execution of golang tests +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} +Requires: golang + +%description -n python3-avocado-plugins-golang +Allows Avocado to list golang tests, and if golang is installed, +also run them. + +%files -n python3-avocado-plugins-golang +%{python3_sitelib}/avocado_golang/ +%{python3_sitelib}/avocado_framework_plugin_golang-%{version}-py%{python3_version}.egg-info +%{_bindir}/avocado-runner-golang + + +%if ! 0%{?rhel} +%package -n python3-avocado-plugins-ansible +Summary: Avocado Ansible Dependency plugin +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} +Requires: ansible-core + +%description -n python3-avocado-plugins-ansible +Adds to Avocado the ability to use ansible modules as dependecies for +tests. + +%files -n python3-avocado-plugins-ansible +%{python3_sitelib}/avocado_ansible* +%{python3_sitelib}/avocado_framework_plugin_ansible* +%{_bindir}/avocado-runner-ansible-module +%endif + + +%package -n python3-avocado-plugins-varianter-pict +Summary: Varianter with combinatorial capabilities by PICT +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-varianter-pict +This plugin uses a third-party tool to provide variants created by +Pair-Wise algorithms, also known as Combinatorial Independent Testing. + +%files -n python3-avocado-plugins-varianter-pict +%{python3_sitelib}/avocado_varianter_pict/ +%{python3_sitelib}/avocado_framework_plugin_varianter_pict-%{version}-py%{python3_version}.egg-info + + +%package -n python3-avocado-plugins-varianter-cit +Summary: Varianter with Combinatorial Independent Testing capabilities +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-varianter-cit +A varianter plugin that generates variants using Combinatorial +Independent Testing (AKA Pair-Wise) algorithm developed in +collaboration with CVUT Prague. + +%files -n python3-avocado-plugins-varianter-cit +%{python3_sitelib}/avocado_varianter_cit/ +%{python3_sitelib}/avocado_framework_plugin_varianter_cit-%{version}-py%{python3_version}.egg-info + + +%package -n python3-avocado-plugins-result-upload +Summary: Avocado plugin propagate job results to a remote host +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-result-upload +This optional plugin is intended to upload the Avocado Job results to +a dedicated sever. + +%files -n python3-avocado-plugins-result-upload +%{python3_sitelib}/avocado_result_upload/ +%{python3_sitelib}/avocado_framework_plugin_result_upload-%{version}-py%{python3_version}.egg-info + +%package -n python3-avocado-plugins-result-mail +Summary: Avocado Mail Notification for Jobs +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-result-mail +The Mail result plugin enables you to receive email notifications +for job start and completion events within the Avocado testing framework. + +%files -n python3-avocado-plugins-result-mail +%{python3_sitelib}/avocado_result_mail* +%{python3_sitelib}/avocado_framework_plugin_result_mail* + +%if ! 0%{?rhel} +%package -n python3-avocado-plugins-spawner-remote +Summary: Avocado Plugin to spawn tests on a remote host +License: GPLv2+ +Requires: python3-avocado == %{version}-%{release} + +%description -n python3-avocado-plugins-spawner-remote +This optional plugin is intended to spawn tests on a remote host. + +%files -n python3-avocado-plugins-spawner-remote +%{python3_sitelib}/avocado_spawner_remote* +%{python3_sitelib}/avocado_framework_plugin_spawner_remote* +%endif + +%package -n python-avocado-examples +Summary: Avocado Test Framework Example Tests +License: GPLv2+ +# documentation does not require main package, but needs to be in lock-step if present +Conflicts: python3-avocado < %{version}-%{release}, python3-avocado > %{version}-%{release} + +%description -n python-avocado-examples +The set of example tests present in the upstream tree of the Avocado framework. +Some of them are used as functional tests of the framework, others serve as +examples of how to write tests on your own. + +%files -n python-avocado-examples +%license LICENSE %dir %{_docdir}/avocado -%{_docdir}/avocado/avocado.rst -%{_docdir}/avocado/avocado-rest-client.rst +%{_docdir}/avocado/gdb-prerun-scripts +%{_docdir}/avocado/plugins +%{_docdir}/avocado/tests +%{_docdir}/avocado/varianter_cit +%{_docdir}/avocado/varianter_pict +%{_docdir}/avocado/yaml_to_mux + + +%package -n python-avocado-bash +Summary: Avocado Test Framework Bash Utilities +License: GPLv2+ and GPLv2 +Requires: python-avocado-common == %{version}-%{release} + +%description -n python-avocado-bash +A small set of utilities to interact with Avocado from the Bourne +Again Shell code (and possibly other similar shells). + +%files -n python-avocado-bash +%license LICENSE %dir %{_libexecdir}/avocado %{_libexecdir}/avocado/avocado-bash-utils %{_libexecdir}/avocado/avocado_debug @@ -371,43 +537,216 @@ find %{buildroot}%{_docdir}/avocado -type f -name '*.py' -exec %{__chmod} -c -x %{_libexecdir}/avocado/avocado_warn -%files -n python2-%{pkgname}-plugins-output-html -%{python2_sitelib}/avocado_result_html/ -%{python2_sitelib}/avocado_framework_plugin_result_html-%{version}-py%{python2_version}.egg-info - - -%files -n python2-%{pkgname}-plugins-runner-remote -%{python2_sitelib}/avocado_runner_remote/ -%{python2_sitelib}/avocado_framework_plugin_runner_remote-%{version}-py%{python2_version}.egg-info - - -%files -n python2-%{pkgname}-plugins-runner-vm -%{python2_sitelib}/avocado_runner_vm/ -%{python2_sitelib}/avocado_framework_plugin_runner_vm-%{version}-py%{python2_version}.egg-info - - -%files -n python2-%{pkgname}-plugins-runner-docker -%{python2_sitelib}/avocado_runner_docker/ -%{python2_sitelib}/avocado_framework_plugin_runner_docker-%{version}-py%{python2_version}.egg-info - - -%files -n python2-%{pkgname}-plugins-resultsdb -%{python2_sitelib}/avocado_resultsdb/ -%{python2_sitelib}/avocado_framework_plugin_resultsdb-%{version}-py%{python2_version}.egg-info - - -%files -n python2-%{pkgname}-plugins-varianter-yaml-to-mux -%{python2_sitelib}/avocado_varianter_yaml_to_mux/ -%{python2_sitelib}/avocado_framework_plugin_varianter_yaml_to_mux-%{version}-py%{python2_version}.egg-info - - -%files -n python-%{pkgname}-examples -%dir %{_docdir}/avocado -%{_docdir}/avocado/tests -%{_docdir}/avocado/wrappers - - %changelog +* Fri Oct 10 2025 Cleber Rosa - 112.0-1 +- Sync with upstream release 112.0 +- Removed python3-elementpath build requirement +- Made the remote spawner a proper sub package +- Packaged JSON schema files +- Introduced new sub package for mail plugin +- Removed the pinning of markupsafe on Fedora 42 and later +- Packaged avocado-runner-pip +- Packaged avocado-runner-vmimage +- Provide requirements for running the functional test + nrunner.py:TaskRunStatusService.test_task_status_service_lost +- Require gcc, gdb and gdb-gdbserver for tests + +* Fri Jul 25 2025 Fedora Release Engineering - 92.3-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Tue Jun 03 2025 Python Maint - 92.3-5 +- Rebuilt for Python 3.14 + +* Mon Jan 20 2025 Miro Hrončok - 92.3-4 +- Loosen the PyYAML version requirement in python3-avocado-plugins-varianter-yaml-to-mux + +* Mon Jan 20 2025 Cleber Rosa - 92.3-3 +- convert remaining licenses to SPDX + +* Sat Jan 18 2025 Fedora Release Engineering - 92.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Mon Aug 19 2024 Cleber Rosa - 92.3-1 +- Updated to 92.3 +- Support building and running under Python 3.13 for F42 +- Removed patch from 92.1 as its present in 92.3 + +* Fri Jul 26 2024 Miroslav Suchý - 92.1-8 +- convert license to SPDX + +* Fri Jul 19 2024 Fedora Release Engineering - 92.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Fri Jun 07 2024 Python Maint - 92.1-6 +- Rebuilt for Python 3.13 + +* Mon Jan 29 2024 Fedora Release Engineering - 92.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Jan 26 2024 Fedora Release Engineering - 92.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 92.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Jul 21 2023 Fedora Release Engineering - 92.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Mon Jul 17 2023 Cleber Rosa - 92.1-1 +- Updated to 92.1 +- Support building and running under Python 3.12 for F39 + +* Wed Jun 14 2023 Python Maint - 92.0-3 +- Rebuilt for Python 3.12 + +* Fri Jan 20 2023 Fedora Release Engineering - 92.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Tue Aug 9 2022 Cleber Rosa - 92.0-1 +- Use selftests/check.py job instead of more limited selftests/run +- Included avocado-runner-sysinfo, avocado-runner-requirement-package, + avocado-runner-requirement-asset and avocado-runner-dry-run and + avocado-runner-golang executables +- Removed avocado-runner-exec executable +- Removed loader_yaml and glib plugin packages + +* Fri Jul 22 2022 Fedora Release Engineering - 82.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Tue Jun 21 2022 Python Maint - 82.0-6 +- Rebuilt for Python 3.11 + +* Fri Jan 21 2022 Fedora Release Engineering - 82.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Wed Jul 28 2021 Merlin Mathesius - 82.0-4 +- Loosen jinja2 version requirement to fix FTBFS in Rawhide + +* Fri Jul 23 2021 Fedora Release Engineering - 82.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Mar 18 2021 Merlin Mathesius - 82.0-2 +- Drop obsolete packages from BuildRequires +- Generate man page directly using 'rst2man' rather than requiring 'make' +- Adjust PATH to make sure self-tests find internal modules +- Spec file cleanup following package review. + +* Mon Sep 14 2020 Cleber Rosa - 82.0-1 +- Sync with upstream release 82.0. +- Removed python libvirt depedency as the vm runner has been removed + upstream +- Dropped configuration files to sync with upstream which made them + optional and doesn't ship them anymore +- Add on extra character to short commit to sync with upstream + +* Sat Jun 6 2020 Cleber Rosa - 80.0-1 +- Sync with upstream release 80.0. +- Dropped use of custom avocado command for tests +- Do not build deprecated runners + +* Tue May 12 2020 Cleber Rosa - 79.0-1 +- Sync with upstream release 79.0. +- Added Python's user base bin dir to the PATH environment variable + while running tests, so that avocado-runner-* scripts can be found +- Moved comment to new lines closing the conditionals, to avoid + errors from rpmlint and rpmbuild + +* Wed Apr 15 2020 Merlin Mathesius - 78.0-1 +- Sync with upstream release 78.0. + +* Tue Mar 17 2020 Merlin Mathesius - 77.0-1 +- Sync with upstream release 77.0. + +* Mon Mar 09 2020 Merlin Mathesius - 76.0-1 +- Sync with upstream release 76.0. + +* Mon Jan 20 2020 Merlin Mathesius - 75.1-1 +- Sync with upstream release 75.1. + +* Mon Dec 23 2019 Merlin Mathesius - 74.0-1 +- Sync with upstream release 74.0. + +* Wed Nov 27 2019 Merlin Mathesius - 73.0-1 +- Sync with upstream release 73.0. +- Adjustments to build for RHEL 8. + +* Wed Oct 02 2019 Merlin Mathesius - 72.0-1 +- Sync with upstream release 72.0. + +* Wed Aug 28 2019 Merlin Mathesius - 71.0-1 +- Sync with upstream release 71.0. + +* Wed Jun 26 2019 Merlin Mathesius - 70.0-1 +- Sync with upstream release 70.0. +- Drop all Python 2 support from SPEC file. + +* Wed May 22 2019 Merlin Mathesius - 69.0-4 +- pyliblzma is Python 2-only and no longer available as of F31. +- Unversioned executables should now be Python 3. + +* Mon May 20 2019 Merlin Mathesius - 69.0-3 +- Drop Python 2 support from F31 and RHEL8 onward. +- Disable components dependent upon Fiber in Fedora 31 and later, + since avocado is currently incompatible with the new Fiber API. + +* Tue Mar 19 2019 Merlin Mathesius - 69.0-2 +- python2-sphinx is no longer available or needed as of F31 + +* Wed Feb 27 2019 Merlin Mathesius - 69.0-1 +- Sync with upstream release 69.0. + +* Fri Feb 22 2019 Merlin Mathesius - 68.0-1 +- Sync with upstream release 68.0. + +* Thu Jan 31 2019 Merlin Mathesius - 67.0-1 +- Sync with upstream release 67.0. +- genisoimage, libcdio, and psmisc added as build deps so iso9660 tests run. +- Replace pystache requirement with jinja2. +- glibc-all-langpacks added as build dep for F30+ so vmimage tests run. +- python2-resultsdb_api package has been removed in F30 so + python2-avocado-plugins-resultsdb was also disabled. + +* Wed Nov 21 2018 Merlin Mathesius - 66.0-1 +- Sync with upstream release 66.0. +- python2-pycdlib package has been removed in F30 as part of + https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal + +* Thu Oct 04 2018 Merlin Mathesius - 65.0-1 +- Sync with upstream release 65.0. + +* Tue Aug 28 2018 Merlin Mathesius - 64.0-1 +- Sync with upstream release 64.0. + +* Thu Jul 26 2018 Merlin Mathesius - 63.0-2 +- Added missing python[2]-enum34 requirement. + +* Mon Jul 23 2018 Merlin Mathesius - 63.0-1 +- Sync with upstream release 63.0. (BZ#1602175) + Include upstream patches needed to build for Rawhide. + +* Wed Jun 13 2018 Merlin Mathesius - 62.0-1 +- Sync with upstream release 62.0. (BZ#1590572) +- Correct libvirt dependency for EPEL7/RHEL7 + +* Thu May 17 2018 Merlin Mathesius - 61.0-1 +- Sync with upstream release 61.0. +- Packaging updates for Python 3. +- Reorganize SPEC file. + +* Mon Apr 9 2018 Cleber Rosa - 52.1-2 +- Added Fedora CI tests + +* Tue Apr 03 2018 Merlin Mathesius - 52.1-1 +- Sync with upstream release 52.1 (LTS series). +- Correct deprecated use of unversioned python. + +* Mon Mar 26 2018 Iryna Shcherbina - 52.0-5 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Fri Feb 09 2018 Fedora Release Engineering - 52.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + * Wed Aug 09 2017 Merlin Mathesius - 52.0-3 - Fix FTBFS error by disabling selfcheck producing false failures - Update SPEC to use pkgname instead of srcname macro where appropriate diff --git a/sources b/sources index 13be916..6494afc 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (avocado-52.0.tar.gz) = 291587c90b2774e3030595cb9ae3781e1bd151c9a3d21e899a64ba1da766387b40979700f4c6b1c373156f2eda4be1857c98b08cc32c5a712c8bd4f168da04cc +SHA512 (avocado-112.0.tar.gz) = 1872eda730f5cd28f0562732464ce14b2c7731cedb298fcc4b093a04235d26cc5e3db7f92c3ae3edcd6104ad2db4fce66fa7a6148da754e4bdb8120fa12a75a3 diff --git a/test/help-usage-1/Makefile b/test/help-usage-1/Makefile deleted file mode 100644 index d71e61f..0000000 --- a/test/help-usage-1/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: all install download clean - -BUILT_FILES= - -FILES=runtest.sh Makefile - -run: $(FILES) build - ./runtest.sh - -build: $(BUILT_FILES) - chmod a+x ./runtest.sh - -clean: - rm -f *~ $(BUILT_FILES) diff --git a/test/help-usage-1/README.rst b/test/help-usage-1/README.rst deleted file mode 100644 index 1d25e34..0000000 --- a/test/help-usage-1/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -help-usage-1 -============ - -This is an example task for `Taskotron `_ -that tests the basic functionality of 'avocado --help' to confirm it generates a usage message. - -Standalone you can run it like this:: - - $ make run - -Through taskotron runner you can run it like this:: - - $ runtask -i python-avocado-46.0-2.fc25 -t koji_build -a noarch runtask.yml diff --git a/test/help-usage-1/runtask.yml b/test/help-usage-1/runtask.yml deleted file mode 100644 index 1ff3857..0000000 --- a/test/help-usage-1/runtask.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: help-usage-1 -desc: "Tests the basic functionality of 'avocado --help' to confirm it generates a usage message." -maintainer: merlinm - -input: - args: - - koji_build - - arch - -environment: - rpm: - - make - -actions: - - name: download the build - koji: - action: download - koji_build: ${koji_build} - arch: $arch - target_dir: ${workdir}/rpms - - - name: install the build - shell: - - dnf install -y ${workdir}/rpms/*.rpm - - - name: run test - shell: - - make run diff --git a/test/help-usage-1/runtest.sh b/test/help-usage-1/runtest.sh deleted file mode 100755 index b2cb24b..0000000 --- a/test/help-usage-1/runtest.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -PACKAGE=python-avocado - -# Assume the test will pass. -result=PASS - -avocado --help | grep -q -i '^usage:' -if [ $? -ne 0 ]; then - result=FAIL -fi - -echo $result diff --git a/tests/gdbtest.py b/tests/gdbtest.py new file mode 100755 index 0000000..c0cdc55 --- /dev/null +++ b/tests/gdbtest.py @@ -0,0 +1,347 @@ +import os + +from avocado import Test +from avocado.utils import gdb, genio, process + + +class GdbTest(Test): + + """ + Execute the gdb test + + :avocado: tags=requires_c_compiler + """ + + VALID_CMDS = ["-list-target-features", + "-break-info", + "-break-list", + "-thread-info", + "-stack-info-frame", + "-stack-info-depth"] + + INVALID_CMDS = ["-foobar", + "-magic8ball", + "-find-me-the-bug", + "-auto-debug-it"] + + def setUp(self): + self.return99_binary_path = os.path.join(self.teststmpdir, 'return99') + if not os.path.exists(self.return99_binary_path): + return99_source_path = self.get_data('return99.c') + if return99_source_path is None: + self.cancel('Test is missing data file "return99.c"') + process.system(f'gcc -O0 -g {return99_source_path} -o {self.return99_binary_path}') + + self.segfault_binary_path = os.path.join(self.teststmpdir, 'segfault') + if not os.path.exists(self.segfault_binary_path): + segfault_source_path = self.get_data('segfault.c') + if segfault_source_path is None: + self.cancel('Test is missing data file "segfault.c"') + process.system(f'gcc -O0 -g {segfault_source_path} -o {self.segfault_binary_path}') + + @staticmethod + def is_process_alive(process): # pylint: disable=W0621 + """ + Checks if a process is still alive + + :param process: a :class:`subprocess.POpen` instance + :type process: :class:`subprocess.POpen` + :returns: True or False + :rtype: bool + """ + return process.poll() is None + + def test_start_exit(self): + """ + Tests execution of multiple GDB instances without any blocking or race + """ + self.log.info("Testing execution of multiple GDB instances") + process_count = 10 + gdb_instances = [] + for i in range(0, process_count): + gdb_instances.append(gdb.GDB()) + + for i in range(0, process_count): + self.assertEqual(gdb_instances[i].exit(), 0) + + def test_existing_commands_raw(self): + """ + Tests the GDB response to commands that exist and to those that do not + """ + g = gdb.GDB() + self.log.info("Testing existing (valid) GDB commands using raw commands") + for cmd in self.VALID_CMDS: + info_cmd = f"-info-gdb-mi-command {cmd[1:]}" + r = g.cmd(info_cmd) + self.assertEqual(r.result.result.command.exists, 'true') + + self.log.info("Testing non-existing (invalid) GDB commands using raw " + "commands") + for cmd in self.INVALID_CMDS: + info_cmd = f"-info-gdb-mi-command {cmd[1:]}" + r = g.cmd(info_cmd) + self.assertEqual(r.result.result.command.exists, 'false') + + def test_existing_commands(self): + g = gdb.GDB() + + self.log.info("Testing existing (valid) GDB commands using utility " + "methods") + for cmd in self.VALID_CMDS: + self.assertTrue(g.cmd_exists(cmd)) + g.cmd(cmd) + + self.log.info("Testing non-existing (invalid) GDB commands using " + "utility methods") + for cmd in self.INVALID_CMDS: + self.assertFalse(g.cmd_exists(cmd)) + + def test_load_set_breakpoint_run_exit_raw(self): + """ + Test a common GDB cycle using raw commands: load, set break, run, exit + """ + self.log.info("Testing that GDB loads a file and sets a breakpoint") + g = gdb.GDB() + + file_cmd = f"-file-exec-and-symbols {self.return99_binary_path}" + r = g.cmd(file_cmd) + self.assertEqual(r.result.class_, 'done') + + break_cmd = "-break-insert 5" + r = g.cmd(break_cmd) + self.assertEqual(r.result.class_, 'done') + self.assertEqual(r.result.result.bkpt.number, '1') + self.assertEqual(r.result.result.bkpt.enabled, 'y') + + break_del_cmd = "-break-delete 1" + r = g.cmd(break_del_cmd) + self.assertEqual(r.result.class_, 'done') + + run_cmd = "-exec-run" + r = g.cmd(run_cmd) + self.assertEqual(r.result.class_, 'running') + + g.cmd("-gdb-exit") + self.assertEqual(g.process.wait(), 0) + + def test_load_set_breakpoint_run_exit(self): + """ + Test a common GDB cycle: load, set break, delete break, run, exit + """ + self.log.info("Testing a common GDB cycle") + g = gdb.GDB() + g.set_file(self.return99_binary_path) + g.set_break("5") + g.del_break(1) + g.run() + g.exit() + + def test_generate_core(self): + """ + Load a file that will cause a segfault and produce a core dump + """ + self.log.info("Testing that a core dump will be generated") + + g = gdb.GDB() + file_cmd = f"-file-exec-and-symbols {self.segfault_binary_path}" + r = g.cmd(file_cmd) + self.assertEqual(r.result.class_, 'done') + + run_cmd = "-exec-run" + r = g.cmd(run_cmd) + self.assertEqual(r.result.class_, 'running') + + other_messages = g.read_until_break() + core_path = None + for msg in other_messages: + parsed_msg = gdb.parse_mi(msg.decode()) + if (hasattr(parsed_msg, 'class_') and + (parsed_msg.class_ == 'stopped') and + (parsed_msg.result.signal_name == 'SIGSEGV')): + core_path = f"{self.segfault_binary_path}.core" + gcore_cmd = f'gcore {core_path}' + gcore_cmd = gdb.encode_mi_cli(gcore_cmd) + r = g.cmd(gcore_cmd) + self.assertEqual(r.result.class_, 'done') + + self.assertTrue(os.path.exists(core_path)) + g.exit() + + def test_set_multiple_break(self): + """ + Tests that multiple breakpoints do not interfere with each other + """ + self.log.info("Testing setting multiple breakpoints") + g = gdb.GDB() + g.set_file(self.return99_binary_path) + g.set_break('empty') + g.set_break('7') + g.exit() + + def test_disconnect_raw(self): + """ + Connect/disconnect repeatedly from a remote debugger using raw commands + """ + self.log.info("Testing connecting and disconnecting repeatedly using " + "raw commands") + s = gdb.GDBServer() + g = gdb.GDB() + + # Do 100 cycle of target (kind of connects) and disconnects + for _ in range(0, 100): + cmd = f'-target-select extended-remote :{s.port}' + r = g.cmd(cmd) + self.assertEqual(r.result.class_, 'connected') + r = g.cmd('-target-disconnect') + self.assertEqual(r.result.class_, 'done') + + # manual server shutdown + cmd = f'-target-select extended-remote :{s.port}' + r = g.cmd(cmd) + self.assertEqual(r.result.class_, 'connected') + r = g.cli_cmd('monitor exit') + self.assertEqual(r.result.class_, 'done') + + g.exit() + s.exit() + + def test_disconnect(self): + """ + Connect/disconnect repeatedly from a remote debugger using utilities + """ + self.log.info("Testing connecting and disconnecting repeatedly") + s = gdb.GDBServer() + g = gdb.GDB() + + for _ in range(0, 100): + r = g.connect(s.port) + self.assertEqual(r.result.class_, 'connected') + r = g.disconnect() + self.assertEqual(r.result.class_, 'done') + + g.exit() + s.exit() + + def test_remote_exec(self): + """ + Tests execution on a remote target + """ + self.log.info("Testing execution on a remote target") + hit_breakpoint = False + + s = gdb.GDBServer() + g = gdb.GDB() + + cmd = f'-file-exec-and-symbols {self.return99_binary_path}' + r = g.cmd(cmd) + self.assertEqual(r.result.class_, 'done') + + cmd = f'set remote exec-file {self.return99_binary_path}' + r = g.cmd(cmd) + self.assertEqual(r.result.class_, 'done') + + cmd = f"-break-insert {'main'}" + r = g.cmd(cmd) + self.assertEqual(r.result.class_, 'done') + + r = g.cmd('-exec-run') + + other_messages = g.read_until_break() + for msg in other_messages: + parsed_msg = gdb.parse_mi(msg.decode()) + if (hasattr(parsed_msg, 'class_') and + parsed_msg.class_ == 'stopped' and + parsed_msg.result.reason == 'breakpoint-hit'): + hit_breakpoint = True + + self.assertTrue(hit_breakpoint) + g.exit() + s.exit() + + def test_stream_messages(self): + """ + Tests if the expected response appears in the result stream messages + """ + self.log.info("Testing that messages appears in the result stream") + g = gdb.GDB() + r = g.cmd("-gdb-version") + self.assertIn("GNU GPL version", r.get_stream_messages_text()) + + def test_connect_multiple_clients(self): + """ + Tests two or more connections to the same server raise an exception + """ + self.log.info("Testing that multiple clients cannot connect at once") + s = gdb.GDBServer() + c1 = gdb.GDB() + c1.connect(s.port) + c2 = gdb.GDB() + with self.assertRaises(gdb.UnexpectedResponseError): + c2.connect(s.port) + s.exit() + + def test_server_exit(self): + """ + Tests that the server is shutdown by using a monitor exit command + """ + self.log.info("Testing that a single server exits cleanly") + s = gdb.GDBServer() + s.exit() + self.assertFalse(self.is_process_alive(s.process)) + + def test_multiple_servers(self): + """ + Tests multiple server instances without any blocking or race condition + """ + self.log.info("Testing execution of multiple GDB server instances") + process_count = 10 + server_instances = [] + for i in range(0, process_count): + s = gdb.GDBServer() + c = gdb.GDB() + c.connect(s.port) + c.cmd('show-version') + c.disconnect() + server_instances.append(s) + + for i in range(0, process_count): + self.assertTrue(self.is_process_alive(server_instances[i].process)) + server_instances[i].exit() + self.assertFalse(self.is_process_alive(server_instances[i].process)) + + def test_server_stderr(self): + self.log.info('Testing server stderr collection') + s = gdb.GDBServer() + s.exit() + self.assertTrue(os.path.exists(s.stderr_path)) + + stderr_lines = genio.read_all_lines(s.stderr_path) + listening_line = f"Listening on port {s.port}" + self.assertIn(listening_line, stderr_lines) + + def test_server_stdout(self): + self.log.info('Testing server stdout/stderr collection') + s = gdb.GDBServer() + c = gdb.GDB() + c.connect(s.port) + c.set_file(self.return99_binary_path) + c.run() + s.exit() + + self.assertTrue(os.path.exists(s.stdout_path)) + self.assertTrue(os.path.exists(s.stderr_path)) + + stdout_lines = genio.read_all_lines(s.stdout_path) + self.assertIn("return 99", stdout_lines) + + @staticmethod + def test_remote(): + """ + Tests GDBRemote interaction with a GDBServer + """ + s = gdb.GDBServer() + r = gdb.GDBRemote('127.0.0.1', s.port) + r.connect() + r.cmd(b"qSupported") + r.cmd(b"qfThreadInfo") + s.exit() diff --git a/tests/gdbtest.py.data/return99.c b/tests/gdbtest.py.data/return99.c new file mode 100644 index 0000000..bf14935 --- /dev/null +++ b/tests/gdbtest.py.data/return99.c @@ -0,0 +1,47 @@ +#include +#include + +void empty() +{ +} + +void write_stdout() +{ + fprintf(stdout, "testing output to stdout\n"); +} + +void write_stderr() +{ + fprintf(stderr, "testing output to stderr\n"); +} + +int forkme() +{ + int pid; + + pid = fork(); + if (pid != 0) + pid = fork(); + if (pid != 0) + pid = fork(); + + return pid; +} + +int main(int argc, char *argv[]) +{ + int exit_status = 99; + + if (argc > 1) + exit_status = atoi(argv[1]); + + empty(); + write_stdout(); + write_stderr(); + + if (forkme()) { + fprintf(stdout, "return %i\n", exit_status); + } + + return exit_status; +} diff --git a/tests/gdbtest.py.data/segfault.c b/tests/gdbtest.py.data/segfault.c new file mode 100644 index 0000000..a685f86 --- /dev/null +++ b/tests/gdbtest.py.data/segfault.c @@ -0,0 +1,9 @@ +#include + +int main() +{ + int *p = NULL; + *p = 0xdead; + + return 0; +} diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..be4a031 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,29 @@ +- hosts: localhost + roles: + - role: standard-test-avocado + tests: + - gdbtest.py:GdbTest.test_start_exit + - gdbtest.py:GdbTest.test_existing_commands + - gdbtest.py:GdbTest.test_existing_commands_raw + - gdbtest.py:GdbTest.test_load_set_breakpoint_run_exit_raw + - gdbtest.py:GdbTest.test_load_set_breakpoint_run_exit + - gdbtest.py:GdbTest.test_generate_core + - gdbtest.py:GdbTest.test_set_multiple_break + - gdbtest.py:GdbTest.test_disconnect_raw + - gdbtest.py:GdbTest.test_disconnect + - gdbtest.py:GdbTest.test_remote_exec + - gdbtest.py:GdbTest.test_stream_messages + - gdbtest.py:GdbTest.test_connect_multiple_clients + - gdbtest.py:GdbTest.test_server_exit + - gdbtest.py:GdbTest.test_server_stdout + - gdbtest.py:GdbTest.test_server_stderr + - gdbtest.py:GdbTest.test_multiple_servers + - gdbtest.py:GdbTest.test_interactive + - gdbtest.py:GdbTest.test_interactive_args + - gdbtest.py:GdbTest.test_exit_status + - gdbtest.py:GdbTest.test_interactive_stdout + - gdbtest.py:GdbTest.test_remote + required_packages: + - gcc + - gdb + - gdb-gdbserver