-->

iPhone Intermittent Network Testing

2020-07-18 10:47发布

问题:

I've seen the "Testing iPhone app with limited network access" (link) question, and while it's a great tip, it's not very helpful in terms of testing the actual performance of a piece of code when used over EDGE. In my experience the network will randomly come in an out of connectedness. I'd like some way to simulate this. I'm thinking of something like how sqlite does automated testing of malloc.

These instrumented mallocs can be set to fail only once and then start working again, or to continue failing after the first failure. OOM tests are done in a loop. On the first iteration of the loop, the instrumented malloc is rigged to fail on the first allocation. Then some SQLite operation is carried out and checks are done to make sure SQLite handled the OOM error correctly. Then the time-to-failure counter on the instrumented malloc is increased by one and the test is repeated. The loop continues until the entire operation runs to completion without ever encountering a simulated OOM failure. Tests like this are run twice, once with the instrumented malloc set to fail only once, and again with the instrumented malloc set to fail continuously after the first failure"

I've done a bit of Googling but I wondered if there was a good tool for doing this. I'd like to simulate with my dev machine as the server and the iPhone connecting via WiFi.

回答1:

Craig Hockenberry posted a script here that will let you test varying levels of network performance using the simulator. It also mentions some tricks for testing on the device itself.



回答2:

You could install Apple's Network Link Conditioner

On Yosemite:

Network Link Conditioner can be found in the "Hardware IO Tools for Xcode" package. This can be downloaded from the Apple Developer Downloads page. Once the download has finished, open the DMG and double-click "Network Link Condition.prefPane" to install (source).

On older versions of OSX:

Mountain Lion / Mavericks: Xcode > Open Developer Tool > More Developer Tools
Lion: /Developer/Applications/Utilities/Network Link Conditioner



回答3:

I had this issue when developing GigGuide.me for iphone.

Wrapping my ipod touch in tinfoil didnt seem to reduce wifi at all, so I had to walk down the street to the edge of my wireless router reach to reproduce the problem!

A fault injection tool would really help here.