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