mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 12:11:27 -05:00 
			
		
		
		
	Save the coverage report to a file
Save the "Test Report Summary" to a file. This can help both CI scripts and human readers who want the summary after the fact without having to copy the console output. Take care to exit with a nonzero status if there is a failure while generating the test report summary. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
		
							parent
							
								
									bbced87390
								
							
						
					
					
						commit
						fc70b5252b
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -18,6 +18,7 @@ Testing
 | 
			
		||||
Coverage
 | 
			
		||||
*.gcno
 | 
			
		||||
*.gcda
 | 
			
		||||
coverage-summary.txt
 | 
			
		||||
 | 
			
		||||
# generated by scripts/memory.sh
 | 
			
		||||
massif-*
 | 
			
		||||
 | 
			
		||||
@ -156,6 +156,8 @@ echo "========================================================================="
 | 
			
		||||
echo "Test Report Summary"
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    cd tests
 | 
			
		||||
 | 
			
		||||
    # Step 4a - Unit tests
 | 
			
		||||
@ -255,17 +257,24 @@ FUNCS_PERCENT="$(($FUNCS_PERCENT/10)).$(($FUNCS_PERCENT-($FUNCS_PERCENT/10)*10))
 | 
			
		||||
    BRANCHES_PERCENT=$((1000*$BRANCHES_TESTED/$BRANCHES_TOTAL))
 | 
			
		||||
    BRANCHES_PERCENT="$(($BRANCHES_PERCENT/10)).$(($BRANCHES_PERCENT-($BRANCHES_PERCENT/10)*10))"
 | 
			
		||||
 | 
			
		||||
echo "Lines Tested       : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%"
 | 
			
		||||
echo "Functions Tested   : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%"
 | 
			
		||||
echo "Branches Tested    : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
    rm unit-test-$TEST_OUTPUT
 | 
			
		||||
    rm sys-test-$TEST_OUTPUT
 | 
			
		||||
    rm compat-test-$TEST_OUTPUT
 | 
			
		||||
    rm cov-$TEST_OUTPUT
 | 
			
		||||
 | 
			
		||||
cd ..
 | 
			
		||||
    echo "Lines Tested       : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%"
 | 
			
		||||
    echo "Functions Tested   : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%"
 | 
			
		||||
    echo "Branches Tested    : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
 | 
			
		||||
    echo
 | 
			
		||||
 | 
			
		||||
    # If there was a failure, remind the reader here. This also ensures that
 | 
			
		||||
    # the coverage summary ends with a distinctive mark so that this script
 | 
			
		||||
    # knows to exit with a failure status.
 | 
			
		||||
    if [ $TOTAL_FAIL -ne 0 ]; then
 | 
			
		||||
        echo "Note: $TOTAL_FAIL failures."
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
} | tee coverage-summary.txt
 | 
			
		||||
 | 
			
		||||
make clean
 | 
			
		||||
 | 
			
		||||
@ -273,6 +282,13 @@ if [ -f "$CONFIG_BAK" ]; then
 | 
			
		||||
    mv "$CONFIG_BAK" "$CONFIG_H"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ $TOTAL_FAIL -ne 0 ]; then
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
# If the coverage summary doesn't end with the expected last two lines
 | 
			
		||||
# ("Branches Tested" and a blank line), either there was an error while
 | 
			
		||||
# creating the coverage summary or the coverage summary reported failures.
 | 
			
		||||
newline='
 | 
			
		||||
'
 | 
			
		||||
case "$(tail -n2 coverage-summary.txt)" in
 | 
			
		||||
    *"$newline"*) exit 1;;
 | 
			
		||||
    "Branches Tested"*) :;;
 | 
			
		||||
    *) exit 1;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user