You may need a lung function test if you have: trouble breathing, have a persistent cough, have chronic lung disease, been exposed to substances known to cause lung damage, have a respiratory infection or disease that damages the lungs, an abnormal chest X-ray, or are scheduled for lung surgery.