将 cmp 与进程替换 (stdout) 一起使用? (Bash)

Using cmp with process substitution (stdout)? (Bash)

对于我们的 class,我们必须制作一个 C 程序,将 MIPS 指令编码为指令字,并将指令字解码为 MIPS 指令。

我已经编写了所有内容并在某些情况下进行了测试,但我想在更大的数据集上进行测试。

我们得到了测试文件:test.asmtest.bin.asm 文件包含 MIPS 指令,.bin 文件包含与这些 MIPS 指令等效的指令字。

我的 decode 函数接收来自 test.bin 的指令字,将它们转换为等效的 MIPS 指令并将其发送到 stdout

我想将解码函数的输出与 test.asm 文件中的 MIPS 指令进行比较,看看它们是否等效(我解码正确)。

我被告知我可以使用带有进程替换的 cmp 命令来比较两者,但我不知道我会在 <(...).

中放入什么

我 运行 我的程序使用: bin/mips -d < test.bin 其中 -d 标志代表 decoding.

我在想也许会是这样,但我不确定:

cmp <(cat test.asm) <(bin/mips -d < test.bin)

我不确定是否使用 cmp file1 file2 格式,但您可以 file1 | cmp file2 这样做:

bin/mips -d test.bin | cmp test.asm

该命令应该有效,但不需要使用 cat 的进程替换,只需将文件名放在那里:

cmp test.asm <(bin/mips -d < test.bin)