[NUI][AT-SPI] Add Accessibility.Enabled and .Disabled signals
[platform/core/csapi/tizenfx.git] / coverage.sh
1 #!/bin/bash -e
2
3 SCRIPT_DIR=$(dirname $(readlink -f $0))
4 ROOTDIR=$SCRIPT_DIR
5
6 BUILD_CONF=Debug
7 SLN_NAME=_TizenFX_Cov
8 SLN_FILE=$ROOTDIR/$SLN_NAME.sln
9
10 COV_TOOL_PATH=$ROOTDIR/tools/coverage
11 COV_REPORT_PATH=$ROOTDIR/Artifacts/coverage
12 MINICOVER_PATH=$COV_TOOL_PATH/coverage/minicover_linux
13 TARGET_ASSEMBLY_PATH=/usr/share/dotnet.tizen/framework
14 TARGET_COV_PATH=/home/owner/share/cov
15
16
17 usage() {
18   echo "Usage: $0 [command] [module]"
19   echo "Commands:"
20   echo "    instrument|--instrument|-i : Instrument assemblies to record code coverage."
21   echo "    replace |--replace |-c     : Replace runtime assemblies with intrumented."
22   echo "    report|--report|-r         : Generate report files."
23 }
24
25 check_module() {
26   if [ -z "$1" ]; then
27     echo "No module specified." 1>&2
28     exit 1
29   fi
30
31   local PROJECT_DIR=$ROOTDIR/src/$1
32
33   if [ ! -f $PROJECT_DIR/$1.csproj ]; then
34     echo "No such found $1 module." 1>&2
35     exit 1
36   fi
37
38   echo $PROJECT_DIR
39 }
40
41 update_coverage_tools() {
42   echo "## Update Coverage Tools ##"
43   if [ -d $COV_TOOL_PATH ]; then
44     pushd $COV_TOOL_PATH > /dev/null
45     git fetch origin
46     git reset --hard origin/master
47     popd > /dev/null
48   else
49     git clone https://github.sec.samsung.net/RS8-DotNetTctTools/CSharpCoverageTool $COV_TOOL_PATH
50   fi  
51 }
52
53 public_modules() {
54   find $ROOTDIR/src -maxdepth 1 \
55       -type d ! -name "*.Design" \
56       -not -path $ROOTDIR/src | sort | sed "s:$ROOTDIR/src/::"
57 }
58
59 build() {
60   PROJECT_DIR=$(check_module $1)
61   dotnet build -c $BUILD_CONF $PROJECT_DIR/$1.csproj
62 }
63
64 instrument() {
65   PROJECT_DIR=$(check_module $1)
66   dotnet $MINICOVER_PATH/dotnet-minicover.dll instrument \
67       --workdir $ROOTDIR \
68       --sources "/src/$1/**/*.cs" \
69       --assemblies "/src/$1/bin/$BUILD_CONF/*/$1.dll" \
70       --hits-file $1
71 }
72
73 prepare_replace() {
74   sdb root on
75   sdb shell mount -o remount,rw /
76   sdb shell "rm -f $TARGET_ASSEMBLY_PATH/*.ni.dll"
77   sdb shell "rm -fr $TARGET_COV_PATH"
78   sdb shell "mkdir -p $TARGET_COV_PATH" 
79   sdb push $MINICOVER_PATH/MiniCover.HitServices.dll $TARGET_ASSEMBLY_PATH
80   sdb shell chsmack -a '_' $TARGET_ASSEMBLY_PATH/MiniCover.HitServices.dll
81 }
82
83 replace() {
84   PROJECT_DIR=$(check_module $1)
85   sdb push $PROJECT_DIR/bin/$BUILD_CONF/*/$1.dll $TARGET_ASSEMBLY_PATH
86   sdb shell chsmack -a '_' $TARGET_ASSEMBLY_PATH/$1.dll
87 }
88
89 prepare_report() {
90   rm -fr $COV_REPORT_PATH  
91   mkdir -p $COV_REPORT_PATH
92   sdb pull $TARGET_COV_PATH
93 }
94
95 report() {
96   set +e
97   PROJECT_DIR=$(check_module $1)
98   dotnet $MINICOVER_PATH/dotnet-minicover.dll xmlreport \
99       --threshold 85 --output $1.xml
100   dotnet $COV_TOOL_PATH/coverage/ReportGenerator_4.8.0/netcoreapp2.0/ReportGenerator.dll \
101       -reporttypes:lcov -reports:$1.xml -targetdir:$COV_REPORT_PATH/$1
102   java -jar $COV_TOOL_PATH/coverage/jgenhtml-1.5.jar \
103       $COV_REPORT_PATH/$1/lcov.info -o $COV_REPORT_PATH/$1 --no-branch-coverage
104
105   rm -f $1.xml
106   rm -f $1*.hits
107 }
108
109 cmd_instrument() {
110   build $1
111   instrument $1
112 }
113
114 cmd_replace() {
115   prepare_replace
116   replace $1
117 }
118
119 cmd_report() {
120   prepare_report
121   report $1
122 }
123
124 update_coverage_tools
125
126 cmd=$1; [ $# -gt 0 ] && shift;
127 case "$cmd" in
128   instrument|--instrument|-i) cmd_instrument $@ ;;
129   replace |--replace |-c) cmd_replace $@ ;;
130   report|--report| -r)  cmd_report $@ ;;
131   *) usage ;;
132 esac