You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/10/26 07:47:20 UTC

[GitHub] [incubator-nuttx] Gary-Hobson opened a new pull request #4730: tool: add code coverage tool

Gary-Hobson opened a new pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730


   ## Summary
   add code coverage tool,  use tools/gcov.sh to generate code coverage report 
   
   ## Impact
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Gary-Hobson commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Gary-Hobson commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r737069795



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	OBJS += *.gcno *.gcda

Review comment:
       You're right. I made some updates




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 merged pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 merged pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Gary-Hobson commented on pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Gary-Hobson commented on pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#issuecomment-954808398


   > LGTM. Please squash the commits.
   
   Thank you for your reminder Now it has been squash ~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736376155



##########
File path: arch/Kconfig
##########
@@ -217,6 +217,14 @@ config ARCH_SIZET_LONG
 		C++ library routines because the NuttX size_t might not have
 		the same underlying type as your toolchain's size_t.
 
+config ARCH_COVERAGE
+	bool "arch coverage"

Review comment:
       ```suggestion
   	bool "Enable code coverage analysis"
   ```
   Suggestion for improving the prompt string.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736376155



##########
File path: arch/Kconfig
##########
@@ -217,6 +217,14 @@ config ARCH_SIZET_LONG
 		C++ library routines because the NuttX size_t might not have
 		the same underlying type as your toolchain's size_t.
 
+config ARCH_COVERAGE
+	bool "arch coverage"

Review comment:
       ```suggestion
   	bool "Enable code coverage"
   ```
   Suggestion for improving the prompt string.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736599102



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	OBJS += *.gcno *.gcda

Review comment:
       > Besides, I feel like this is more of a hack, gcno and gcda are not "object" files.
   
   I think what can work here is just a simple separate `EXTRA` (or other name) variable, to hold these kind of files.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Gary-Hobson commented on pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Gary-Hobson commented on pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#issuecomment-951884858


   @gustavonihei  
   You need to run `nuttx` once first.
   I've added checks and hints to the script


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r737271273



##########
File path: tools/Config.mk
##########
@@ -462,7 +462,7 @@ endef
 # CLEAN - Default clean target
 
 ifeq ($(CONFIG_ARCH_COVERAGE),y)
-	OBJS += *.gcno *.gcda
+	EXTRA = *.gcno *.gcda

Review comment:
       modify the related patch directly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r737267078



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	EXTRA = *.gcno *.gcda
+endif

Review comment:
       ```suggestion
   EXTRA=
   
   ifeq ($(CONFIG_ARCH_COVERAGE),y)
   	EXTRA += *.gcno *.gcda
   endif
   ```
   
   I think this will fail if `CONFIG_ARCH_CONVERAGE` is not defined.  We need an empty definition of `EXTRA`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Gary-Hobson commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Gary-Hobson commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r737419592



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	EXTRA = *.gcno *.gcda
+endif

Review comment:
       I closed "coverage" and ran the program without any errors.
   
   In my opinion, the undefined variable in the makefile is null, so this will not affect the operation of the command




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#issuecomment-951884278


   > I tested with `sim:nsh`, but `tools/gcov.sh` failed to find the `.gcno` files:
   > 
   > ```
   > $ ./tools/gcov.sh 
   > Capturing coverage data from /home/nihei/Projects/NuttX
   > Found gcov version: 10.3.0
   > Using intermediate gcov format
   > Scanning /home/nihei/Projects/NuttX for .gcda files ...
   > Found 4 data files in /home/nihei/Projects/NuttX
   > Processing tools/mkversion.gcda
   > Processing tools/mkconfig.gcda
   > Processing tools/cfgdefine.gcda
   > Processing tools/mkdeps.gcda
   > Finished .info-file creation
   > Reading data file coverage.info
   > Found 4 entries.
   > ```
   > 
   > I am not used to running `lcov`, but it seems some step might be missing for the tool setup.
   
   Well, now I felt a bit stupid. After your latest commit I realized that the coverage information is only generated after the execution haha


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r739114870



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	EXTRA = *.gcno *.gcda
+endif

Review comment:
       That's right, it won't fail.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#issuecomment-951801383


   I tested with `sim:nsh`, but `tools/gcov.sh` failed to find the `.gcno` files:
   ```
   $ ./tools/gcov.sh 
   Capturing coverage data from /home/nihei/Projects/NuttX
   Found gcov version: 10.3.0
   Using intermediate gcov format
   Scanning /home/nihei/Projects/NuttX for .gcda files ...
   Found 4 data files in /home/nihei/Projects/NuttX
   Processing tools/mkversion.gcda
   Processing tools/mkconfig.gcda
   Processing tools/cfgdefine.gcda
   Processing tools/mkdeps.gcda
   Finished .info-file creation
   Reading data file coverage.info
   Found 4 entries.
   ```
   I am not used to running `lcov`, but it seems some step might be missing for the tool setup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736476925



##########
File path: tools/gcov.sh
##########
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+# tools/gcov.sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ROOT_DIR=$(cd $(dirname $0)/../../; pwd)

Review comment:
       Could you please run ShellCheck (https://www.shellcheck.net/) on this script?
   It is currently reporting several warnings and some of them might be interesting to address.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#issuecomment-952653022


   @Gary-Hobson please rebase and fix the conflict.   For some reason I can't even start the checks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736586263



##########
File path: tools/Config.mk
##########
@@ -461,6 +461,10 @@ endef
 
 # CLEAN - Default clean target
 
+ifeq ($(CONFIG_ARCH_COVERAGE),y)
+	OBJS += *.gcno *.gcda

Review comment:
       Is this working properly?  `OBJS` will be overwritten by each subfolders Makefile which will lead to not deleting these files.  
   Besides, I feel like this is more of a hack, gcno and gcda are not "object" files.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #4730: tool: add code coverage tool

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #4730:
URL: https://github.com/apache/incubator-nuttx/pull/4730#discussion_r736552109



##########
File path: tools/gcov.sh
##########
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+# tools/gcov.sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ROOT_DIR=$(cd $(dirname $0)/../../; pwd)
+
+if [ $# == 1 ]; then
+    GCOV_DIR=$1
+else
+    GCOV_DIR=${ROOT_DIR}/gcov
+fi
+
+files=$(find -name "*.gcda" 2> /dev/null | wc -l)
+if [ "$files" == "0" ] ;then
+    echo "Please run ./nuttx before using gcov.sh to generate the coverage report"
+    exit 1
+fi
+
+type lcov
+if [ $? -ne 0 ]; then
+    echo "Code coverage generation tool is not detected, please execute \"apt get install lcov\""

Review comment:
       ```suggestion
       echo "Code coverage generation tool not detected, please install lcov"
   ```
   
   `apt get install` is too specific to an OS/distribution.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org