aboutsummaryrefslogtreecommitdiff
path: root/tests/atf_python
Commit message (Collapse)AuthorAgeFilesLines
* pf: test rules evaluation in the face of multiple IPv6 fragment headersKristof Provost2023-08-041-0/+21
| | | | | | | | | | | | | | | Send an ICMPv6 echo request packet with multiple IPv6 fragment headers. Set rules to pass all packets, except for ICMPv6 echo requests. pf ought to drop the echo request, but doesn't because it reassembles the packet, and then doesn't handle the second fragment header. In other words: it fails to detect the ICMPv6 echo header. Reported by: Enrico Bassetti bassetti@di.uniroma1.it (NetSecurityLab @ Sapienza University of Rome) MFC after: instant Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit b23dbabb7f3edb3f323a64f03e37be2c9a8b2a45)
* tests: fix python parsing of netlink nested attributesAlexander V. Chernikov2023-04-081-2/+3
| | | | | | MFC after: 2 weeks (cherry picked from commit 90bc2120b51bc5ac9fbcb29763cc47562ee49977)
* tests: add more netlink tests for neighbors/routesAlexander V. Chernikov2023-04-081-15/+106
| | | | | | | Differential Revision: https://reviews.freebsd.org/D38912 MFC after: 2 weeks (cherry picked from commit c57dfd92c876fabc04e94945dd9534468520bbbf)
* tests: add netlink large dump buffer checkAlexander V. Chernikov2023-04-081-9/+11
| | | | | | | Differential Revision: https://reviews.freebsd.org/D38665 MFC after: 2 weeks (cherry picked from commit 828d3c6c4cc0b782e16abb1ae18023734a0b710f)
* netlink: improve attribute decoding in python testsAlexander V. Chernikov2023-04-081-39/+92
| | | | | | MFC after: 2 weeks (cherry picked from commit ff8da9b2bab43920a19c16855ac3d30b5ccb1df2)
* testing: handling non-root users with VNETs in pytest-based tests.Alexander V. Chernikov2023-02-243-6/+74
| | | | | | | | | | | | | | | | | | Currently isolation and resource requirements are handled directly by the kyua runner, based on the requirements specified by the test. It works well for simple tests, but may cause discrepancy with tests doing complex pre-setups. For example, all tests that perform VNET setups require root access to properly function. This change adds additional handling of the "require_user" property within the python testing framework. Specifically, it requests root access if the test class signals its root requirements and drops privileges to the desired user after performing the pre-setup. Differential Revision: https://reviews.freebsd.org/D37923 MFC after: 2 weeks (cherry picked from commit 6332ef8941999b0c074d1ece0e1e108447c70b98)
* netlink: return optional metadata with the operation result.Alexander V. Chernikov2023-02-201-60/+74
| | | | | | | | | | | | | | | | | Some operations like interface creation may need to return metadata - in this case, interface name - back to the caller if the operation is successful. This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the operation reply message via `nlmsg_report_cookie()`. Additionally, on successful interface creation, interface index and interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`. Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D38283 MFC after: 1 week (cherry picked from commit 25c2dd2f2c6c6144d59d463c95f0471301d6efaa)
* pytest: delete interfaces from inside the jail.Alexander V. Chernikov2023-02-091-9/+37
| | | | | | | | | This change follows the approach used in 80fc25025ffc, to minimise the impact of the delayed interface migration. MFC after: 2 weeks (cherry picked from commit 20ea7f26e41375828a390fba613b86acfe366add)
* tests: Add an IPv4 loopback address of 127.0.0.1/8 to the lo0Jose Luis Duran2023-02-091-0/+1
| | | | | | | | | interface by default when creating VNETSs using pytest. Reviewed By: asomers Differential Revision: https://reviews.freebsd.org/D38021 (cherry picked from commit 4856aeaaed17726a1dfa5dd6c736e5b0851255b6)
* netlink: improve RTM_GETADDR handling.Alexander V. Chernikov2023-01-231-15/+87
| | | | | | | | | | | | | * Allow filtering by ifa_family & ifa_index. * Add common RTM_<NEW|DEL|GET>ADDR parser * Add tests verifying RTM_GETADDR filtering behaviour & output * Factor out common netlink socket test methods into NetlinkTestTemplate * Add NLMSG_DONE message handler Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D37970 (cherry picked from commit c1871a3372e382bfcd46452d1d8d4f06561508cc)
* testing: fix tests without cleanup in pytest.Alexander V. Chernikov2023-01-231-4/+0
| | | | | | | | It was broken by 89ffac3b01fb3f6749799ac67b7d94056a36778e, which added "cleanup" method to the base test class, resulting in reporting cleanup for all of the tests. (cherry picked from commit bb60d265c9825d71cce84a42f66a435f05a6c5f7)
* testing: allow custom test cleanup handlers in pytestAlexander V. Chernikov2023-01-231-8/+23
| | | | | | | | | | | | | | | In order to provide more flexibility for the test writers, add per-test-method cleanups in addition to the per-class cleanups. Now the test 'test_one' can perform cleanup by either defining per-class 'cleanup' method (typically used in VNET classes) and per-test method 'cleanup_test_one'. The latter has preference. In order to handle paramatrization, testid is passed as a single argument to both of the methods. MFC after: 2 weeks (cherry picked from commit 89ffac3b01fb3f6749799ac67b7d94056a36778e)
* testing: improve python vnet wrapper.Alexander V. Chernikov2023-01-232-37/+67
| | | | | | | | | | | | | | | | | | * Derive jail name from class name and method name, instead of just method name. This change reduces the chances of different tests clashing. Old: 'jail_test_one'. New: 'pytest:TestExampleSimplest:test_one' * Simplify vnetX_handler() method signature by skipping obj_map (unused) and pipe. The latter can be accessed as the vnet property. * Add `send_object()` method as a pair to the `wait_object` inside the VnetTestTemplate class. * Add `test_id` property to the BaseTest method. Previously it was provided only for the VnetTestTemplate class. This change makes the identifier easily accessible for all users. MFC after: 2 weeks (cherry picked from commit f63825ff21a3bee2630ea8b0ed27a4583cc4242b)
* netlink: connect netlink tests to the buildAlexander V. Chernikov2023-01-234-21/+54
| | | | | | | Reviewed By: ngie Differential Revision: https://reviews.freebsd.org/D37708 (cherry picked from commit 3873bdc2f28f6aab6b426ccb6c85ab2a41483264)
* netlink: improve interface handlingAlexander V. Chernikov2023-01-232-1/+1496
| | | | | | | | | | | | | | | | | | * Separate interface creation from interface modification code * Support setting some interface attributes (ifdescr, mtu, up/down, promisc) * Improve interaction with the cloners requiring to parse/write custom interface attributes * Add bitmask-based way of checking if the attribute is present in the message * Don't use multipart RTM_GETLINK replies when searching for the specific interface names * Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search * Add python netlink test helpers * Add some netlink interface tests Differential Revision: https://reviews.freebsd.org/D37668 (cherry picked from commit 80f03e63d67ede8fedbed4bd6bf6b12ec2ab2cfb)
* tests: add routing tests for switching between same prefixesAlexander V. Chernikov2023-01-132-3/+20
| | | | | | | Differential Revision: https://reviews.freebsd.org/D36055 MFC after: 2 weeks (cherry picked from commit 7064c94a02af2f8665636a8594557b9e93ad71bf)
* testing: add ability to specify multi-vnet topologies in the pytest framework.Alexander V. Chernikov2023-01-132-100/+397
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notable amount of tests related to the packet IO require two VNET jails for proper testing and avoiding side effects for the host system. Additionally, it is often required to run actions in the jails seme-sequentially - waiting for the listener initialisation can be an example of such dependency. This change extends pytest vnet framework to allow defining multi-vnet multi-epair topologies in declarative style, without any need to bother about jail or repair names. All jail creation/teardown, interface creation/teardown and address assignments are handled automatically. Example: TOPOLOGY = { "vnet1": {"ifaces": ["if1", "if2", "if3"]}, "vnet2": {"ifaces": ["if1", "if2", "if3"]}, "if1": {"prefixes6": [("2001:db8:a::1/64", "2001:db8:a::2/64")]}, "if2": {"prefixes6": [("2001:db8:b::1/64", "2001:db8:b::2/64")]}, "if3": {"prefixes6": [("2001:db8:c::1/64", "2001:db8:c::2/64")]}, } def vnet2_handler(self, vnet, obj_map, pipe): ss = VerboseSocketServer("::", self.DEFAULT_PORT) pipe.send("READY") def test_output6_base(self): self.wait_object(second_vnet.pipe) The definitions above will create 2 vnets ("jail_test_output6_base", "jail_test_output6_base_2"), 3 epairs, attached to both first and second jails, set up the IP addresses for each epair, spawn another process for vnet2_handler and pass control to vnet2_handler and test_output6_base. Both processes can pass objects between each other using pre-created pipes. Differential Revision: https://reviews.freebsd.org/D35708 (cherry picked from commit cfc9cf9baf474618daad9f5d5f7c74e66acafbd3)
* testing: pass ATF vars to pytest via env instead of arguments.Alexander V. Chernikov2023-01-131-0/+6
| | | | | | | | | | | | | | | | This change is a continuation of 9c42645a1e4d workaround. Apparently pytest argument parser is not happy when parsing values with spaces or just more than one --atf-var argument. Switch wrapper to send these kv pairs as env variables. Specifically, use _ATF_VAR_key=value format to distinguish from the other vars. Add the `atf_vars` fixture returning all passed kv pairs as a dict. Reviewed by: lwhsu Differential Revision: https://reviews.freebsd.org/D35625 MFC after: 2 weeks (cherry picked from commit 513ce835b55831d343185e03a51efa2901405ac8)
* testing: Add basic atf support to pytest.Alexander V. Chernikov2023-01-1310-0/+1095
Implementation consists of the pytest plugin implementing ATF format and a simple C++ wrapper, which reorders the provided arguments from ATF format to the format understandable by pytest. Each test has this wrapper specified after the shebang. When kyua executes the test, wrapper calls pytest, which loads atf plugin, does the work and returns the result. Additionally, a separate python "package", `/usr/tests/atf_python` has been added to collect code that may be useful across different tests. Current limitations: * Opaque metadata passing via X-Name properties. Require some fixtures to write * `-s srcdir` parameter passed by the runner is ignored. * No `atf-c-api(3)` or similar - relying on pytest framework & existing python libraries * No support for `atf_tc_<get|has>_config_var()` & `atf_tc_set_md_var()`. Can be probably implemented with env variables & autoload fixtures Differential Revision: https://reviews.freebsd.org/D31084 Reviewed by: kp, ngie (cherry picked from commit 8eb2bee6c0f4957c6c1cea826e59cda4d18a2a64)