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