From 152e51c7af2624831cc4796e06bf3b72787cc85f Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 10 Sep 2013 15:18:09 -0400 Subject: included-tests: generate binary data from test files for inclusion into test binaries This change moves test data into the binaries rather than reading them from the disk at runtime. Advantages: - Tests become distributable - Cross-compile friendly. Build on one machine and execute in an arbitrary location on another. - Easier testing for backports. Users can verify that tests pass without having to track down corresponding test data. - More trustworthy test results and easier quality assurance as tests make fewer assumptions about their environment. - Tests could theoretically run at client/daemon startup and exit on failure. Disadvantages: - Required 'hexdump' build-dependency. This is a standard bsd tool that should be usable everywhere. It is likely already installed on all build-machines. - Tests can no longer be fudged after build by altering test-data. --- src/Makefile.include | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Makefile.include') diff --git a/src/Makefile.include b/src/Makefile.include index be7da2d35c..d002e8ed6f 100644 --- a/src/Makefile.include +++ b/src/Makefile.include @@ -49,3 +49,19 @@ moc_%.cpp: %.h %.pb.cc %.pb.h: %.proto test -f $(PROTOC) && $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $( $@ + @echo "static unsigned const char $(*F)[] = {" >> $@ + @$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' >> $@ + @echo "};};" >> $@ + @echo "Generated $@" + +%.raw.h: %.raw + @$(MKDIR_P) $(@D) + @echo "namespace alert_tests{" > $@ + @echo "static unsigned const char $(*F)[] = {" >> $@ + @$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' >> $@ + @echo "};};" >> $@ + @echo "Generated $@" -- cgit v1.2.3