[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] ptsname_r-tests: new test module
From: |
Bruno Haible |
Subject: |
Re: [PATCH 2/4] ptsname_r-tests: new test module |
Date: |
Tue, 8 Nov 2011 12:14:54 +0100 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Eric Blake wrote:
> +static int
> +test_errors (int fd, char *slave)
The parameter should be a 'const char *slave'.
> +{
> + char buffer[256];
> + size_t len;
> + int result;
> +
> + errno = 0;
> + len = strlen (buffer);
This should be: len = strlen (slave), right? buffer is uninitialized at
this point.
> + memset (buffer, 0, sizeof buffer);
> + result = ptsname_r (fd, buffer, len);
> + ASSERT (result != 0);
> + ASSERT (result == errno);
> + ASSERT (errno == ERANGE);
> + ASSERT (buffer[0] == '\0');
I would find it good to test other values of the buflen parameter, since
the experience shows that platforms have bugs in this area. Like this:
size_t buflen;
for (buflen = 0; buflen <= sizeof (buffer); buflen++)
{
memset (buffer, 'X', sizeof buffer);
result = ptsname_r (fd, buffer, len);
if (buflen > len)
{
ASSERT (result == 0);
ASSERT (buffer[0] == '/');
}
else
{
ASSERT (result != 0);
ASSERT (result == errno);
ASSERT (errno == ERANGE);
ASSERT (buffer[0] == 'X');
}
}
> + errno = 0;
> + result = ptsname_r (-1, buffer, sizeof buffer);
> + ASSERT (result != 0);
> + ASSERT (result == errno);
> + ASSERT (errno == EBADF);
> + ASSERT (buffer[0] == '\0');
This test does not use the fd and slave parameters and is already contained
in main(). Why repeat it in test_errors()?
Bruno
--
In memoriam The inmates of the Daugavpils Ghetto
<http://en.wikipedia.org/wiki/Daugavpils_Ghetto>
- [PATCH 0/4] add ptsname_r, Eric Blake, 2011/11/07
- [PATCH 2/4] ptsname_r-tests: new test module, Eric Blake, 2011/11/07
- Re: [PATCH 2/4] ptsname_r-tests: new test module,
Bruno Haible <=
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Eric Blake, 2011/11/09
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Bruno Haible, 2011/11/09
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Bruno Haible, 2011/11/09
- ptsname_r testing, Bruno Haible, 2011/11/10
- Re: ptsname_r on OSF/1, Bruno Haible, 2011/11/10
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Bruno Haible, 2011/11/10
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Bruno Haible, 2011/11/10
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Eric Blake, 2011/11/10
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Bruno Haible, 2011/11/10
- Re: [PATCH 2/4] ptsname_r-tests: new test module, Eric Blake, 2011/11/10