The presence of a significant amount of gravitational radiation in the early Universe affects the total energy density and hence the expansion rate in the early epoch. In this work, we develop a physical model to connect the number of relativistic degrees of freedom Neff with the amplitude and shape of the primordial tensor power spectrum, and use the cosmic microwave background temperature and polarization data from Planck and the BICEP2/KECK Array and the primordial deuterium measurements from damped Lyman-α systems to constrain this model. We find that with the extra relation ∆ Neff(r ,nt), the tensor-to-scalar ratio r is constrained to be r <0.07 (3 σ C.L.) and the tilt of the tensor power spectrum is nt=-0.01 ±0.31 (1 σ C.L.) for P l a n c k +BICEP 2 +KECK +[D /H ] data. This achieves a much tighter constraint on the tensor spectrum and provides a stringent test for cosmic inflation models. In addition, the current constraint on Neff=3.122 ±0.171 excludes the possibility of a fourth neutrino species at more than 5 σ C.L.