asmtests = [ ("test aa", "nop", "90", 1), ("test aa", "mov ax, 0", "B80000", 1), ("test aa", "mov ax, 1234", "B83412", 1), ("test aa", "mov ax, (26)", "B82600", 1), ("test aa", "mov ax, (#38)", "B82600", 1), ("test aa", "jmp 100", "EBFE", 1), ("test aa", "jmp near 100", "E9FDFF", 1), ("test aa fail", "jmp near 100", "90", 0), ("test aa fail", "jmp xyz", "", 0), ] for (msg, inst, code, success) in asmtests: with self.subTest(msg = msg + ": " + inst): self.do_read() if self.debug: print(self.buffer) print("msg=%s inst=%s code=%s success=%d" % (msg, inst, code, success)) self.buffer = "" actuallysucceeded = 0 try: os.write(self.m, ("a 100\r%s\r.\r" % inst).encode()) os.write(self.m, b"u 100 l 1\r") time.sleep(0.05) self.do_read() self.assertNotRegex(self.buffer, r"\^ Error", "error in assembling") self.assertRegex(self.buffer, r"\r\n[0-9A-Fa-f:]{9,13} %s " % code, "code mismatch") actuallysucceeded = 1 except AssertionError as e: if success: raise e else: pass if actuallysucceeded and not success: raise AssertionError("unexpected success")