如何在unix环境中使用.in和.out文件进行测试
How to use .in and .out files for testing in a unix environment?
我有C++程序,还有一堆.in和.out文件用于预制测试。我想知道如何执行我的c++程序并将其输入其中。
我假设您有一个文件列表,如test0.in
和一个corrosconding test1.out
。也许你想要这样的Makefile:
#Put rules/variables to actually make the program
SRC = test.cpp
TARGET = program
INPUTS = $(shell ls *.in)
OUTPUTS = $(patsubst %.in, %.out, $(INPUTS))
TESTS = $(patsubst %.in, %.test, $(INPUTS))
#This build rule is just for showcase. You will probably need your own, more sophisticated build rules
$(TARGET): $(SRC)
g++ $^ -o $@ -std=c++11
.PHONY: test
test: $(TESTS)
%.test : %.in %.out $(TARGET)
@./$(TARGET) < $*.in > $@;
@if cmp -s $@ $*.out; then
echo "PASS: $*";
else
echo "FAIL: $*";
fi
@rm $@
然后,只需键入make test -j
进行多线程测试。
相关文章:
- .cpp和.h文件中的模板专用化声明
- -bash:/a.out:无法执行二进制文件:Exec格式错误
- 为什么 .out 文件是十六进制而不是二进制
- g++ 不创建"a.out"文件
- 如何将文件写入当前目录而不是Bazel-Out
- 为什么PHP的Shell_exec没有给出某些A.Out文件的输出
- g++.exe:error:libgomp-1.dll:没有这样的文件或目录;make:***[Out release]
- Android Cmake编译器正在生成带有额外前缀和符号后缀的.out文件
- 尝试同时写入 std:out 和文件
- 如何通过键入 "a.out < textfilename.txt" 让 .out 文件通过终端读取文本文件
- 什么可能导致错误:"Fatal Error: Out of memory - aborting"简单地包含头文件?
- a.out Linux 可执行文件是哪个程序
- 如何将llvm::out()重定向到文件
- 在 C++ 文件上的 Windows 环境中运行 Unix 类似命令"./a.out <data.txt"
- 可以在windows中运行.out文件吗
- 编译器g++不能创建a.out文件
- 读/写同一个文件(获取gmon.out)
- 将打开的文件的ios_base从'out'更改为'app'而不关闭文件
- 如何在unix环境中使用.in和.out文件进行测试
- 为什么编译文件时文件名为"a.out" C++?