public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Testcase for BZ 28519
@ 2023-03-20 18:10 Joe Simmons-Talbott
  2023-03-20 20:14 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Simmons-Talbott @ 2023-03-20 18:10 UTC (permalink / raw)
  To: libc-help

Hi,

I'm trying to write a testcase for BZ 28519 but not having much luck.
My testcase is below.  For a simple application that calls
'system("-echo")' I get the same behavior as the BZ but for the testcase
I get the expected behavior where sh fails to find "-echo".

Does anyone have any thought on what I might be missing?

Thanks,
Joe

My testcase looks like this:

diff --git a/stdlib/tst-system.c b/stdlib/tst-system.c
index 47a0afe6bf..6f3329c08e 100644
--- a/stdlib/tst-system.c
+++ b/stdlib/tst-system.c
@@ -146,6 +146,20 @@ do_test (void)
     TEST_COMPARE_STRING (result.out.buffer, "...\n");
   }

+  {
+    struct support_capture_subprocess result;
+    const char *cmd = "-echo";
+    result = support_capture_subprocess (call_system,
+                                        &(struct args) { cmd, 127, 0 });
+    support_capture_subprocess_check (&result, "system", 0, sc_allow_stderr);
+       printf("JOE: %s\n", result.err.buffer);
+    char *returnerr = xasprintf ("%s: execing %s failed: "
+                                "No such file or directory",
+                                basename(_PATH_BSHELL), cmd);
+    TEST_COMPARE_STRING (result.err.buffer, returnerr);
+    free (returnerr);
+  }
+
   {
     struct support_capture_subprocess result;
     result = support_capture_subprocess (call_system,


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

* Re: Testcase for BZ 28519
  2023-03-20 18:10 Testcase for BZ 28519 Joe Simmons-Talbott
@ 2023-03-20 20:14 ` Florian Weimer
  2023-03-21 17:19   ` Joe Talbott
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2023-03-20 20:14 UTC (permalink / raw)
  To: Joe Simmons-Talbott via Libc-help; +Cc: Joe Simmons-Talbott

* Joe Simmons-Talbott via Libc-help:

> Hi,
>
> I'm trying to write a testcase for BZ 28519 but not having much luck.
> My testcase is below.  For a simple application that calls
> 'system("-echo")' I get the same behavior as the BZ but for the testcase
> I get the expected behavior where sh fails to find "-echo".
>
> Does anyone have any thought on what I might be missing?

I suspect it's because of

tests-container := \
  tst-system \
  #tests-container

in stdlib/Makefile.  /bin/sh in the container is not a real /bin/sh,
so it has different behavior.

Thanks,
Florian


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

* Re: Testcase for BZ 28519
  2023-03-20 20:14 ` Florian Weimer
@ 2023-03-21 17:19   ` Joe Talbott
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Talbott @ 2023-03-21 17:19 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Joe Simmons-Talbott via Libc-help

On Mon, Mar 20, 2023 at 4:14 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Joe Simmons-Talbott via Libc-help:
>
> > Hi,
> >
> > I'm trying to write a testcase for BZ 28519 but not having much luck.
> > My testcase is below.  For a simple application that calls
> > 'system("-echo")' I get the same behavior as the BZ but for the testcase
> > I get the expected behavior where sh fails to find "-echo".
> >
> > Does anyone have any thought on what I might be missing?
>
> I suspect it's because of
>
> tests-container := \
>   tst-system \
>   #tests-container
>
> in stdlib/Makefile.  /bin/sh in the container is not a real /bin/sh,
> so it has different behavior.

Thanks Florian that does appear to be why I'm seeing this behavior.

Is it worth the effort to add support to shell-container for both a "--" flag
and another flag, a boiler-plate "-e" perhaps?

Thanks,
Joe

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

end of thread, other threads:[~2023-03-21 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 18:10 Testcase for BZ 28519 Joe Simmons-Talbott
2023-03-20 20:14 ` Florian Weimer
2023-03-21 17:19   ` Joe Talbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).