Factor out some common code in smoke.py