A diagnostic test pattern generation algorithm