Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #19128 #19133
Browse files Browse the repository at this point in the history
19128: boards: common: stdio_cdc_acm: let tests wait a bit for serial port r=aabadie a=miri64



19133: makefiles/utils/strings.mk: Fix version_is_greater_or_equal r=maribu a=maribu

### Contribution description

The Makefile function `version_is_greater_or_equal` is used to check if a version of GNU Make is at least the required one. However, it has the built-in assumption the version numbers have to format x.y.z, but Alpine Linux currently ships GNU Make 4.4. This results in `$(call _pad_number,3,)` which runs `printf '$03d' ''` in the shell, which is not valid.

This fixes the issue by making `_pad_number` more robust by fall back to printing `0` with the given padding, if the number given to print is empty.

### Testing procedure

Append

```Makefile

$(info A=$(call version_is_greater_or_equal,4.2.0,4.2.0))
$(info B=$(call version_is_greater_or_equal,4.2,4.2.0))
$(info C=$(call version_is_greater_or_equal,4.1,4.2.0))
$(info D=$(call version_is_greater_or_equal,4.1.9,4.2.0))
$(info E=$(call version_is_greater_or_equal,5.1.9,4.2.0))
$(info F=$(call version_is_greater_or_equal,5.0.0,4.2.0))
$(info G=$(call version_is_greater_or_equal,4.2.1,4.2.0))
$(info H=$(call version_is_greater_or_equal,4.3.1,4.2.0))
```

e.g. to `makefiles/utils/strings.mk`, build something and observe the info output.

This yields

```
A=1
B=1
C=
D=
E=1
F=1
G=1
H=1
```

for me and does not complain about invalid `printf` invocations.

### Issues/PRs references

None

Co-authored-by: Martine Lenders <m.lenders@fu-berlin.de>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
3 people authored Jan 12, 2023
3 parents 75c909b + 64bea31 + 8c055f0 commit b14a89a
Showing 6 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions boards/common/makefiles/stdio_cdc_acm.dep.mk
Original file line number Diff line number Diff line change
@@ -8,4 +8,9 @@ ifeq (,$(filter-out stdio_cdc_acm,$(filter stdio_% slipdev_stdio,$(USEMODULE))))
USEMODULE += stdio_cdc_acm
endif
FEATURES_REQUIRED += highlevel_stdio

# Enforce tests to wait a bit for the serial port after reset
TERM_DELAY ?= 2
TESTRUNNER_CONNECT_DELAY ?= $(TERM_DELAY)
$(call target-export-variables,test,TESTRUNNER_CONNECT_DELAY)
endif
4 changes: 2 additions & 2 deletions makefiles/utils/strings.mk
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst
uppercase = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
uppercase_and_underscore = $(call uppercase,$(subst -,_,$1))

# Padds $2 number to $1 digits
_pad_number = $(shell printf '%0$1d' $2)
# Padds number $2 to $1 digits. If $2 is empty, zero will be printed instead.
_pad_number = $(shell printf '%0$1d' $(if $2,$2,0))

# Gets major, minor, patch from 'major.minor.patch', e.g.: 4.2.1 by index
# $1: index
4 changes: 4 additions & 0 deletions tests/congure_abe/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -8,13 +8,16 @@

import logging
import sys
import time
import unittest

from riotctrl.ctrl import RIOTCtrl
from riotctrl.shell.json import RapidJSONShellInteractionParser, rapidjson

from riotctrl_shell.congure_test import CongureTest

from testrunner.spawn import MAKE_TERM_CONNECT_DELAY


class TestCongUREBase(unittest.TestCase):
# pylint: disable=too-many-public-methods
@@ -25,6 +28,7 @@ class TestCongUREBase(unittest.TestCase):
def setUpClass(cls):
cls.ctrl = RIOTCtrl()
cls.ctrl.reset()
time.sleep(MAKE_TERM_CONNECT_DELAY)
cls.ctrl.start_term()
if cls.DEBUG:
cls.ctrl.term.logfile = sys.stdout
4 changes: 4 additions & 0 deletions tests/congure_quic/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -8,13 +8,16 @@

import logging
import sys
import time
import unittest

from riotctrl.ctrl import RIOTCtrl
from riotctrl.shell.json import RapidJSONShellInteractionParser, rapidjson

from riotctrl_shell.congure_test import CongureTest

from testrunner.spawn import MAKE_TERM_CONNECT_DELAY


class TestCongUREBase(unittest.TestCase):
DEBUG = False
@@ -25,6 +28,7 @@ class TestCongUREBase(unittest.TestCase):
def setUpClass(cls):
cls.ctrl = RIOTCtrl()
cls.ctrl.reset()
time.sleep(MAKE_TERM_CONNECT_DELAY)
cls.ctrl.start_term()
if cls.DEBUG:
cls.ctrl.term.logfile = sys.stdout
4 changes: 4 additions & 0 deletions tests/congure_reno/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -8,13 +8,16 @@

import logging
import sys
import time
import unittest

from riotctrl.ctrl import RIOTCtrl
from riotctrl.shell.json import RapidJSONShellInteractionParser, rapidjson

from riotctrl_shell.congure_test import CongureTest

from testrunner.spawn import MAKE_TERM_CONNECT_DELAY


class TestCongUREBase(unittest.TestCase):
# pylint: disable=too-many-public-methods
@@ -25,6 +28,7 @@ class TestCongUREBase(unittest.TestCase):
def setUpClass(cls):
cls.ctrl = RIOTCtrl()
cls.ctrl.reset()
time.sleep(MAKE_TERM_CONNECT_DELAY)
cls.ctrl.start_term()
if cls.DEBUG:
cls.ctrl.term.logfile = sys.stdout
4 changes: 4 additions & 0 deletions tests/congure_test/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import logging
import os
import sys
import time
import unittest

from riotctrl.ctrl import RIOTCtrl
@@ -17,6 +18,8 @@

from riotctrl_shell.congure_test import CongureTest

from testrunner.spawn import MAKE_TERM_CONNECT_DELAY


class TestCongUREBase(unittest.TestCase):
DEBUG = False
@@ -25,6 +28,7 @@ class TestCongUREBase(unittest.TestCase):
def setUpClass(cls):
cls.ctrl = RIOTCtrl()
cls.ctrl.reset()
time.sleep(MAKE_TERM_CONNECT_DELAY)
cls.ctrl.start_term()
if cls.DEBUG:
cls.ctrl.term.logfile = sys.stdout

0 comments on commit b14a89a

Please sign in to comment.