我有一个运行stdin和stdout的交互式程序.
我需要创建将X发送到它的stdin的包装器,检查它是否打印Y然后
将包装器的stdin和stdout重定向到程序的stdin和stdout,就像直接执行程序一样.
我需要创建将X发送到它的stdin的包装器,检查它是否打印Y然后
将包装器的stdin和stdout重定向到程序的stdin和stdout,就像直接执行程序一样.
怎么实现这个? X和Y可以硬编码.击?Python?
编辑:我无法运行程序两次.它必须是一个例子.
这是伪代码:
def wrap(cmd,in,expected_out): p = exec(cmd) p.writeToStdin(in) out = p.readBytes (expected_out.size()) if (out != expected_out) return fail; # if the above 4 lines would be absent or (in == "" and out == "") # then this wrapper would be exactly like direct execution of cmd connectpipe (p.stdout,stdout) connectpipe (stdin,p.stdin) p.continueExecution()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。