Skip to content

Commit 0f07133

Browse files
committed
test: Add self-tests for genhtml
Add some tests for checking basic functionality of genhtml. Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent 544a695 commit 0f07133

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed

test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include common.mak
22

3-
TESTDIRS := $(patsubst %/,%,$(dir $(wildcard */Makefile)))
3+
TESTDIRS := $(sort $(patsubst %/,%,$(dir $(wildcard */Makefile))))
44

55
help: info
66

@@ -19,7 +19,7 @@ test:
1919
done
2020

2121
clean:
22-
rm -f *.info *.counts test.log
22+
rm -rf *.info *.counts test.log src/
2323
for TEST in $(TESTDIRS) ; do \
2424
make -C $$TEST clean ; \
2525
done

test/bin/mkinfo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,11 @@ sub main()
885885
}
886886

887887
if (defined($opt_output)) {
888+
if (! -d $opt_output) {
889+
mkdir($opt_output) or
890+
die("$0: Could not create directory ".
891+
"$opt_output: $!\n");
892+
}
888893
$root = abs_path($opt_output)
889894
} else {
890895
$root = "/";

test/common.mak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SIZE := small
2121
CC := gcc
2222

2323
export LCOV := lcov $(LCOVFLAGS)
24+
export GENHTML := genhtml $(LCOVFLAGS)
2425
export PATH := $(TOPDIR)/../bin:$(TOPDIR)/bin:$(PATH)
2526
export LANG := C
2627

@@ -40,7 +41,7 @@ clean_common:
4041
echo " CLEAN $(patsubst %/,%,$(RELDIR))"
4142

4243
$(INFOFILES) $(COUNTFILES):
43-
cd $(TOPDIR) && mkinfo profiles/$(SIZE)
44+
cd $(TOPDIR) && mkinfo profiles/$(SIZE) -o src/
4445

4546
ifneq ($(V),2)
4647
.SILENT:

test/genhtml_output/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
include ../common.mak
2+
3+
GENHTML_TEST := ./genhtml_test
4+
5+
TESTS := genhtml_output_zero genhtml_output_full genhtml_output_target \
6+
genhtml_output_part1 genhtml_output_part2 genhtml_output_combined
7+
8+
test: $(TESTS)
9+
10+
genhtml_output_zero:
11+
@test_run genhtml_output_zero $(GENHTML) $(ZEROINFO) -o out_zero/
12+
13+
genhtml_output_full:
14+
@test_run genhtml_output_full $(GENHTML) $(FULLINFO) -o out_full/
15+
16+
genhtml_output_target:
17+
@test_run genhtml_output_target $(GENHTML) $(TARGETINFO) -o out_target/
18+
19+
genhtml_output_part1:
20+
@test_run genhtml_output_part1 $(GENHTML) $(PART1INFO) -o out_part1/
21+
22+
genhtml_output_part2:
23+
@test_run genhtml_output_part2 $(GENHTML) $(PART2INFO) -o out_part2/
24+
25+
genhtml_output_combined: genhtml_output_target
26+
@test_run genhtml_output_combined $(GENHTML_TEST) $(TARGETINFO) $(PART1INFO) $(PART2INFO)
27+
28+
clean:
29+
rm -rf out_*/
30+
31+
.PHONY: test $(TESTS) clean

test/genhtml_output/genhtml_test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Copyright IBM Corp. 2017
4+
#
5+
# Usage: genhtml_test <ref-file> <file1> [<file2>...]
6+
#
7+
# Compare genhtml output of a reference coverage data file with that of
8+
# a combination of multiple files.
9+
#
10+
11+
function die()
12+
{
13+
echo "Error: $@" >&2
14+
exit 1
15+
}
16+
17+
GENHTMLFLAGS="-t title"
18+
REFFILE=$1
19+
shift
20+
21+
if [ -z "$REFFILE" -o -z "$*" ] ; then
22+
echo "Usage: $0 <ref-file> <file1> [<file2>...]" >&2
23+
exit 2
24+
fi
25+
26+
OUTREF="out_$(basename $REFFILE .info)"
27+
OUTCOMBINED="out_combined"
28+
29+
$GENHTML $GENHTMLFLAGS "$REFFILE" -o "$OUTREF" || \
30+
die "Could not generate HTML for reference file"
31+
32+
$GENHTML $GENHTMLFLAGS "$@" -o "$OUTCOMBINED" || \
33+
die "Could not generate HTML for combined files"
34+
35+
diff -ur "$OUTREF" "$OUTCOMBINED" -I "headerValue" || \
36+
die "Mismatch in generated output"

0 commit comments

Comments
 (0)