1#!/bin/bash
2
3set -e
4
5cd $(dirname $0)
6root_path=$(cd ../../../common; pwd)
7
8# Exclude strings
9exclude_file_list=" $root_path/*/src/*_class_asix*"
10exclude_file_list+=" $root_path/*/src/*_class_audio*"
11exclude_file_list+=" $root_path/*/src/*_class_ccid*"
12exclude_file_list+=" $root_path/*/src/*_class_dfu*"
13exclude_file_list+=" $root_path/*/src/*_class_gser*"
14exclude_file_list+=" $root_path/*/src/*_class_pima*"
15exclude_file_list+=" $root_path/*/src/*_class_rndis*"
16exclude_file_list+=" $root_path/*/src/*_class_printer*"
17exclude_file_list+=" $root_path/*/src/*_class_prolific*"
18exclude_file_list+=" $root_path/*/src/*_class_swar*"
19exclude_file_list+=" $root_path/*/src/*_class_video*"
20exclude_file_list+=" $root_path/*/src/*_hnp_*"
21exclude_file_list+=" $root_path/*/src/*_role_*"
22exclude_file_list+=" $root_path/*/src/ux_utility_set_interrupt_handler.c"
23exclude_file_list+=" $root_path/*/src/*dcd_sim_slave*"
24exclude_file_list+=" $root_path/*/src/*device_class_dpump*"
25exclude_file_list+=" $root_path/*/src/*hcd_sim_host*"
26exclude_file_list+=" $root_path/*/src/*host_class_dpump*"
27exclude_file_list+=" $root_path/*/src/*ux_network_driver*"
28
29# Device HID interrupt OUT related
30exclude_file_list+=" $root_path/*/src/ux_device_class_hid_read.c"
31exclude_file_list+=" $root_path/*/src/ux_device_class_hid_receiver*"
32
33# CB/CBI related
34exclude_file_list+=" $root_path/*/src/*_storage*_cb.c"
35exclude_file_list+=" $root_path/*/src/*_storage*_cbi.c"
36
37# CD/DVD related things
38exclude_file_list+=" $root_path/*/src/*_storage_get_status*"
39exclude_file_list+=" $root_path/*/src/*_storage_get_configuration*"
40exclude_file_list+=" $root_path/*/src/*_storage_get_performance*"
41exclude_file_list+=" $root_path/*/src/*_storage_read_disk_information*"
42exclude_file_list+=" $root_path/*/src/*_storage_report_key*"
43exclude_file_list+=" $root_path/*/src/*_storage_read_dvd*"
44exclude_file_list+=" $root_path/*/src/*_storage_read_toc*"
45
46# Obsolete
47exclude_file_list+=" $root_path/*/src/ux_device_stack_interface_get.c"
48exclude_file_list+=" $root_path/*/src/ux_host_stack_delay_ms.c"
49
50# Host controllers
51exclude_file_list+=" $root_path/usbx_host_controllers/src/*"
52
53# Pictbridge related files
54exclude_file_list+=" $root_path/usbx_pictbridge/src/*"
55
56# Host related files
57exclude_host_list=" $root_path/*/src/*_host_*"
58
59# Device related files
60exclude_device_list=" $root_path/*/src/*_device_*"
61
62# RTOS related files
63exclude_rtos_list=" $root_path/*/src/*_thread*"
64exclude_rtos_list+=" $root_path/*/src/*_event_*"
65exclude_rtos_list+=" $root_path/*/src/*_mutex_*"
66exclude_rtos_list+=" $root_path/*/src/*_semaphore_*"
67exclude_rtos_list+=" $root_path/*/src/*_timer_*"
68
69exclude_rtos_list+=" $root_path/*/src/*_cdc_ecm_*"
70
71exclude_rtos_list+=" $root_path/*/src/*_hub_*"
72
73exclude_rtos_list+=" $root_path/*/src/*_cdc_acm_capabilities_get.c"
74exclude_rtos_list+=" $root_path/*/src/*_cdc_acm_configure.c"
75
76exclude_rtos_list+=" $root_path/*/src/*_hid_configure.c"
77exclude_rtos_list+=" $root_path/*/src/*_hid_descriptor_parse.c"
78exclude_rtos_list+=" $root_path/*/src/*_hid_report_descriptor_get.c"
79
80exclude_rtos_list+=" $root_path/*/src/*_storage_configure.c"
81exclude_rtos_list+=" $root_path/*/src/*_storage_media_mount.c"
82exclude_rtos_list+=" $root_path/*/src/*_storage_media_open.c"
83exclude_rtos_list+=" $root_path/*/src/*_storage_partition_read.c"
84exclude_rtos_list+=" $root_path/*/src/*_storage_transport.c"
85
86# Standalone related files
87exclude_standalone_list=" $root_path/*/src/*_run.c"
88
89if [[ $1 = *"_full_coverage" ]]; then
90
91    exclude_options=""
92else
93
94    exclude_options=""
95    for f in $exclude_file_list;do
96        exclude_options+=" -e $f"
97    done
98
99    if [[ $1 = *"_device_"* ]]; then
100        for f in $exclude_host_list;do
101            exclude_options+=" -e $f"
102        done
103    fi
104
105    if [[ $1 = *"_host_"* ]]; then
106        for f in $exclude_device_list;do
107            exclude_options+=" -e $f"
108        done
109    fi
110
111    if [[ $1 = "standalone_"* ]]; then
112        for f in $exclude_rtos_list;do
113            exclude_options+=" -e $f"
114        done
115    else
116        for f in $exclude_standalone_list;do
117            exclude_options+=" -e $f"
118        done
119    fi
120fi
121
122mkdir -p coverage_report/$1
123gcovr --object-directory=build/$1/usbx/CMakeFiles/usbx.dir/common -r ../../../common $exclude_options --xml-pretty --output coverage_report/$1.xml
124gcovr --object-directory=build/$1/usbx/CMakeFiles/usbx.dir/common -r ../../../common $exclude_options --html --html-details --html-high-threshold 100.0 --output coverage_report/$1/index.html
125