Search code examples
iosmacostestingwifi

Using Mac Hotspot for automated testing of mobile devices


I've used Apple's Network Link Conditioner to simulate a degraded network for my iOS device testing. But I'd like to set up some automated testing where a Mac's wifi hotspot is used as the mobile device-under-test's wifi connection. I'd like to be able to programmatically disable/enable the wifi network as well as disable/enable the networks upstream connection, perhaps under shell control. Any notion on how to achieve this?


Solution

  • On my MacBook, which has no built-in Ethernet, the following commands turns the Wi-Fi radio off and on:

    sudo ifconfig en0 down

    sudo ifconfig en0 up

    If you enable Internet Connection Sharing you can use these commands to disable and enable Wi-Fi, and the backhaul interface as well, you'll just need to figure out which en device is which.

    For finer grained control over the Wi-Fi radio check out the airport tool:

    /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport