Test and diagnosis pattern generation for distinguishing stuck-at faults and bridging faults