xref: /xnu-11417.101.15/tests/skywalk_tests.c (revision e3723e1f17661b24996789d8afc084c0c3303b26)
1*e3723e1fSApple OSS Distributions /*
2*e3723e1fSApple OSS Distributions  * Copyright (c) 2024 Apple Inc. All rights reserved.
3*e3723e1fSApple OSS Distributions  *
4*e3723e1fSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*e3723e1fSApple OSS Distributions  *
6*e3723e1fSApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*e3723e1fSApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*e3723e1fSApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*e3723e1fSApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*e3723e1fSApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*e3723e1fSApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*e3723e1fSApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*e3723e1fSApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*e3723e1fSApple OSS Distributions  *
15*e3723e1fSApple OSS Distributions  * Please obtain a copy of the License at
16*e3723e1fSApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*e3723e1fSApple OSS Distributions  *
18*e3723e1fSApple OSS Distributions  * The Original Code and all software distributed under the License are
19*e3723e1fSApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*e3723e1fSApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*e3723e1fSApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*e3723e1fSApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*e3723e1fSApple OSS Distributions  * Please see the License for the specific language governing rights and
24*e3723e1fSApple OSS Distributions  * limitations under the License.
25*e3723e1fSApple OSS Distributions  *
26*e3723e1fSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*e3723e1fSApple OSS Distributions  */
28*e3723e1fSApple OSS Distributions #include <stdlib.h>
29*e3723e1fSApple OSS Distributions #include <darwintest.h>
30*e3723e1fSApple OSS Distributions #include <darwintest_multiprocess.h>
31*e3723e1fSApple OSS Distributions #include <unistd.h>
32*e3723e1fSApple OSS Distributions 
33*e3723e1fSApple OSS Distributions #include "skywalk/skywalk_test_driver.h"
34*e3723e1fSApple OSS Distributions #include "skywalk/skywalk_test_common.h"
35*e3723e1fSApple OSS Distributions 
36*e3723e1fSApple OSS Distributions T_GLOBAL_META(
37*e3723e1fSApple OSS Distributions 	T_META_NAMESPACE("xnu.skywalk"),
38*e3723e1fSApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
39*e3723e1fSApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("skywalk")
40*e3723e1fSApple OSS Distributions 	);
41*e3723e1fSApple OSS Distributions 
42*e3723e1fSApple OSS Distributions #define BATS_TESTS \
43*e3723e1fSApple OSS Distributions 	X(noop, "test just returns true") \
44*e3723e1fSApple OSS Distributions 	X(crash, "test expects a segfault") \
45*e3723e1fSApple OSS Distributions 	X(assert, "test verifies that assert catches failure") \
46*e3723e1fSApple OSS Distributions 	X(features, "verifies skywalk features match kernel config") \
47*e3723e1fSApple OSS Distributions 	X(oneslotus, "test sends one slot of data on user pipe loopback using select") \
48*e3723e1fSApple OSS Distributions 	X(oneslotks, "test sends one slot of data on kpipe loopback using select") \
49*e3723e1fSApple OSS Distributions 	X(oneslotup, "test sends one slot of data on user pipe loopback using poll") \
50*e3723e1fSApple OSS Distributions 	X(oneslotkp, "test sends one slot of data on kpipe loopback using poll") \
51*e3723e1fSApple OSS Distributions 	X(oneslotuk, "test sends one slot of data on user pipe loopback using kqueue") \
52*e3723e1fSApple OSS Distributions 	X(oneslotkk, "test sends one slot of data on kpipe loopback using kqueue") \
53*e3723e1fSApple OSS Distributions 	X(oneslotuk_defunct, "test sends one slot of data on user pipe loopback using kqueue with one end of the pipe defuncted") \
54*e3723e1fSApple OSS Distributions 	X(shutdownus, "test shuts down channel on upipe and calls select") \
55*e3723e1fSApple OSS Distributions 	X(shutdownks, "test shuts down channel on kpipe and calls select") \
56*e3723e1fSApple OSS Distributions 	X(shutdownup, "test shuts down channel on upipe and calls poll") \
57*e3723e1fSApple OSS Distributions 	X(shutdownkp, "test shuts down channel on kpipe and calls poll") \
58*e3723e1fSApple OSS Distributions 	X(shutdownuk, "test shuts down channel on upipe and calls kqueue") \
59*e3723e1fSApple OSS Distributions 	X(shutdownkk, "test shuts down channel on kpipe and calls kqueue") \
60*e3723e1fSApple OSS Distributions 	X(shutdown2us, "test shuts down channel on upipe while in select") \
61*e3723e1fSApple OSS Distributions 	X(shutdown2ks, "test shuts down channel on kpipe while in select") \
62*e3723e1fSApple OSS Distributions 	X(shutdown2up, "test shuts down channel on upipe while in poll") \
63*e3723e1fSApple OSS Distributions 	X(shutdown2kp, "test shuts down channel on kpipe while in poll") \
64*e3723e1fSApple OSS Distributions 	X(shutdown2uk, "test shuts down channel on upipe while in kqueue") \
65*e3723e1fSApple OSS Distributions 	X(shutdown2kk, "test shuts down channel on kpipe while in kqueue") \
66*e3723e1fSApple OSS Distributions 	X(nslotsus, "test sends TX_SLOTS of data on user pipe loopback using select") \
67*e3723e1fSApple OSS Distributions 	X(nslotsks, "test sends TX_SLOTS of data on kpipe loopback using select") \
68*e3723e1fSApple OSS Distributions 	X(nslotsup, "test sends TX_SLOTS of data on user pipe loopback using poll") \
69*e3723e1fSApple OSS Distributions 	X(nslotskp, "test sends TX_SLOTS of data on kpipe loopback using poll") \
70*e3723e1fSApple OSS Distributions 	X(nslotsuk, "test sends TX_SLOTS of data on user pipe loopback using kqueue") \
71*e3723e1fSApple OSS Distributions 	X(nslotskk, "test sends TX_SLOTS of data on kpipe loopback using kqueue") \
72*e3723e1fSApple OSS Distributions 	X(mslotsus, "test sends 1000000 slots of data on user pipe loopback using select") \
73*e3723e1fSApple OSS Distributions 	X(mslotsks, "test sends 1000000 slots of data on kpipe loopback using select") \
74*e3723e1fSApple OSS Distributions 	X(mslotsup, "test sends 1000000 slots of data on user pipe loopback using poll") \
75*e3723e1fSApple OSS Distributions 	X(mslotskp, "test sends 1000000 slots of data on kpipe loopback using poll") \
76*e3723e1fSApple OSS Distributions 	X(mslotsuk, "test sends 1000000 slots of data on user pipe loopback using kqueue") \
77*e3723e1fSApple OSS Distributions 	X(mslotskk, "test sends 1000000 slots of data on kpipe loopback using kqueue") \
78*e3723e1fSApple OSS Distributions 	X(closecfd, "test closing guarded channel fd") \
79*e3723e1fSApple OSS Distributions 	X(writecfd, "test writing to channel fd") \
80*e3723e1fSApple OSS Distributions 	X(readcfd, "test reading from channel fd") \
81*e3723e1fSApple OSS Distributions 	X(closenfd, "test closing guarded nexus fd") \
82*e3723e1fSApple OSS Distributions 	X(readnfd, "test reading from a guarded nexus fd") \
83*e3723e1fSApple OSS Distributions 	X(writeif, "test writes to the read only channel if") \
84*e3723e1fSApple OSS Distributions 	X(writering, "test writes to the writeable ring") \
85*e3723e1fSApple OSS Distributions 	X(readsmap, "test reads from the read only smap") \
86*e3723e1fSApple OSS Distributions 	X(writesmap, "test writes to the read only smap") \
87*e3723e1fSApple OSS Distributions 	X(verifynxadv, "test verifies nexus advisory region") \
88*e3723e1fSApple OSS Distributions 	X(badringtl, "test calls select with bad tx ring pointers") \
89*e3723e1fSApple OSS Distributions 	X(badringtp, "test calls poll with bad tx ring pointers") \
90*e3723e1fSApple OSS Distributions 	X(badringtk, "test calls kqueue with bad tx ring pointers") \
91*e3723e1fSApple OSS Distributions 	X(badringts, "test calls sync with bad tx ring pointers") \
92*e3723e1fSApple OSS Distributions 	X(badringrl, "test calls select with bad rx ring pointers") \
93*e3723e1fSApple OSS Distributions 	X(badringrp, "test calls poll with bad rx ring pointers") \
94*e3723e1fSApple OSS Distributions 	X(badringrk, "test calls kqueue with bad rx ring pointers") \
95*e3723e1fSApple OSS Distributions 	X(badringrs, "test calls sync with bad rx ring pointers") \
96*e3723e1fSApple OSS Distributions 	X(kqueue_basic, "test kqueue return values") \
97*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_chan_bytes, "test kqueue low watermark (byte watermark on channel)") \
98*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_chan_slots, "test kqueue low watermark (slot watermark on channel)") \
99*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_note_bytes, "test kqueue low watermark (byte watermark on knote)") \
100*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_note_slots, "test kqueue low watermark (slot watermark on knote)") \
101*e3723e1fSApple OSS Distributions 	X(change_len, "test kernel resilience to modified slot lengths") \
102*e3723e1fSApple OSS Distributions 	X(big_len, "test unrealistically large slot lengths") \
103*e3723e1fSApple OSS Distributions 	X(internalizemetdata, "test internalizex packet metadata verification") \
104*e3723e1fSApple OSS Distributions 	X(ringidtx, "test opening tx ringids") \
105*e3723e1fSApple OSS Distributions 	X(ringidrx, "test opening rx ringids") \
106*e3723e1fSApple OSS Distributions 	X(closekqk, "test closing kqueue in kqueue") \
107*e3723e1fSApple OSS Distributions 	X(debug_verify_u, "test confirms that skywalk is storing checksums of slots received on a upipe when in SKF_VERIFY debug mode") \
108*e3723e1fSApple OSS Distributions 	X(utun27302538a, "test cleaning up utun kpipe while channel is in kevent (case a)") \
109*e3723e1fSApple OSS Distributions 	X(utun27302538b, "test cleaning up utun kpipe while channel is in kevent (case b)") \
110*e3723e1fSApple OSS Distributions 	X(utun27302538c, "test cleaning up utun kpipe while channel is in kevent (case c)") \
111*e3723e1fSApple OSS Distributions 	X(utun27302538d, "test cleaning up utun kpipe while channel is in kevent (case d)") \
112*e3723e1fSApple OSS Distributions 	X(bindupipeanon, "test binds a channel to an anonymous user pipe nexus") \
113*e3723e1fSApple OSS Distributions 	X(bindupipekey, "test binds a channel to a non-anonymous user pipe nexus") \
114*e3723e1fSApple OSS Distributions 	X(bindfswanon, "test binds a channel to an anonymous flowswitch nexus") \
115*e3723e1fSApple OSS Distributions 	X(bindfswkey, "test binds a channel to a non-anonymous flowswitch nexus") \
116*e3723e1fSApple OSS Distributions 	X(bindnetifkey, "test binds a channel to a non-anonymous netif nexus") \
117*e3723e1fSApple OSS Distributions 	X(flowswitch_ns_reserve, "test confirms that flowswitches can reserve L4 ports") \
118*e3723e1fSApple OSS Distributions 	X(flowswitch_ns_reserve2, "thorough test of netns for both BSD & flowswitch, IPv4/v6") \
119*e3723e1fSApple OSS Distributions 	X(netifcompata, "Test setup and teardown netifcompat on feth0") \
120*e3723e1fSApple OSS Distributions 	X(netifcompatb, "Test setup and teardown netifcompat on feth0 with deferred close channel") \
121*e3723e1fSApple OSS Distributions 	X(netifcompatc, "Test setup and teardown netifcompat on feth0 with deferred detach and close channel") \
122*e3723e1fSApple OSS Distributions 	X(fswloopfsw, "Test creates a flowswitch and attaches it to itself") \
123*e3723e1fSApple OSS Distributions 	X(fswloop2ff, "Test attaches a flowswitch to a flowswitch without any netif") \
124*e3723e1fSApple OSS Distributions 	X(teardown, "Test setup complicated topology tear it down") \
125*e3723e1fSApple OSS Distributions 	X(teardownb, "Test setup complicated topology tear it down backwards") \
126*e3723e1fSApple OSS Distributions 	X(fsw29301703a, "Test open 63 channels to a flowswitch") \
127*e3723e1fSApple OSS Distributions 	X(fsw29301703b, "Test open 200 channels to a flowswitch") \
128*e3723e1fSApple OSS Distributions 	X(fsw29301703c, "Open too many channels to a flowswitch") \
129*e3723e1fSApple OSS Distributions 	X(fswbindany, "Test attempts to bind to port -1 of flowswitch") \
130*e3723e1fSApple OSS Distributions 	X(fswbind0, "Test attempts to bind to port 0 of flowswitch") \
131*e3723e1fSApple OSS Distributions 	X(fswbind1, "Test attempts to bind to port 1 of flowswitch") \
132*e3723e1fSApple OSS Distributions 	X(fswbind512, "Test attempts to bind to port 512 of flowswitch") \
133*e3723e1fSApple OSS Distributions 	X(fswbind2, "Test attempts to bind to port 2 of flowswitch") \
134*e3723e1fSApple OSS Distributions 	X(fswbind5, "Test attempts to bind to port 5 of flowswitch") \
135*e3723e1fSApple OSS Distributions 	X(fullupipe, "Test rx on full tx pipe") \
136*e3723e1fSApple OSS Distributions 	X(upipepeerclosure, "Test channel operations on upipe with no peer") \
137*e3723e1fSApple OSS Distributions 	X(listener, "Test skywalk listener flow creation check") \
138*e3723e1fSApple OSS Distributions 	X(listener_stress, "Test stress skywalk listener flows") \
139*e3723e1fSApple OSS Distributions 	X(listener_reuse, "Test stress skywalk listener reuse") \
140*e3723e1fSApple OSS Distributions 	X(copy_cksum_single, "Test copy/checksum code: single buffer") \
141*e3723e1fSApple OSS Distributions 	X(copy_cksum_multi, "Test copy/checksum code: buffer chain") \
142*e3723e1fSApple OSS Distributions 	X(reass_timeout, "Test send partial fragment to flowswitch and check for ICMPv6 time exceeded reply") \
143*e3723e1fSApple OSS Distributions 	X(reass_bad_fraglen, "Test send fragment with bad fragment length (!= 8*) to flowswitch and check for ICMPv6 param header reply") \
144*e3723e1fSApple OSS Distributions 	X(reass_atomic, "Test send atomic ICMP echo fragment to flowswitch and check for reply") \
145*e3723e1fSApple OSS Distributions 	X(reass_fuzz_queue_limit, "Test fuzz flowswitch to hit fragment limit") \
146*e3723e1fSApple OSS Distributions 	X(cksum, "Test checksum code") \
147*e3723e1fSApple OSS Distributions 	X(memory, "Test skmem allocator basic and advanced tests") \
148*e3723e1fSApple OSS Distributions 	X(flow_req, "Test skywalk flow request api") \
149*e3723e1fSApple OSS Distributions 	X(flow_req_ll, "Test skywalk flow request api for low latency flows") \
150*e3723e1fSApple OSS Distributions 	X(flow_config, "Test skywalk flow config api") \
151*e3723e1fSApple OSS Distributions 	X(flowlookup, "Test test flow lookup by send/receive of packets") \
152*e3723e1fSApple OSS Distributions 	X(libcuckoo, "Test Cuckoo hashtable library basic and advanced tests") \
153*e3723e1fSApple OSS Distributions 	X(restricted_port, "Test reserve a restricted ephemeral port") \
154*e3723e1fSApple OSS Distributions 	X(steering, "Test steering rules") \
155*e3723e1fSApple OSS Distributions 	X(listen_stress, "Test stress posix socket listen") \
156*e3723e1fSApple OSS Distributions 	X(pllutxk, "Test send 10000000 slots to upipe sink using kqueue")
157*e3723e1fSApple OSS Distributions 
158*e3723e1fSApple OSS Distributions /*
159*e3723e1fSApple OSS Distributions  *  The following tetsts are disabled:
160*e3723e1fSApple OSS Distributions  *       X(writenfd, "test writing to a guarded nexus fd") due to rdar://133461652
161*e3723e1fSApple OSS Distributions  */
162*e3723e1fSApple OSS Distributions 
163*e3723e1fSApple OSS Distributions #define BATSPLL_TESTS \
164*e3723e1fSApple OSS Distributions 	X(noop, "test just returns true") \
165*e3723e1fSApple OSS Distributions 	X(crash, "test expects a segfault") \
166*e3723e1fSApple OSS Distributions 	X(assert, "test verifies that assert catches failure") \
167*e3723e1fSApple OSS Distributions 	X(features, "verifies skywalk features match kernel config") \
168*e3723e1fSApple OSS Distributions 	X(pllutxk, "send 10000000 slots to upipe sink using kqueue") \
169*e3723e1fSApple OSS Distributions 	X(pllutxs, "send 10000000 slots to upipe sink using select") \
170*e3723e1fSApple OSS Distributions 	X(pllutxp, "send 10000000 slots to upipe sink using poll") \
171*e3723e1fSApple OSS Distributions 	X(pllurxk, "receive 10000000 slots from upipe source using kqueue") \
172*e3723e1fSApple OSS Distributions 	X(pllurxs, "receive 10000000 slots from upipe source using select") \
173*e3723e1fSApple OSS Distributions 	X(pllurxp, "receive 10000000 slots to upipe source using poll")
174*e3723e1fSApple OSS Distributions 
175*e3723e1fSApple OSS Distributions #define BATSUTUN_TESTS \
176*e3723e1fSApple OSS Distributions 	X(noop, "test just returns true") \
177*e3723e1fSApple OSS Distributions 	X(crash, "test expects a segfault") \
178*e3723e1fSApple OSS Distributions 	X(assert, "test verifies that assert catches failure") \
179*e3723e1fSApple OSS Distributions 	X(features, "verifies skywalk features match kernel config") \
180*e3723e1fSApple OSS Distributions 	X(utun27302538a, "test cleaning up utun kpipe while channel is in kevent (case a)") \
181*e3723e1fSApple OSS Distributions 	X(utun27302538b, "test cleaning up utun kpipe while channel is in kevent (case b)") \
182*e3723e1fSApple OSS Distributions 	X(utun27302538c, "test cleaning up utun kpipe while channel is in kevent (case c)") \
183*e3723e1fSApple OSS Distributions 	X(utun27302538d, "test cleaning up utun kpipe while channel is in kevent (case d)") \
184*e3723e1fSApple OSS Distributions 	X(utun27646755, "race cleaning up channel and utun socket (20 iterations)") \
185*e3723e1fSApple OSS Distributions 	X(utunloopn4u1, "open 2 utuns without netif and floods ipv4 udp packets in one direction") \
186*e3723e1fSApple OSS Distributions 	X(utunloopn4u2, "open 2 utuns without netif and floods ipv4 udp packets in two directions") \
187*e3723e1fSApple OSS Distributions 	X(utunloopn4t1, "open 2 utuns without netif and floods ipv4 tcp packets in one direction") \
188*e3723e1fSApple OSS Distributions 	X(utunloopn4t2, "open 2 utuns without netif and floods ipv4 tcp packets in two directions") \
189*e3723e1fSApple OSS Distributions 	X(utunloopy4u1, "open 2 utuns with netif and floods ipv4 udp packets in one direction") \
190*e3723e1fSApple OSS Distributions 	X(utunloopy4u2, "open 2 utuns with netif and floods ipv4 udp packets in two directions") \
191*e3723e1fSApple OSS Distributions 	X(utunloopy4t1, "open 2 utuns with netif and floods ipv4 tcp packets in one direction") \
192*e3723e1fSApple OSS Distributions 	X(utunloopy4t2, "open 2 utuns with netif and floods ipv4 tcp packets in two directions")
193*e3723e1fSApple OSS Distributions 
194*e3723e1fSApple OSS Distributions #define SHUTDOWN_TESTS \
195*e3723e1fSApple OSS Distributions 	X(oneslotus, "test sends one slot of data on user pipe loopback using select") \
196*e3723e1fSApple OSS Distributions 	X(oneslotks, "test sends one slot of data on kpipe loopback using select") \
197*e3723e1fSApple OSS Distributions 	X(oneslotup, "test sends one slot of data on user pipe loopback using poll") \
198*e3723e1fSApple OSS Distributions 	X(oneslotkp, "test sends one slot of data on kpipe loopback using poll") \
199*e3723e1fSApple OSS Distributions 	X(oneslotuk, "test sends one slot of data on user pipe loopback using kqueue") \
200*e3723e1fSApple OSS Distributions 	X(oneslotuk_defunct, "test sends one slot of data on user pipe loopback using kqueue with one end of the pipe defuncted") \
201*e3723e1fSApple OSS Distributions 	X(oneslotkk, "test sends one slot of data on kpipe loopback using kqueue") \
202*e3723e1fSApple OSS Distributions 	X(nslotsus, "test sends TX_SLOTS of data on user pipe loopback using select") \
203*e3723e1fSApple OSS Distributions 	X(nslotsks, "test sends TX_SLOTS of data on kpipe loopback using select") \
204*e3723e1fSApple OSS Distributions 	X(nslotsup, "test sends TX_SLOTS of data on user pipe loopback using poll") \
205*e3723e1fSApple OSS Distributions 	X(nslotskp, "test sends TX_SLOTS of data on kpipe loopback using poll") \
206*e3723e1fSApple OSS Distributions 	X(nslotsuk, "test sends TX_SLOTS of data on user pipe loopback using kqueue") \
207*e3723e1fSApple OSS Distributions 	X(nslotskk, "test sends TX_SLOTS of data on kpipe loopback using kqueue") \
208*e3723e1fSApple OSS Distributions 	X(mslotsus, "test sends 1000000 slots of data on user pipe loopback using select") \
209*e3723e1fSApple OSS Distributions 	X(mslotsks, "test sends 1000000 slots of data on kpipe loopback using select") \
210*e3723e1fSApple OSS Distributions 	X(mslotsup, "test sends 1000000 slots of data on user pipe loopback using poll") \
211*e3723e1fSApple OSS Distributions 	X(mslotskp, "test sends 1000000 slots of data on kpipe loopback using poll") \
212*e3723e1fSApple OSS Distributions 	X(mslotsuk, "test sends 1000000 slots of data on user pipe loopback using kqueue") \
213*e3723e1fSApple OSS Distributions 	X(mslotskk, "test sends 1000000 slots of data on kpipe loopback using kqueue") \
214*e3723e1fSApple OSS Distributions 	X(mmslotsus, "test sends 10000000 slots of data on user pipe loopback using select") \
215*e3723e1fSApple OSS Distributions 	X(mmslotsks, "test sends 10000000 slots of data on kpipe loopback using select") \
216*e3723e1fSApple OSS Distributions 	X(mmslotsup, "test sends 10000000 slots of data on user pipe loopback using poll") \
217*e3723e1fSApple OSS Distributions 	X(mmslotskp, "test sends 10000000 slots of data on kpipe loopback using poll") \
218*e3723e1fSApple OSS Distributions 	X(mmslotsuk, "test sends 10000000 slots of data on user pipe loopback using kqueue") \
219*e3723e1fSApple OSS Distributions 	X(mmslotskk, "test sends 10000000 slots of data on kpipe loopback using kqueue") \
220*e3723e1fSApple OSS Distributions 	X(closecfd, "test closing guarded channel fd") \
221*e3723e1fSApple OSS Distributions 	X(writecfd, "test writing to channel fd") \
222*e3723e1fSApple OSS Distributions 	X(readcfd, "test reading from channel fd") \
223*e3723e1fSApple OSS Distributions 	X(closenfd, "test closing guarded nexus fd") \
224*e3723e1fSApple OSS Distributions 	X(writeif, "test writes to the read only channel if") \
225*e3723e1fSApple OSS Distributions 	X(writering, "test writes to the writeable ring") \
226*e3723e1fSApple OSS Distributions 	X(readsmap, "test reads from the read only smap") \
227*e3723e1fSApple OSS Distributions 	X(writesmap, "test writes to the read only smap") \
228*e3723e1fSApple OSS Distributions 	X(verifynxadv, "test verifies nexus advisory region") \
229*e3723e1fSApple OSS Distributions 	X(badringtl, "test calls select with bad tx ring pointers") \
230*e3723e1fSApple OSS Distributions 	X(badringtp, "test calls poll with bad tx ring pointers") \
231*e3723e1fSApple OSS Distributions 	X(badringtk, "test calls kqueue with bad tx ring pointers") \
232*e3723e1fSApple OSS Distributions 	X(badringts, "test calls sync with bad tx ring pointers") \
233*e3723e1fSApple OSS Distributions 	X(badringrl, "test calls select with bad rx ring pointers") \
234*e3723e1fSApple OSS Distributions 	X(badringrp, "test calls poll with bad rx ring pointers") \
235*e3723e1fSApple OSS Distributions 	X(badringrk, "test calls kqueue with bad rx ring pointers") \
236*e3723e1fSApple OSS Distributions 	X(badringrs, "test calls sync with bad rx ring pointers") \
237*e3723e1fSApple OSS Distributions 	X(kqueue_basic, "test kqueue return values") \
238*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_chan_slots, "test kqueue low watermark (slot watermark on channel)") \
239*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_chan_bytes, "test kqueue low watermark (byte watermark on channel)") \
240*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_note_slots, "test kqueue low watermark (slot watermark on knote)") \
241*e3723e1fSApple OSS Distributions 	X(kqueue_lowat_note_bytes, "test kqueue low watermark (byte watermark on knote)") \
242*e3723e1fSApple OSS Distributions 	X(change_len, "test kernel resilience to modified slot lengths") \
243*e3723e1fSApple OSS Distributions 	X(big_len, "test unrealistically large slot lengths") \
244*e3723e1fSApple OSS Distributions 	X(internalizemetdata, "test internalizex packet metadata verification") \
245*e3723e1fSApple OSS Distributions 	X(ringidtx, "test opening tx ringids") \
246*e3723e1fSApple OSS Distributions 	X(ringidrx, "test opening rx ringids") \
247*e3723e1fSApple OSS Distributions 	X(debug_verify_u, "test confirms that skywalk is storing checksums of slots received on a upipe when in SKF_VERIFY debug mode") \
248*e3723e1fSApple OSS Distributions 	X(debug_verify_k, "test confirms that skywalk is storing checksums of slots received on a kpipe when in SKF_VERIFY debug mode") \
249*e3723e1fSApple OSS Distributions 	X(utun27302538a, "test cleaning up utun kpipe while channel is in kevent (case a)") \
250*e3723e1fSApple OSS Distributions 	X(utun27302538b, "test cleaning up utun kpipe while channel is in kevent (case b)") \
251*e3723e1fSApple OSS Distributions 	X(utun27302538c, "test cleaning up utun kpipe while channel is in kevent (case c)") \
252*e3723e1fSApple OSS Distributions 	X(utun27302538d, "test cleaning up utun kpipe while channel is in kevent (case d)") \
253*e3723e1fSApple OSS Distributions 	X(utun27646755, "race cleaning up channel and utun socket (20 iterations)") \
254*e3723e1fSApple OSS Distributions 	X(utunloopn4u1, "open 2 utuns without netif and floods ipv4 udp packets in one direction") \
255*e3723e1fSApple OSS Distributions 	X(utunloopn4u2, "open 2 utuns without netif and floods ipv4 udp packets in two directions") \
256*e3723e1fSApple OSS Distributions 	X(utunloopn4t1, "open 2 utuns without netif and floods ipv4 tcp packets in one direction") \
257*e3723e1fSApple OSS Distributions 	X(utunloopn4t2, "open 2 utuns without netif and floods ipv4 tcp packets in two directions") \
258*e3723e1fSApple OSS Distributions 	X(utunloopy4u1, "open 2 utuns with netif and floods ipv4 udp packets in one direction") \
259*e3723e1fSApple OSS Distributions 	X(utunloopy4u2, "open 2 utuns with netif and floods ipv4 udp packets in two directions") \
260*e3723e1fSApple OSS Distributions 	X(utunloopy4t1, "open 2 utuns with netif and floods ipv4 tcp packets in one direction") \
261*e3723e1fSApple OSS Distributions 	X(utunloopy4t2, "open 2 utuns with netif and floods ipv4 tcp packets in two directions") \
262*e3723e1fSApple OSS Distributions 	X(ipsecloopy4u1, "open 2 ipsecs with netif and floods ipv4 udp packets in one direction") \
263*e3723e1fSApple OSS Distributions 	X(ipsecloopy4u2, "open 2 ipsecs with netif and floods ipv4 udp packets in two directions") \
264*e3723e1fSApple OSS Distributions 	X(ipsecloopy4t1, "open 2 ipsecs with netif and floods ipv4 tcp packets in one direction") \
265*e3723e1fSApple OSS Distributions 	X(ipsecloopy4t2, "open 2 ipsecs with netif and floods ipv4 tcp packets in two directions") \
266*e3723e1fSApple OSS Distributions 	X(bindupipekey, "test binds a channel to a non-anonymous user pipe nexus") \
267*e3723e1fSApple OSS Distributions 	X(bindfswkey, "test binds a channel to a non-anonymous flowswitch nexus") \
268*e3723e1fSApple OSS Distributions 	X(netifcompata, "Test setup and teardown netifcompat on feth0") \
269*e3723e1fSApple OSS Distributions 	X(netifcompatb, "Test setup and teardown netifcompat on feth0 with deferred close channel") \
270*e3723e1fSApple OSS Distributions 	X(netifcompatc, "Test setup and teardown netifcompat on feth0 with deferred detach and close channel") \
271*e3723e1fSApple OSS Distributions 	X(teardown, "Test setup complicated topology tear it down") \
272*e3723e1fSApple OSS Distributions 	X(teardownb, "Test setup complicated topology tear it down backwards") \
273*e3723e1fSApple OSS Distributions 	X(teardownr, "setup complicated topology tear it down randomly (1000 iterations)") \
274*e3723e1fSApple OSS Distributions 	X(teardownz, "setup complicated topology tear it down with each stage in an out of order position") \
275*e3723e1fSApple OSS Distributions 	X(fsw29301703a, "Test open 63 channels to a flowswitch") \
276*e3723e1fSApple OSS Distributions 	X(fsw29301703b, "Test open 200 channels to a flowswitch") \
277*e3723e1fSApple OSS Distributions 	X(fsw29301703c, "Open too many channels to a flowswitch") \
278*e3723e1fSApple OSS Distributions 	X(mf10x10, "test binds 10 ports with 10 flows per port") \
279*e3723e1fSApple OSS Distributions 	X(mf10x100, "test binds 10 ports with 100 flows per port") \
280*e3723e1fSApple OSS Distributions 	X(mf100x10, "test binds 100 ports with 10 flows per port") \
281*e3723e1fSApple OSS Distributions 	X(mf100x100, "test binds 100 ports with 100 flows per port") \
282*e3723e1fSApple OSS Distributions 	X(fullupipe, "Test rx on full tx pipe") \
283*e3723e1fSApple OSS Distributions 	X(upipepeerclosure, "Test channel operations on upipe with no peer") \
284*e3723e1fSApple OSS Distributions 	X(pllutxk, "send 10000000 slots to upipe sink using kqueue") \
285*e3723e1fSApple OSS Distributions 	X(pllutxs, "send 10000000 slots to upipe sink using select") \
286*e3723e1fSApple OSS Distributions 	X(pllutxp, "send 10000000 slots to upipe sink using poll") \
287*e3723e1fSApple OSS Distributions 	X(pllurxk, "receive 10000000 slots from upipe source using kqueue") \
288*e3723e1fSApple OSS Distributions 	X(pllurxs, "receive 10000000 slots from upipe source using select") \
289*e3723e1fSApple OSS Distributions 	X(pllurxp, "receive 10000000 slots to upipe source using poll")
290*e3723e1fSApple OSS Distributions 
291*e3723e1fSApple OSS Distributions /*
292*e3723e1fSApple OSS Distributions  * These tests have failure rate > 2%, so we turn on extra logging.
293*e3723e1fSApple OSS Distributions  */
294*e3723e1fSApple OSS Distributions #define BATS_FAILING_TESTS \
295*e3723e1fSApple OSS Distributions 	X(utunloopn4u1, "open 2 utuns without netif and floods ipv4 udp packets in one direction") \
296*e3723e1fSApple OSS Distributions 	X(utunloopn4u2, "open 2 utuns without netif and floods ipv4 udp packets in two directions") \
297*e3723e1fSApple OSS Distributions 	X(utunloopn4t1, "open 2 utuns without netif and floods ipv4 tcp packets in one direction") \
298*e3723e1fSApple OSS Distributions 	X(utunloopn4t2, "open 2 utuns without netif and floods ipv4 tcp packets in two directions") \
299*e3723e1fSApple OSS Distributions 	X(utunloopy4u1, "open 2 utuns with netif and floods ipv4 udp packets in one direction") \
300*e3723e1fSApple OSS Distributions 	X(utunloopy4u2, "open 2 utuns with netif and floods ipv4 udp packets in two directions") \
301*e3723e1fSApple OSS Distributions 	X(utunloopy4t1, "open 2 utuns with netif and floods ipv4 tcp packets in one direction") \
302*e3723e1fSApple OSS Distributions 	X(utunloopy4t2, "open 2 utuns with netif and floods ipv4 tcp packets in two directions")
303*e3723e1fSApple OSS Distributions 
304*e3723e1fSApple OSS Distributions #define EXPAND_TO_T_DECL_COMMON(test, desc)                                    \
305*e3723e1fSApple OSS Distributions 	{                                                                      \
306*e3723e1fSApple OSS Distributions 	        const char *memfail_str = getenv("memfail");                   \
307*e3723e1fSApple OSS Distributions 	        const char *ignorefail_str = getenv("ignorefail");             \
308*e3723e1fSApple OSS Distributions 	        const char *shutdown_str = getenv("shutdown");                 \
309*e3723e1fSApple OSS Distributions 	        const char *itersecs_str = getenv("itersecs");                 \
310*e3723e1fSApple OSS Distributions 	        uint32_t memfail = 0;                                          \
311*e3723e1fSApple OSS Distributions 	        bool ignorefail = false;                                       \
312*e3723e1fSApple OSS Distributions 	        bool shutdown = false;                                         \
313*e3723e1fSApple OSS Distributions 	        int itersecs = -1;                                             \
314*e3723e1fSApple OSS Distributions 	        if (memfail_str) {                                             \
315*e3723e1fSApple OSS Distributions 	                T_LOG("memfail option present: %s", memfail_str);      \
316*e3723e1fSApple OSS Distributions 	                memfail = atoi(memfail_str);                           \
317*e3723e1fSApple OSS Distributions 	        }                                                              \
318*e3723e1fSApple OSS Distributions 	        if (ignorefail_str) {                                          \
319*e3723e1fSApple OSS Distributions 	                T_LOG("ignorefail option present: %s", ignorefail_str);\
320*e3723e1fSApple OSS Distributions 	                ignorefail = true;                                     \
321*e3723e1fSApple OSS Distributions 	        }                                                              \
322*e3723e1fSApple OSS Distributions 	        if (shutdown_str) {                                            \
323*e3723e1fSApple OSS Distributions 	                T_LOG("shutdown option present: %s", shutdown_str);    \
324*e3723e1fSApple OSS Distributions 	                shutdown = true;                                       \
325*e3723e1fSApple OSS Distributions 	                ignorefail = true;                                     \
326*e3723e1fSApple OSS Distributions 	        }                                                              \
327*e3723e1fSApple OSS Distributions 	        if (itersecs_str) {                                            \
328*e3723e1fSApple OSS Distributions 	                T_LOG("itersecs option present: %s", itersecs_str);    \
329*e3723e1fSApple OSS Distributions 	                itersecs = atoi(itersecs_str);                         \
330*e3723e1fSApple OSS Distributions 	        }                                                              \
331*e3723e1fSApple OSS Distributions 	        skywalk_test_driver_run(&skt_##test, argc, (skt_##test).skt_argv,\
332*e3723e1fSApple OSS Distributions 	            memfail, ignorefail, shutdown, itersecs);                  \
333*e3723e1fSApple OSS Distributions 	}
334*e3723e1fSApple OSS Distributions 
335*e3723e1fSApple OSS Distributions /*
336*e3723e1fSApple OSS Distributions  * T_DECL naming convention: <testset>_<options>_<testcase>, where:
337*e3723e1fSApple OSS Distributions  * <testset> is one of pll or utun (we omit "bats" because it's redundant)
338*e3723e1fSApple OSS Distributions  * <options> is one of memfail or shutdown
339*e3723e1fSApple OSS Distributions  * <testcase> is the actual testcase name, such as nslotus
340*e3723e1fSApple OSS Distributions  */
341*e3723e1fSApple OSS Distributions #define EXPAND_TO_T_DECL(tdecl_name, test, desc)    \
342*e3723e1fSApple OSS Distributions 	T_DECL(tdecl_name, desc)                    \
343*e3723e1fSApple OSS Distributions 	EXPAND_TO_T_DECL_COMMON(test, desc)
344*e3723e1fSApple OSS Distributions 
345*e3723e1fSApple OSS Distributions /*
346*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
347*e3723e1fSApple OSS Distributions  * skywalk_tests bats
348*e3723e1fSApple OSS Distributions  */
349*e3723e1fSApple OSS Distributions #define X(test, desc, ...) EXPAND_TO_T_DECL(test, test, desc)
350*e3723e1fSApple OSS Distributions BATS_TESTS;
351*e3723e1fSApple OSS Distributions #undef X
352*e3723e1fSApple OSS Distributions 
353*e3723e1fSApple OSS Distributions /*
354*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
355*e3723e1fSApple OSS Distributions  * skywalk_tests batspll
356*e3723e1fSApple OSS Distributions  */
357*e3723e1fSApple OSS Distributions #define X(test, desc, ...) EXPAND_TO_T_DECL(pll_##test, test, desc)
358*e3723e1fSApple OSS Distributions BATSPLL_TESTS;
359*e3723e1fSApple OSS Distributions #undef X
360*e3723e1fSApple OSS Distributions 
361*e3723e1fSApple OSS Distributions /*
362*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
363*e3723e1fSApple OSS Distributions  * skywalk_tests batsutun
364*e3723e1fSApple OSS Distributions  */
365*e3723e1fSApple OSS Distributions #define X(test, desc, ...) EXPAND_TO_T_DECL(utun_##test, test, desc)
366*e3723e1fSApple OSS Distributions BATSUTUN_TESTS;
367*e3723e1fSApple OSS Distributions #undef X
368*e3723e1fSApple OSS Distributions 
369*e3723e1fSApple OSS Distributions /*
370*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
371*e3723e1fSApple OSS Distributions  * skywalk_tests --ignorefail --memfail 127 bats
372*e3723e1fSApple OSS Distributions  */
373*e3723e1fSApple OSS Distributions #define X(test, desc, ...)                                    \
374*e3723e1fSApple OSS Distributions 	T_DECL_REF(memfail_##test, test, desc,                \
375*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("memfail=127"),                 \
376*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("ignorefail=true"));
377*e3723e1fSApple OSS Distributions BATS_TESTS;
378*e3723e1fSApple OSS Distributions #undef X
379*e3723e1fSApple OSS Distributions 
380*e3723e1fSApple OSS Distributions /*
381*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
382*e3723e1fSApple OSS Distributions  * skywalk_tests --ignorefail --memfail 127 batspll
383*e3723e1fSApple OSS Distributions  */
384*e3723e1fSApple OSS Distributions #define X(test, desc, ...)                                          \
385*e3723e1fSApple OSS Distributions 	T_DECL_REF(pll_memfail_##test, pll_##test, desc,            \
386*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("memfail=127"),                       \
387*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("ignorefail=true"));
388*e3723e1fSApple OSS Distributions BATSPLL_TESTS;
389*e3723e1fSApple OSS Distributions #undef X
390*e3723e1fSApple OSS Distributions 
391*e3723e1fSApple OSS Distributions /*
392*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
393*e3723e1fSApple OSS Distributions  * skywalk_tests --ignorefail --memfail 127 batsutun
394*e3723e1fSApple OSS Distributions  */
395*e3723e1fSApple OSS Distributions #define X(test, desc, ...)                                              \
396*e3723e1fSApple OSS Distributions 	T_DECL_REF(utun_memfail_##test, utun_##test, desc,              \
397*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("memfail=127"),                           \
398*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("ignorefail=true"));
399*e3723e1fSApple OSS Distributions BATSUTUN_TESTS;
400*e3723e1fSApple OSS Distributions #undef X
401*e3723e1fSApple OSS Distributions 
402*e3723e1fSApple OSS Distributions /*
403*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
404*e3723e1fSApple OSS Distributions  * skywalk_tests --memfail 0 noop
405*e3723e1fSApple OSS Distributions  */
406*e3723e1fSApple OSS Distributions T_DECL_REF(noop_memcleanup, noop, "run noop test to cleanup memory failure sysctl",
407*e3723e1fSApple OSS Distributions     T_META_NAMESPACE("xnu.skyawlk.memcleanup"),
408*e3723e1fSApple OSS Distributions     T_META_ENVVAR("memfail=0"));
409*e3723e1fSApple OSS Distributions 
410*e3723e1fSApple OSS Distributions /*
411*e3723e1fSApple OSS Distributions  * This is equivalent to the following legacy test command:
412*e3723e1fSApple OSS Distributions  * skywalk_tests --ignorefail --shutdown --itersecs 1 shutdown
413*e3723e1fSApple OSS Distributions  * Note that in the legacy test, the --itersecs option had a value of 60, but
414*e3723e1fSApple OSS Distributions  * here we used 1. That's because the legacy tests ran a group of tests, but here
415*e3723e1fSApple OSS Distributions  * it is only for a single test.
416*e3723e1fSApple OSS Distributions  */
417*e3723e1fSApple OSS Distributions #define X(test, desc, ...)                           \
418*e3723e1fSApple OSS Distributions 	T_DECL(shutdown_##test, desc,                \
419*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("ignorefail=true"),    \
420*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("shutdown=true"),      \
421*e3723e1fSApple OSS Distributions 	        T_META_ENVVAR("itersecs=1"))         \
422*e3723e1fSApple OSS Distributions 	EXPAND_TO_T_DECL_COMMON(test, desc)
423*e3723e1fSApple OSS Distributions SHUTDOWN_TESTS;
424*e3723e1fSApple OSS Distributions #undef X
425*e3723e1fSApple OSS Distributions 
426*e3723e1fSApple OSS Distributions /*
427*e3723e1fSApple OSS Distributions  * These tests are known to have failure rate > 2% so we turn on extra logging.
428*e3723e1fSApple OSS Distributions  * Uncrustify does not handle T_META_MAYFAIL being used in X macros properly.
429*e3723e1fSApple OSS Distributions  */
430*e3723e1fSApple OSS Distributions /* BEGIN IGNORE CODESTYLE */
431*e3723e1fSApple OSS Distributions #define X(test, desc, ...)                                                \
432*e3723e1fSApple OSS Distributions 	T_DECL(failing_##test, desc,                                      \
433*e3723e1fSApple OSS Distributions 	        T_META_SYSCTL_INT("kern.skywalk.verbose=16492674416640"), \
434*e3723e1fSApple OSS Distributions 	        T_META_MAYFAIL("rdar://126364642, bind call fails with EADDRNOTAVAIL")) \
435*e3723e1fSApple OSS Distributions         EXPAND_TO_T_DECL_COMMON(test, desc)
436*e3723e1fSApple OSS Distributions BATS_FAILING_TESTS;
437*e3723e1fSApple OSS Distributions #undef X
438*e3723e1fSApple OSS Distributions /* END IGNORE CODESTYLE */
439