| #!/bin/bash |
| #/////////////////////////////////////////////////////////////////////////////// |
| #// Copyright (c) 2000-2019 Ericsson Telecom AB // |
| #// // |
| #// All rights reserved. This program and the accompanying materials // |
| #// are made available under the terms of the Eclipse Public License v2.0 // |
| #// which accompanies this distribution, and is available at // |
| #// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| #/////////////////////////////////////////////////////////////////////////////// |
| echo "cov2ttcn3 version 1.0" |
| |
| FILESTOPATCH=$* |
| |
| if [ ! "${FILESTOPATCH}" ] |
| then |
| echo "Adds coverage detection to TTCN" |
| echo "Usage: cov2ttcn3 <fileListToPatch>" |
| echo "" |
| echo "For automatic coverage patching:" |
| echo " Add TTCN3Coverage.grp to the project. Then" |
| echo " this script is automatically executed in the" |
| echo " bin directory." |
| echo "" |
| echo " The patched code is able to detect the" |
| echo " number of times a TTCN3 source line is" |
| echo " called." |
| echo " The output written to the cov files can" |
| echo " be used to generate coverage statistics." |
| echo " For that use the ttcn3cov tool." |
| |
| #remove the function reference database: |
| if [ -r TTCN3Coverage.fns ] |
| then |
| rm TTCN3Coverage.fns |
| fi |
| exit |
| fi |
| |
| echo "cov2ttcn3: Patching files with coverage detection..." |
| |
| FILESUSED="" |
| |
| for f in ${FILESTOPATCH} |
| do |
| #echo "cov2ttcn3: Processing ${f}..." |
| |
| if [ ! -w $f ] |
| then |
| #echo "compiler_ttcn3cov: ${f} is readonly. Ignored..." |
| continue; |
| fi |
| check="$(grep "ttcn3cov.hh" ${f})" |
| if [ "${check}" ] |
| then |
| echo "cov2ttcn3: ${f} already processed. Ignored..." |
| FILESUSED="${FILESUSED} $f" |
| continue |
| fi |
| gawk -f $(dirname $0)/TTCN3Coverage.awk $f | tee ${f}_ > /dev/null |
| difference="$(diff ${f}_ $f)" |
| #echo ${difference} |
| if [ "${difference}" ] |
| then |
| #echo "cov2ttcn3: Coverage detection is added to ${f}." |
| rm $f |
| mv ${f}_ $f |
| FILESUSED="${FILESUSED} $f" |
| else |
| echo "cov2ttcn3: No coverage info available in: "$f |
| rm ${f}_ |
| fi |
| |
| #break |
| done |
| |
| echo "cov2ttcn3: Updating function reference database" |
| TTCN3COV_FNS="" |
| if [ -r "TTCN3Coverage.fns" ] |
| then |
| TTCN3COV_FNS="TTCN3Coverage.fns" |
| fi |
| gawk -f $(dirname $0)/ExtractFunctions.awk ${FILESUSED} ${TTCN3COV_FNS} > TTCN3Coverage.fns_ |
| if [ ! -r TTCN3Coverage.fns ] |
| then |
| difference="yes" |
| else |
| difference="$(diff TTCN3Coverage.fns_ TTCN3Coverage.fns)" |
| fi |
| #echo ${difference} |
| if [ "${difference}" ] |
| then |
| mv TTCN3Coverage.fns_ TTCN3Coverage.fns |
| echo "cov2ttcn3: Function reference database updated" |
| else |
| rm TTCN3Coverage.fns_ |
| echo "cov2ttcn3: Function reference database is up-to-date" |
| fi |
| |
| |