The direct calculation of the elastic and piezoelectric tensors of solids can be accomplished by treating homogeneous strain within the framework of density-functional perturbation theory. By formulating the energy functional in reduced coordinates, we show that the strain perturbation enters only through metric tensors, and can be treated in a manner exactly paralleling the treatment of other perturbations. We present an analysis of the strain perturbation of the plane-wave pseudopotential functional, including the internal strain terms necessary to treat the atomic-relaxation contributions. Procedures for computationally verifying these expressions by comparison with numerical derivatives of ground-state calculations are described and illustrated.