Skip to contentSkip to conversation

RFC: checkpatch: Add a check for tests needed for uclasses

PATCH New Simon Glass 2 participants 5 messages Nov 18, 2018 – Nov 24, 2018 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: checkpatch: Add a check for tests needed for uclasses

This is an experimental check for adding new uclasses without a test.

I am not sure of the best way to add U-Boot-specific tests, although in this case, it would not fire on Linux.

---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +7 -0
index 373094e59ef..2f9edb429d5 100755
@@ -3033,6 +3033,13 @@ sub process {
 			     "adding a line without newline at end of file\n" . $herecurr);
 		}
 
+		# ask for a test if a new uclass ID is added
+		if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+			WARN("NEW_UCLASS",
+			     "Possible new uclass - make sure to add a test in test/dm/<name>.c\n" . $herecurr);
+		}
+
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#1 lore raw

PATCH 1/1 RFC: checkpatch: Add a check for tests needed for uclasses

Quoted 20 lines · Simon Glass

This is an experimental check for adding new uclasses without a test.

I am not sure of the best way to add U-Boot-specific tests, although in this case, it would not fire on Linux.

---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +0 -0
index 373094e59ef..2f9edb429d5 100755
@@ -3033,6 +3033,13 @@ sub process {
 			     "adding a line without newline at end of file\n" . $herecurr);
 		}
 

scripts/checkpatch.pl sub process { · line 3045

Quoted 10 lines
scripts/checkpatch.pl +7 -0
+		# ask for a test if a new uclass ID is added
+		if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+			WARN("NEW_UCLASS",
+			     "Possible new uclass - make sure to add a test in test/dm/<name>.c\n" . $herecurr);
+		}
+
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 

I would prefer if this script were a verbatim copy of the Linux upstream. Joe Perches is continually working on it. So let's update to 4.20 instead.

Tests are needed for any new functionality. Nothing special about u-classes here. The reviewer/custodian should take care that this is observed.

Best regards

Heinrich

#2 lore raw

PATCH 1/1 RFC: checkpatch: Add a check for tests needed for uclasses

Hi Heinrich,

Quoted 21 lines · Heinrich Schuchardt
Quoted 19 lines · Simon Glass

This is an experimental check for adding new uclasses without a test.

I am not sure of the best way to add U-Boot-specific tests, although in this case, it would not fire on Linux.

---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +0 -0
index 373094e59ef..2f9edb429d5 100755
@@ -3033,6 +3033,13 @@ sub process {
                           "adding a line without newline at end of file\n" . $herecurr);
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 3045

Quoted 11 lines
scripts/checkpatch.pl +7 -0
+             # ask for a test if a new uclass ID is added
+             if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+                     WARN("NEW_UCLASS",
+                          "Possible new uclass - make sure to add a test in test/dm/<name>.c\n" . $herecurr);
+             }
+
+
 # check we are in a valid source file C or perl if not then ignore this hunk
              next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 

I would prefer if this script were a verbatim copy of the Linux upstream. Joe Perches is continually working on it. So let's update to 4.20 instead.

That's fine, but is not the point of this patch.

Quoted 4 lines

Tests are needed for any new functionality. Nothing special about u-classes here. The reviewer/custodian should take care that this is observed.

We have similar checks for updating MAINTAINERS files when adding/removing files. I think it is better for people to find out that they need to add tests before they send their patches.

Also we have 73 uclasses but not all have tests, so some have clearly slipped through the cracks.

Regards,
Simon

#3 lore raw

PATCH 1/1 RFC: checkpatch: Add a check for tests needed for uclasses

Quoted 40 lines · Simon Glass

Hi Heinrich,

Quoted 21 lines · Heinrich Schuchardt
Quoted 19 lines · Simon Glass

This is an experimental check for adding new uclasses without a test.

I am not sure of the best way to add U-Boot-specific tests, although in this case, it would not fire on Linux.

