File tree Expand file tree Collapse file tree 12 files changed +157
-9
lines changed Expand file tree Collapse file tree 12 files changed +157
-9
lines changed Original file line number Diff line number Diff line change 11
11
echo " "
12
12
echo " Available make variables:"
13
13
echo " SIZE : specify size of test data (small, medium, large)"
14
- echo " V : specify level of verbosity (0, 1)"
14
+ echo " V : specify level of verbosity (0, 1, 2 )"
15
15
16
16
test :
17
17
for TEST in $( TESTDIRS) ; do \
Original file line number Diff line number Diff line change @@ -178,12 +178,16 @@ sub main()
178
178
my $tn = " " ;
179
179
my %allfiles ;
180
180
181
+ $multi = 1 if (!defined ($multi ));
181
182
if (!defined ($infofile )) {
182
- die (" Usage: $0 <coverage-data-file> [<multiplier>]\n " );
183
+ $infofile = " standard input" ;
184
+ warn (" $0 : Reading data from standard input\n " );
185
+ open ($fd , " <&STDIN" ) or
186
+ die (" $0 : Could not duplicated stdin: $! \n " );
187
+ } else {
188
+ open ($fd , " <" , $infofile ) or
189
+ die (" $0 : Could not open $infofile : $! \n " );
183
190
}
184
- $multi = 1 if (!defined ($multi ));
185
-
186
- open ($fd , " <" , $infofile ) or die (" $0 : Could not open $infofile : $! \n " );
187
191
188
192
# Register starting positions of data sets
189
193
while (my $line = <$fd >) {
Original file line number Diff line number Diff line change 83
83
# Show log excerpt on failure or if requested
84
84
if [ $RC -ne 0 -o " $V " == " 1" ] ; then
85
85
LEN=$( tail -c " +$POS " " $LOGFILE " | wc -l)
86
- if [ " $LEN " -gt " $EXCERPTLEN " ] ; then
86
+ if [ " $LEN " -gt " $EXCERPTLEN " -a " $V " != " 1 " ] ; then
87
87
tail -c " +$POS " " $LOGFILE " | head -n $EXCERPTLEN | t_indent
88
88
let LEN=$LEN -$EXCERPTLEN
89
89
echo " ..."
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ COUNTFILES := $(ZEROCOUNTS) $(FULLCOUNTS) $(TARGETCOUNTS) $(PART1COUNTS) \
18
18
LCOVRC := $(TOPDIR ) lcovrc
19
19
LCOVFLAGS := --config-file $(LCOVRC )
20
20
SIZE := small
21
+ CC := gcc
21
22
22
23
export LCOV := lcov $(LCOVFLAGS )
23
24
export PATH := $(TOPDIR ) /../bin:$(TOPDIR ) /bin:$(PATH )
@@ -41,6 +42,8 @@ clean_common:
41
42
$(INFOFILES ) $(COUNTFILES ) :
42
43
cd $(TOPDIR ) && mkinfo profiles/$(SIZE )
43
44
45
+ ifneq ($(V ) ,2)
44
46
.SILENT :
47
+ endif
45
48
46
49
.PHONY : all init exit prepare clean clean_common
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ include ../common.mak
3
3
ADDTEST := ./add_test
4
4
5
5
TESTS := lcov_add_zero lcov_add_zero2 lcov_add_full lcov_add_full2 \
6
- lcov_add_part lcov_add_part2 lcov_add_concatenated
6
+ lcov_add_part lcov_add_part2 lcov_add_concatenated4
7
7
8
8
9
9
test : $(TESTS )
@@ -35,7 +35,7 @@ lcov_add_part2:
35
35
# should be same as target file
36
36
test_run lcov_add_part2 $(ADDTEST ) 1 " $( TARGETINFO) " " $( PART1INFO) " " $( PART2INFO) "
37
37
38
- lcov_add_concatenated :
38
+ lcov_add_concatenated4 :
39
39
# Add coverage file that consists of 4 concatenation of target files
40
40
# and reduce counts to 1/4 - output should be the same as input
41
41
cat $(TARGETINFO ) $(TARGETINFO ) $(TARGETINFO ) $(TARGETINFO ) > concatenated.info
Original file line number Diff line number Diff line change 41
41
42
42
echo " Comparing with reference..."
43
43
if ! diff -u " $REFFILE " " $SORTFILE " ; then
44
- echo " Error: Result of addition differs from reference file" >&2
44
+ echo " Error: Result of combination differs from reference file" >&2
45
45
exit 1
46
46
fi
Original file line number Diff line number Diff line change
1
+ include ../common.mak
2
+
3
+ test :
4
+ test_run lcov_diff_apply ./diff_test
5
+
6
+ clean :
7
+ make -C old clean
8
+ make -C new clean
9
+ rm -f * .info diff
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Copyright IBM Corp. 2017
4
+ #
5
+ # Usage: diff_test
6
+ #
7
+ # Check lcov's diff function:
8
+ # - Compile two slightly different test programs
9
+ # - Run the programs and collect coverage data
10
+ # - Generate a patch containing the difference between the source code
11
+ # - Apply the patch to the coverage data
12
+ # - Compare the resulting patched coverage data file with the data from the
13
+ # patched source file
14
+ #
15
+
16
+ function die()
17
+ {
18
+ echo " Error: $@ " >&2
19
+ exit 1
20
+ }
21
+
22
+ make -C old || die " Failed to compile old source"
23
+ make -C new || die " Failed to compile new source"
24
+ diff -u $PWD /old/prog.c $PWD /new/prog.c > diff
25
+
26
+ $LCOV --diff old/prog.info diff --convert-filenames -o patched.info -t bla || \
27
+ die " Failed to apply patch to coverage data file"
28
+ norminfo new/prog.info > new_normalized.info
29
+ norminfo patched.info > patched_normalized.info
30
+ sed -i -e ' s/^TN:.*$/TN:/' patched_normalized.info
31
+
32
+ diff -u patched_normalized.info new_normalized.info || \
33
+ die " Mismatch in patched coverage data file"
34
+
35
+ echo " Patched coverage data file matches expected file"
Original file line number Diff line number Diff line change
1
+ prog.info :
2
+
3
+ include ../../common.mak
4
+
5
+ prog.info : prog.gcda
6
+ $(LCOV ) -c -d . -o prog.info
7
+
8
+ prog.gcda : prog
9
+ ./prog || true
10
+
11
+ prog : prog.c
12
+ $(CC ) prog.c -o prog --coverage
13
+
14
+ clean :
15
+ rm -f prog prog.gcda prog.gcno prog.info
16
+
17
+ .PHONY : all clean
Original file line number Diff line number Diff line change
1
+
2
+
3
+
4
+ int fn (int x )
5
+ {
6
+ switch (x ) {
7
+ case -1 : return 0 ;
8
+
9
+
10
+ case 0 : return 2 ;
11
+ case 2 : return 3 ;
12
+
13
+
14
+ case 12 : return 7 ;
15
+ default : return 255 ;
16
+ }
17
+
18
+
19
+
20
+ }
21
+
22
+ int fn2 ()
23
+ {
24
+
25
+
26
+ return 7 ;
27
+ }
28
+
29
+
30
+
31
+ int main (int argc , char * argv [])
32
+ {
33
+
34
+
35
+ if (argc > 1 )
36
+ return fn (argc );
37
+
38
+ return fn2 ();
39
+
40
+
41
+ }
You can’t perform that action at this time.
0 commit comments