A Termination Test for Logic Programs