---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +0 -0
index 373094e59ef..2f9edb429d5 100755
@@ -3033,6 +3033,13 @@ sub process {
                           "adding a line without newline at end of file\n" . $herecurr);
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 3045

Quoted 11 lines
scripts/checkpatch.pl +7 -0
+             # ask for a test if a new uclass ID is added
+             if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+                     WARN("NEW_UCLASS",
+                          "Possible new uclass - make sure to add a test in test/dm/<name>.c\n" . $herecurr);
+             }
+
+
 # check we are in a valid source file C or perl if not then ignore this hunk
              next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 

I would prefer if this script were a verbatim copy of the Linux upstream. Joe Perches is continually working on it. So let's update to 4.20 instead.

Quoted 1 line

That's fine, but is not the point of this patch.

Your patch is making updates harder?

Quoted 9 lines
Quoted 5 lines

Tests are needed for any new functionality. Nothing special about u-classes here. The reviewer/custodian should take care that this is observed.

We have similar checks for updating MAINTAINERS files when adding/removing files. I think it is better for people to find out that they need to add tests before they send their patches.

This is an upstream function.

Quoted 3 lines

Also we have 73 uclasses but not all have tests, so some have clearly slipped through the cracks.

This is not specific for u-classes. With the same reasoning you could warn on all patches creating a C function, "Did you create a test?" and for any other change, "Did you update the tests?".

I am with you in that we should aim for 100 % test coverage. But I don't like nag messages.

Regards

Heinrich

Quoted 4 lines

Regards,
Simon

#4 lore raw

PATCH 1/1 RFC: checkpatch: Add a check for tests needed for uclasses

Hi Heinrich,

Quoted 42 lines · Heinrich Schuchardt
Quoted 40 lines · Simon Glass

Hi Heinrich,

Quoted 36 lines · Heinrich Schuchardt
Quoted 20 lines · Simon Glass

This is an experimental check for adding new uclasses without a test.

I am not sure of the best way to add U-Boot-specific tests, although in this case, it would not fire on Linux.

---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +0 -0
index 373094e59ef..2f9edb429d5 100755
@@ -3033,6 +3033,13 @@ sub process {
                           "adding a line without newline at end of file\n" . $herecurr);
              }
 

scripts/checkpatch.pl sub process { · line 3045

Quoted 10 lines
scripts/checkpatch.pl +7 -0
+             # ask for a test if a new uclass ID is added
+             if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+                     WARN("NEW_UCLASS",
+                          "Possible new uclass - make sure to add a test in test/dm/<name>.c\n" . $herecurr);
+             }
+
+
 # check we are in a valid source file C or perl if not then ignore this hunk
              next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 

I would prefer if this script were a verbatim copy of the Linux upstream. Joe Perches is continually working on it. So let's update to 4.20 instead.

Quoted 3 lines
Quoted 1 line

That's fine, but is not the point of this patch.

Your patch is making updates harder?

Well, perhaps my patch will be accepted upstream. I am not sure how we are supposed to patch this file in downstream projects.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Tests are needed for any new functionality. Nothing special about u-classes here. The reviewer/custodian should take care that this is observed.

Quoted 5 lines
Quoted 3 lines

We have similar checks for updating MAINTAINERS files when adding/removing files. I think it is better for people to find out that they need to add tests before they send their patches.

This is an upstream function.

Do you mean we should not have it?

Quoted 11 lines
Quoted 4 lines

Also we have 73 uclasses but not all have tests, so some have clearly slipped through the cracks.

This is not specific for u-classes. With the same reasoning you could warn on all patches creating a C function, "Did you create a test?" and for any other change, "Did you update the tests?".

I am with you in that we should aim for 100 % test coverage. But I don't like nag messages.

Isn't this the whole point of checkpatch? We are trying to get the v1 series to be a close as possible to perfect, to avoid wasting reviewer time, which is extremely precious, particularly in U-Boot.

Regards,
Simon