aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* wg tests: Add a simple regression test case for netmap supportMark Johnston2024-04-202-1/+97
| | | | | | MFC after: 1 month Sponsored by: Klara, Inc. Sponsored by: Zenarmor
* tests: move atf_python/sys/ into the tests packageLexi Winter2024-04-195-0/+5
| | | | | | Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1174
* Add preliminary in-tree CI infrastructure for developersMuhammad Moinur Rahman2024-04-189-0/+568
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this project is to integrate the relevant scripts from the FreeBSD-CI project (https://github.com/freebsd/freebsd-ci) into the src repository. This allows developers to run the test suite similar to how it is executed on ci.freebsd.org, and eventually, have it directly used by our CI system. This effort is also part of the workflow improvement project, aiming to incorporate pre-merge testing. Current Features: * Does smoke tests using either bhyve(amd64 only) or qemu(Non x86_64 or when defined USE_QEMU=1). Currently defined CITYPE=smoke. Once we have added full tests we can also utilize something like CITYPE=full * Most of the resources are dynamically allocated based on available resources in the host * If CPU supports POPCNT or vmm can be loaded then bhyve is used for amd64 otherwise automatically installs and uses qemu@nox11 * When required third party applications or packages for booting non-x86 images are automatically installed Current Limitation: * Does not support full tests like the one in our Jenkins * At this moment this is also not suitable to be used in our Jenkins platform as the jobs are divided in multiple smaller tasks and artifacts are moved here and there which are not exactly the scenario for individual developers. Future Works: * Add full tests like the one in ci.freebsd.org * Add different tests or options to disable some tests * Add test profiles full * Possibly add test through Cloud Providers like AWS/GCP/Azure or Cirrus or Github Actions * Update documentation Test Plan: cd /usr/src/tests/ci make ci make TARGET=amd64 TARGET_ARCH=amd64 ci make TARGET=amd64 TARGET_ARCH=amd64 USE_QEMU=1 ci make TARGET=arm64 TARGET_ARCH=aarch64 ci make TARGET=powerpc TARGET_ARCH=powerpc64 ci make TARGET=powerpc TARGET_ARCH=powerpc64le ci make TARGET=riscv TARGET_ARCH=riscv64 ci Reviewed by: lwhsu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43786
* tests/unix_stream: test that send(2) of zero bytes is successfulGleb Smirnoff2024-04-142-7/+27
| | | | | | | | | Put this simple test into an existing file. We don't have a designated file for all unix/stream tests. There is extensive unix_seqpacket_test, but (at least right now) unix/seqpacket is not a superset of unix/stream, but a different implementation. We have one file that does one test for unix/stream - unix_socketpair_test. So rename it to unix_stream and start collecting all unix/stream tests in it.
* tests: Add ktrace regression test for shm_openJake Freeland2024-04-101-0/+34
| | | | | | | | | | | Verify that a capability violation is recorded when shm_open(2) is called with a non-anonymous path. Approved by: markj (mentor) Reviewed by: markj MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44733
* tests/unix_seqpacket: remove workaround for a kernel bug that is no longerGleb Smirnoff2024-04-081-6/+1
|
* tests/unix_seqpacket: test send(2) to a closed or aborted peer socketGleb Smirnoff2024-04-081-0/+48
| | | | | | | | | | In both cases the kernel returns EPIPE and delivers SIGPIPE, unless blocked or disabled. The test isn't specific to SOCK_SEQPACKET, it is the same for SOCK_STREAM. Put the test into this file, since it has all primitives to write this test tersely. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D44146
* tests/unix_seqpacket: provide random data pumping test with MSG_EORGleb Smirnoff2024-04-081-0/+151
| | | | | | | | | | | Allocate a big chunk of randomly initialized memory. Send it to the peer in random sized chunks, throwing MSG_EOR at randomly initialized offsets. Receive into random sized chunks setting MSG_WAITALL randomly. Check that MSG_EORs where they should be, check that MSG_WAITALL is abode, but overriden by MSG_EOR. And finally memcmp() what we receive. Reviewed by: asomers, tuexen Differential Revision: https://reviews.freebsd.org/D43775
* tests: Add ktrace capability violation test casesJake Freeland2024-04-072-0/+490
| | | | | | | | | | | | | | | | | | | | | | | | | Introduce regression tests for ktrace(2) that target capability violations. These test cases ensure that ktrace(2) records these violations: - CAPFAIL_NOTCAPABLE - CAPFAIL_INCREASE - CAPFAIL_SYSCALL - CAPFAIL_SIGNAL - CAPFAIL_PROTO - CAPFAIL_SOCKADDR - CAPFAIL_NAMEI - CAPFAIL_CPUSET A portion of these test cases create processes that do NOT enter capability mode, but raise violations. This is intended behavior. Users may run `ktrace -t p` on non-Capsicumized programs to detect violations that would occur if the process were in capability mode. Reviewed by: markj Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D40682
* tarfs: Ignore global extended headers.Dag-Erling Smørgrav2024-04-031-0/+24
| | | | | | | | | | | | | | Previously, we would error out if we encountered a global extended header, because we don't know what it means. This doesn't really matter though, and traditionally, tar implementations have either ignored them or treated them as plain files, so just ignore them. This allows tarfs to mount tar files created by `git archive`. MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44600
* tarfs: Support paths that spill into exthdrs.Dag-Erling Smørgrav2024-04-031-0/+50
| | | | | | | | MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44599
* ptrace tests: Fix a signed/unsigned integer comparisonMark Johnston2024-04-011-1/+1
| | | | | Reported by: Jenkins Fixes: 43b4da44118e ("ptrace tests: Add a test using PROC_REAP_KILL to kill a traced debuggee")
* ptrace tests: Add a test using PROC_REAP_KILL to kill a traced debuggeeMark Johnston2024-03-311-0/+47
| | | | | | | | | This exercises the bug fix in commit 9241ebc796c1 ("thread_single(9): decline external requests for traced or debugger-stopped procs"). Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44564
* pf: fix reply-to after rdr and dummynetKristof Provost2024-03-281-0/+61
| | | | | | | | | | | | | | If we redirect a packet to localhost and it gets dummynet'd it may be re-injected later (e.g. when delayed) which means it will be passed through ip_input() again. ip_input() will then reject the packet because it's directed to the loopback address, but did not arrive on a loopback interface. Fix this by having pf set the rcvif to V_iflo if we redirect to loopback. See also: https://redmine.pfsense.org/issues/15363 Sponsored by: Rubicon Communications, LLC ("Netgate")
* netpfil tests: disable ICMPv6 rate limiting in the test jailGleb Smirnoff2024-03-251-0/+1
| | | | | | | The dummynet test uses flood ping as source of traffic, so the rate limiting of ICMP replies broke the test. Fixes: 32aeee8ce7e72738fff236ccd5629d55035458f8
* tests/netinet: fix UDP I/O test buildGleb Smirnoff2024-03-231-2/+2
| | | | Fixes: 8d3d9ca8bd3db284f6ae671f1e816ba2822f0988
* tests/netgraph: start ng_ksocket(4) testsGleb Smirnoff2024-03-232-0/+116
| | | | | | The ng_ksocket(4) functionality is very fragile as it interfaces with kernel socket code in unusual way. It definitely needs a test suite. Start one with a test that tests UDP over IPv4.
* tests/netinet: add UDP socket I/O testsGleb Smirnoff2024-03-232-1/+141
| | | | | | | | Start a file that would collect tests for I/O functionality of a UDP socket, targeted on how a socket interacts with userland rather than with wire side of the protocol. First version tests that MSG_TRUNC and MSG_PEEK are working correctly.
* tests/netgraph: mark all tests as required_user="root"Gleb Smirnoff2024-03-231-1/+1
| | | | | | | | Any netgraph operation requires root priveleges. Some tests in the directory already mark themselves with 'atf_tc_set_md_var(conf, "require.user", "root");' which creates a lot of pasted code. Some tests don't mark self. For this particular directory a blanket metadata setting in the Makefile is acceptable, imho.
* if_ovpn tests: test large packets in IPv6 tunnelKristof Provost2024-03-221-0/+18
| | | | | | | | | | There's a report of MTU issues over IPv6 DCO tunnels. Extend the 4in6 test to send a series of pings with different sizes, as well as transfer a large file. No issues were found, but we may as well extend the test case. PR: 276838
* pf: convert DIOCSETSTATUSIF to netlinkKristof Provost2024-03-192-0/+88
| | | | | | | While here also add a basic test case for it. Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44368
* pf: fix dummynet + route-toKristof Provost2024-03-191-2/+63
| | | | | | | | | | | | | Ensure that we pick the correct dummynet pipe (i.e. forward vs. reverse direction) when applying route-to. We mark the processing as outbound so that dummynet will re-inject in the correct phase of processing after it's done with the packet, but that will cause us to pick the wrong pipe number. Reverse them so that the incorrect decision ends up picking the correct pipe. Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44366
* pf: avoid passing through dummynet multiple timesKristof Provost2024-03-191-0/+53
| | | | | | | | | | | | In some setups we end up with multiple states created for a single packet, which in turn can mean we run the packet through dummynet multiple times. That's not expected or intended. Mark each packet when it goes through dummynet, and do not pass packet through dummynet if they're marked as having already passed through. See also: https://redmine.pfsense.org/issues/14854 Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44365
* tests/unix_seqpacket: mk_pair_of_sockets() requires a valid argumentGleb Smirnoff2024-03-111-4/+2
| | | | | | | | All callers do it right. Don't be overprotective against a stupid caller and thus don't look like a code that leaks a resource. Reported by: Coverity Scan CID: 1539210
* tarfs: Factor out common test code.Dag-Erling Smørgrav2024-03-061-26/+26
| | | | | | | | MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44227
* tarfs: Fix checksum calculation.Dag-Erling Smørgrav2024-03-061-0/+22
| | | | | | | | | | | | | | The checksum code assumed that struct ustar_header filled an entire block and calculcated the checksum based on the size of the structure. The header is in fact only 500 bytes long while the checksum covers the entire block (“logical record” in POSIX terms). Add padding and an assertion, and clean up the checksum code. MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44226
* tarfs: Fix two input validation issues.Dag-Erling Smørgrav2024-03-063-2/+196
| | | | | | | | | | | | | | | | | | | | | | | * Reject hard or soft links with an empty target path. Currently, a debugging kernel will hit an assertion in tarfs_lookup_path() while a non-debugging kernel will happily create a link to the mount root. * Use a temporary variable to store the result of the link target path, and copy it to tnp->other only once we have found it to be valid. Otherwise we error out after creating a reference to the target but before incrementing the target's reference count, which results in a use-after-free situation in the cleanup code. * Correctly return ENOENT from tarfs_lookup_path() if the requested path was not found and create_dirs is false. Luckily, existing callers did not rely solely on the return value. MFC after: 3 days PR: 277360 Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: sjg Differential Revision: https://reviews.freebsd.org/D44161
* pf tests: IPv6 versions of the route-to/reply-to if-bound testsKristof Provost2024-03-011-0/+106
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* pf: support if-bound with reply-toKristof Provost2024-03-011-0/+56
| | | | | | | | | On reply-to we don't know what interface to bind to when we create the state. Create any reply-to state as floating, but bind to the appropriate interface once we're handling the reply. See also: https://redmine.pfsense.org/issues/15220 Sponsored by: Rubicon Communications, LLC ("Netgate")
* tests/unix_seqpacket: test that implied connect doesn't workGleb Smirnoff2024-02-281-0/+18
| | | | | | | | Applies both to SOCK_STREAM and SOCK_SEQPACKET. Put the test in this file as it is most advanced one. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D43854
* tests/unix_seqpacket: test that data can be sent before accept(2)Gleb Smirnoff2024-02-281-0/+27
| | | | | | | | | This is undocumented feature of PF_UNIX/SOCK_STREAM and thus of PF_UNIX/SOCK_SEQPACKET, too. Put the test into this file, since this file is most advanced and has all primitives to write this test in minimum number of lines. Differential Revision: https://reviews.freebsd.org/D43853
* tests/unix_seqpacket: provide function that returns bound & listening sockGleb Smirnoff2024-02-281-79/+52
| | | | | | | | | | | | Use the function in mk_pair_of_sockets(), and in four existing tests - 'listen_bound', 'connect', 'shutdown_send' and 'shutdown_send_sigpipe'. While here make mk_pair_of_sockets() return pointer to sockaddr_un instead of path. This also fixes bug of returning pointer to stack memory of returning function. However, the only caller that cares about this return is temporarily ifdefed out. No functional change intended. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D43852
* tests/unix_seqpacket: remove EMSGSIZE testsGleb Smirnoff2024-02-281-61/+0
| | | | | | | | | | | | | | | | | | | | | | | | These tests were not testing conformance to the specification, rather than the limitation of our implementation. The specification doesn't say that a SOCK_SEQPACKET shall ever return EMSGSIZE. It says: The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type, and is also connection-oriented. The only difference between these types is that record boundaries are maintained using the SOCK_SEQPACKET type. A record can be sent using one or more output operations and received using one or more input operations, but a single operation never transfers parts of more than one record. Record boundaries are visible to the receiver via the MSG_EOR flag in the received message flags returned by the recvmsg() function. It is protocol-specific whether a maximum record size is imposed. The EMSGSIZE is specified as 'message is too large to be sent all at once, as the socket requires'. Indeed existing implementation that has unix/seqpacket marked as PR_ATOMIC has such a limitation. But future implementation won't have, thus remove the tests. Reviewed by: tuexen, asomers Differential Revision: https://reviews.freebsd.org/D43756
* socket tests: remove MSG_TRUNC test for unix/seqpacketGleb Smirnoff2024-02-281-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The PF_UNIX/SOCK_SEQPACKET was marked as PR_ATOMIC and that made soreceive_generic() to treat it pretty much as a datagram socket. However, POSIX says: The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type, and is also connection-oriented. The only difference between these types is that record boundaries are maintained using the SOCK_SEQPACKET type. A record can be sent using one or more output operations and received using one or more input operations, but a single operation never transfers parts of more than one record. Record boundaries are visible to the receiver via the MSG_EOR flag in the received message flags returned by the recvmsg() function. It is protocol-specific whether a maximum record size is imposed. What the test was doing is checking if MSG_TRUNC would report the space required to return up the end of next mbuf record in the socket buffer. Apparently the test assumed that this boundary is defined by the write(2) size on the peer socket. This was true in test conditions, but I'm not sure it would always be true - sbcompress() may merge mbufs. Anyway, the mbuf boundaries are internal socket buffer implementation, they are not SOCK_SEQPACKET records. The records need to be explicitly marked with MSG_EOR by sender, and the test definitely wasn't doing that. Reviewed by: tuexen, markj Differential Revision: https://reviews.freebsd.org/D43707
* pf: fix packet-to-big for route-to as wellKristof Provost2024-02-271-8/+39
| | | | | | | | | | | | | | | When we handle a packet via route-to (i.e. pf_route6()) we still need to verify the MTU. However, we only run that check in the forwarding case. Set the PFIL_FWD tag when running the pf_test6(PF_OUT) check from pf_route6(). We are in fact forwarding, so should call the test function as such. This will cause us to run the MTU check, and generate an ICMP6 packet-too-big error when required. See also: 54c62e3e5d8cd90c5571a1d4c8c5f062d580480e See also: f1c0030bb05cfa01bdd500e50befbb425fecc4c4 See also: https://redmine.pfsense.org/issues/14290 Sponsored by: Rubicon Communications, LLC ("Netgate")
* sigsys test: correct count of delivered signalsKonstantin Belousov2024-02-251-4/+4
| | | | | | | | | | | When knob is zero, intent is that no SIGSYS signals are delivered. Comparing zero to zero does not test much, we should compare the count of delivered SIGSYSs to zero. Reviewed by: dchagin, imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44077
* tests/fdgrowtable: perform the threaded test in a child processGleb Smirnoff2024-02-241-6/+28
| | | | | | | | The test needs to be performed in a new process that was forked with RFCFDG flag. The will guarantee that the table will start to grow from 20 file descriptors, no matter what kyua(1) or a bare shell was doing before executing this test. This should fix repetitive test runs from a shell as well as failures with kyua(1) in some environments.
* Revert "tests/fdgrowtable: open more files in the threaded case"Gleb Smirnoff2024-02-241-1/+0
| | | | | | | | This reverts commit fa6a02f50e65c47540f51b3177f5080bc6af168e. It makes the test less probable to fail, but it doesn't fix the root issue - that on entry the parent process may have already a large file descriptor table.
* pf: Correct SPDX identifierTom Jones2024-02-231-1/+1
| | | | Pointed out by: Mike Karels <karels@FreeBSD.org>
* pf: Add a TCP rdr test on IPv6Tom Jones2024-02-232-0/+128
| | | | | | | Reviewed by: kp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42105
* tests/sigsys: initialize parameter passed to sysctlbyname()Gleb Smirnoff2024-02-201-1/+1
|
* tests/fdgrowtable: remove always true checkGleb Smirnoff2024-02-201-6/+4
| | | | We are always the parent in this code path.
* tests/fdgrowtable: open more files in the threaded caseGleb Smirnoff2024-02-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This should fix the test failing on some machines/conditions/runs. This won't fix failures in standalone run, but should fix kyua(1) runs. Currently with standalone run it will usually fail because the 40-sized allocation is skipped (see details below). This matches what forking test does: open 128 files in the parent and 128 in the child. There should actually be no difference where and when the files are open, but let's mimic the forking test, and open more files in the spawned thread. Also opening from two different contexts adds a bit more entropy to the test. What the test does it checks that fdgrowtable() has been called at least three tmes for the test process, and the old tables are still on the free list as long as other execution contexts exist. Under kyua(1) control the first call grows the table from 20 to 40, but the original table of 20 is an embedded one, thus is not put on the free list. Passing 40 open files the table grows to 128 and first old table lands on the free list. Passing 128 open file the table grows to 256 and a second old table lands on the free list. After that the test would pass. The threaded test was one open file off before this fix sometimes.
* tests/arp: test arp -s/-S workGleb Smirnoff2024-02-201-0/+62
| | | | | Install permanent entry, try to modify it, check that net.link.ether.inet.log_arp_permanent_modify works.
* tests/arp: when checking 'arp -d' check that entry is removedGleb Smirnoff2024-02-201-0/+1
| | | | | | Previous check trusted the "entry was deleted" output of the command. Improved check does additional request to make sure that entry is not returned.
* socket tests: add listener_wakeupGleb Smirnoff2024-02-152-0/+295
| | | | | | | | | | | | | | | | | | This test runs several scenarios when sleep(9) on a listen(2)ing socket is interrupted by shutdown(2) or by close(2). What should happen in that case is not specified, neither is documented. However, there is certain behavior that we have and this test makes sure it is preserved. There is software that relies on it, see bug 227259. This test is based on submission with this bug, bugzilla attachment 192260. The test checks TCP and unix(4) stream socket behavior and SCTP can be added easily if needed. The test passes on FreeBSD 11 to 15. It won't pass on FreeBSD 10, although the wakeup behavior of shutdown(2) is the same, but it doesn't return error. PR: 227259
* path_test: fix cap_rights_init usageEd Maste2024-02-151-3/+3
| | | | | | | | | | Capability rights passed to cap_rights_* are not simple bitmaks and cannot be ORed together in general (although it will work for certain subsets of rights). PR: 277057 Fixes: e5e1d9c7b781 ("path_test: Add a test case for...") Sponsored by: The FreeBSD Foundation
* Fix grammar error in test/sys/file/closefrom_test.cYen-Cheng Chang2024-02-131-1/+1
| | | | | Event: Advanced UNIX Programming Course (Fall’23) at NTHU. Pull Request: https://github.com/freebsd/freebsd-src/pull/973
* tests/unix_passfd: add a comment for send_a_lotGleb Smirnoff2024-02-081-2/+11
| | | | | Explain why SOCK_DGRAM and SOCK_STREAM differ in this edge case. While here improve output in case of a failure.
* tests/unix_passfd: test that control mixed with data creates recordsGleb Smirnoff2024-02-081-11/+45
| | | | | | | | | | | | | | | | | | | If socket has data interleaved with control it would never allow to read two pieces of data, neither two pieces of control with one recvmsg(2). In other words, presence of control makes a SOCK_STREAM socket behave like SOCK_SEQPACKET, where control marks the records. This is not a documented or specified behavior, but this is how it worked always for BSD sockets. If you look closer at it, this actually makes a lot of sense, as if it were the opposite both the kernel code and an application code would become way more complex. The change made recvfd_payload() to return received length and requires caller to do ATF_REQUIRE() itself. This required a small change to existing test rights_creds_payload. It also refactors a bit f28532a0f363, pushing two identical calls out of TEST_PROTO ifdef. Reviwed by: markj Differential Revision: https://reviews.freebsd.org/D43724