|
|
446cf2 |
commit 183083c35972611e7786c7ee0c96d7da571631ed
|
|
|
446cf2 |
Author: Carlos O'Donell <carlos@redhat.com>
|
|
|
446cf2 |
Date: Wed Apr 29 16:31:29 2020 -0400
|
|
|
446cf2 |
|
|
|
446cf2 |
support: Set errno before testing it.
|
|
|
446cf2 |
|
|
|
446cf2 |
In test-conainer we should set errno to 0 before calling strtol,
|
|
|
446cf2 |
and check after with TEST_COMPARE.
|
|
|
446cf2 |
|
|
|
446cf2 |
In tst-support_capture_subprocess we should set errno to 0 before
|
|
|
446cf2 |
checking it after the call to strtol.
|
|
|
446cf2 |
|
|
|
446cf2 |
Tested on x86_64.
|
|
|
446cf2 |
|
|
|
446cf2 |
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
|
446cf2 |
|
|
|
446cf2 |
diff --git a/support/test-container.c b/support/test-container.c
|
|
|
446cf2 |
index 9fcc91e478038232..d7ed073812305f71 100644
|
|
|
446cf2 |
--- a/support/test-container.c
|
|
|
446cf2 |
+++ b/support/test-container.c
|
|
|
446cf2 |
@@ -940,7 +940,9 @@ main (int argc, char **argv)
|
|
|
446cf2 |
else if (nt == 3 && strcmp (the_words[0], "chmod") == 0)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
long int m;
|
|
|
446cf2 |
+ errno = 0;
|
|
|
446cf2 |
m = strtol (the_words[1], NULL, 0);
|
|
|
446cf2 |
+ TEST_COMPARE (errno, 0);
|
|
|
446cf2 |
if (chmod (the_words[2], m) < 0)
|
|
|
446cf2 |
FAIL_EXIT1 ("chmod %s: %s\n",
|
|
|
446cf2 |
the_words[2], strerror (errno));
|
|
|
446cf2 |
diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c
|
|
|
446cf2 |
index 99570879eedd65b1..fe6649dda6032de2 100644
|
|
|
446cf2 |
--- a/support/tst-support_capture_subprocess.c
|
|
|
446cf2 |
+++ b/support/tst-support_capture_subprocess.c
|
|
|
446cf2 |
@@ -133,7 +133,9 @@ static int
|
|
|
446cf2 |
parse_int (const char *str)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
char *endptr;
|
|
|
446cf2 |
- long int ret = strtol (str, &endptr, 10);
|
|
|
446cf2 |
+ long int ret;
|
|
|
446cf2 |
+ errno = 0;
|
|
|
446cf2 |
+ ret = strtol (str, &endptr, 10);
|
|
|
446cf2 |
TEST_COMPARE (errno, 0);
|
|
|
446cf2 |
TEST_VERIFY (ret >= 0 && ret <= INT_MAX);
|
|
|
446cf2 |
return ret;
|