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