# Remove gcda for meaningless file (CMake's autogenerated)
find . -name "CMakeCCompilerId*.gcda" -delete
find . -name "CMakeCXXCompilerId*.gcda" -delete
-# Generate report
+# Generate report and exclude files which are generated by gdbus-codegen and external files in /usr/*.
# TODO: the --no-external option is removed to include machine-learning-agent related source files.
# Restore this option when there is proper way to include those source files.
pushd %{builddir}
+# Set different lcov options for Tizen/lcov versions.
+%if 0%{tizen_version_major} >= 9
lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd) --ignore-errors mismatch
-# Exclude generated files (e.g., Orc, Protobuf) and device-dependent files.
-# Exclude files which are generated by gdbus-codegen and external files in /usr/*.
lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info --ignore-errors graph,unused
+%else
+lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd)
+lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info
+%endif # tizen_version_major >= 9
# Visualize the report
genhtml -o result unittest-filtered.info -t "ML-Agent %{version}-%{release} ${VCS}" --ignore-errors source -p ${RPM_BUILD_DIR}