Thanks for the snippets above, they're really helpful!
FWIW, one can generate that test sample a lot faster using numpy as follows:
import numpy as np
th=np.linspace(0, 2*np.pi*freq*duration, numSamples, endpoint=False)
data = (32767*volume/100.0*np.sin(th)).astype(np.int16)