Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty
@ 2025-01-20  7:17 yann.morin
  2025-01-20  7:17 ` [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without " yann.morin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: yann.morin @ 2025-01-20  7:17 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Yann E . MORIN

From: "Yann E. MORIN" <yann.morin@orange.com>

Hello All!

This small series aims at fixing the get-developers test when running in
an environment where stdin is not a tty, like in a CI pipeline (e.g.
Gitlab-CI).

Then it extends the get-develpers test with an actual test for reading a
patch from stdin.


Regards,
Yann E. MORIN.


The following changes since commit 12ec5d5059ea107a960b9e20dd11b9f7affd1070

  package/lighttpd: fix missing conf install (2025-01-19 15:13:45 +0100)


are available as patches in this mail series,

for you to apply patches up to b8090988958a71953ab904d2f33af498536a280c

  support/testing.utils: check patch on stdin to get-developers (2025-01-20 08:14:58 +0100)


----------------------------------------------------------------
Yann E. MORIN (2):
      support/testing/utils: fix get-developers test without a tty
      support/testing.utils: check patch on stdin to get-developers

 support/testing/tests/utils/test_get_developers.py | 28 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)

--
                                        ____________
.-----------------.--------------------:       _    :------------------.
|  Yann E. MORIN  | Real-Time Embedded |    __/ )   | /"\ ASCII RIBBON |
|                 | Software  Designer |  _/ - /'   | \ / CAMPAIGN     |
| +33 638.411.245 '--------------------: (_    `--, |  X  AGAINST      |
| yann.morin (at) orange.com           |_="    ,--' | / \ HTML MAIL    |
'--------------------------------------:______/_____:------------------'

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without a tty
  2025-01-20  7:17 [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty yann.morin
@ 2025-01-20  7:17 ` yann.morin
  2025-01-31 16:47   ` Peter Korsgaard
  2025-01-20  7:17 ` [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers yann.morin
  2025-01-20 20:20 ` [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty Julien Olivain
  2 siblings, 1 reply; 6+ messages in thread
From: yann.morin @ 2025-01-20  7:17 UTC (permalink / raw)
  To: buildroot; +Cc: yann.morin, Julien Olivain

From: "Yann E. MORIN" <yann.morin@orange.com>

get-developers will check its stdin to decide whether it is a tty or
not, and behave differently whether it is or not. So, when we run the
tests, we need an actual tty.

However, when running in a CI pipeline, like on Gitlab-CI, there is no
tty available on stdin.

Fake one. We don't need anything too fancy, so just a slave pty will
suffice.

Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/8830671800
Fixes: d10d22221f93 (utils/get-developers: read patch from stdin when
it's not a tty)

Reported-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
---
 support/testing/tests/utils/test_get_developers.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py
index 3ec4edeadd..701c3acb1a 100644
--- a/support/testing/tests/utils/test_get_developers.py
+++ b/support/testing/tests/utils/test_get_developers.py
@@ -15,10 +15,16 @@ import infra
 
 def call_script(args, env, cwd):
     """Call a script and return stdout and stderr as lists and the exit code."""
-    proc = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,
+    # We need stdin to be a tty, not just a pipe or whatever
+    m_tty, s_tty = os.openpty()
+    proc = subprocess.Popen(args, cwd=cwd,
+                            stdin=s_tty,
+                            stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, env=env,
                             universal_newlines=True)
     out, err = proc.communicate()
+    os.close(s_tty)
+    os.close(m_tty)
     return out.splitlines(), err.splitlines(), proc.returncode
 
 
-- 
2.34.1

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers
  2025-01-20  7:17 [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty yann.morin
  2025-01-20  7:17 ` [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without " yann.morin
@ 2025-01-20  7:17 ` yann.morin
  2025-01-31 16:47   ` Peter Korsgaard
  2025-01-20 20:20 ` [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty Julien Olivain
  2 siblings, 1 reply; 6+ messages in thread
From: yann.morin @ 2025-01-20  7:17 UTC (permalink / raw)
  To: buildroot; +Cc: yann.morin, Julien Olivain

From: "Yann E. MORIN" <yann.morin@orange.com>

Since commit d10d22221f93 (utils/get-developers: read patch from stdin
when it's not a tty), get-developers accepts to read a patch fromn its
stdin when it is not a tty.

Add a test for this.

Reported-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
---
 .../tests/utils/test_get_developers.py        | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py
index 701c3acb1a..195e421332 100644
--- a/support/testing/tests/utils/test_get_developers.py
+++ b/support/testing/tests/utils/test_get_developers.py
@@ -13,26 +13,32 @@ import unittest
 import infra
 
 
-def call_script(args, env, cwd):
+def call_script(args, env, cwd, stdin_data=None):
     """Call a script and return stdout and stderr as lists and the exit code."""
-    # We need stdin to be a tty, not just a pipe or whatever
-    m_tty, s_tty = os.openpty()
+    if stdin_data is None:
+        # We need stdin to be a tty, not just a pipe or whatever
+        m_tty, s_tty = os.openpty()
+        com_opts = dict()
+    else:
+        s_tty = subprocess.PIPE
+        com_opts = dict([("input", stdin_data)])
     proc = subprocess.Popen(args, cwd=cwd,
                             stdin=s_tty,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, env=env,
                             universal_newlines=True)
-    out, err = proc.communicate()
-    os.close(s_tty)
-    os.close(m_tty)
+    out, err = proc.communicate(**com_opts)
+    if stdin_data is None:
+        os.close(s_tty)
+        os.close(m_tty)
     return out.splitlines(), err.splitlines(), proc.returncode
 
 
-def call_get_developers(cmd, args, env, cwd, developers_content):
+def call_get_developers(cmd, args, env, cwd, developers_content, stdin_data=None):
     """Call get-developers overrinding the default DEVELOPERS file."""
     with tempfile.NamedTemporaryFile(buffering=0) as developers_file:
         developers_file.write(developers_content)
-        return call_script([cmd, "-d", developers_file.name] + args, env, cwd)
+        return call_script([cmd, "-d", developers_file.name] + args, env, cwd, stdin_data)
 
 
 class TestGetDevelopers(unittest.TestCase):
@@ -174,3 +180,9 @@ class TestGetDevelopers(unittest.TestCase):
         self.assertIn('git send-email --to buildroot@buildroot.org --cc "dev1"', out)
         self.assertEqual(rc, 0)
         self.assertEqual(len(err), 0)
+        with open(abs_file, "r") as fd:
+            patch_data = fd.read()
+        out, err, rc = call_get_developers("./utils/get-developers", [], self.WITH_EMPTY_PATH, topdir, developers, patch_data)
+        self.assertIn('git send-email --to buildroot@buildroot.org --cc "dev1"', out)
+        self.assertEqual(rc, 0)
+        self.assertEqual(len(err), 0)
-- 
2.34.1

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty
  2025-01-20  7:17 [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty yann.morin
  2025-01-20  7:17 ` [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without " yann.morin
  2025-01-20  7:17 ` [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers yann.morin
@ 2025-01-20 20:20 ` Julien Olivain
  2 siblings, 0 replies; 6+ messages in thread
From: Julien Olivain @ 2025-01-20 20:20 UTC (permalink / raw)
  To: yann.morin; +Cc: buildroot

Hi Yann,

On 20/01/2025 08:17, yann.morin@orange.com wrote:
> From: "Yann E. MORIN" <yann.morin@orange.com>
> 
> Hello All!
> 
> This small series aims at fixing the get-developers test when running 
> in
> an environment where stdin is not a tty, like in a CI pipeline (e.g.
> Gitlab-CI).
> 
> Then it extends the get-develpers test with an actual test for reading 
> a
> patch from stdin.

Thanks for this fast answer!  I applied this series to master.

> Regards,
> Yann E. MORIN.

Best regards,

Julien.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without a tty
  2025-01-20  7:17 ` [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without " yann.morin
@ 2025-01-31 16:47   ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2025-01-31 16:47 UTC (permalink / raw)
  To: yann.morin; +Cc: buildroot, Julien Olivain

>>>>>   <yann.morin@orange.com> writes:

 > From: "Yann E. MORIN" <yann.morin@orange.com>
 > get-developers will check its stdin to decide whether it is a tty or
 > not, and behave differently whether it is or not. So, when we run the
 > tests, we need an actual tty.

 > However, when running in a CI pipeline, like on Gitlab-CI, there is no
 > tty available on stdin.

 > Fake one. We don't need anything too fancy, so just a slave pty will
 > suffice.

 > Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/8830671800
 > Fixes: d10d22221f93 (utils/get-developers: read patch from stdin when
 > it's not a tty)

 > Reported-by: Julien Olivain <ju.o@free.fr>
 > Signed-off-by: Yann E. MORIN <yann.morin@orange.com>

Committed to 2024.02.x and 2024.11.x, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers
  2025-01-20  7:17 ` [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers yann.morin
@ 2025-01-31 16:47   ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2025-01-31 16:47 UTC (permalink / raw)
  To: yann.morin; +Cc: buildroot, Julien Olivain

>>>>>   <yann.morin@orange.com> writes:

 > From: "Yann E. MORIN" <yann.morin@orange.com>
 > Since commit d10d22221f93 (utils/get-developers: read patch from stdin
 > when it's not a tty), get-developers accepts to read a patch fromn its
 > stdin when it is not a tty.

 > Add a test for this.

 > Reported-by: Julien Olivain <ju.o@free.fr>
 > Signed-off-by: Yann E. MORIN <yann.morin@orange.com>

Committed to 2024.02.x and 2024.11.x, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-31 16:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20  7:17 [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty yann.morin
2025-01-20  7:17 ` [Buildroot] [PATCH 1/2] support/testing/utils: fix get-developers test without " yann.morin
2025-01-31 16:47   ` Peter Korsgaard
2025-01-20  7:17 ` [Buildroot] [PATCH 2/2] support/testing.utils: check patch on stdin to get-developers yann.morin
2025-01-31 16:47   ` Peter Korsgaard
2025-01-20 20:20 ` [Buildroot] [PATCH 0/2] support/tests: fix get-developers test when stdini for tests is not a tty Julien Olivain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox