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