|
Packit Service |
fd7b69 |
/* Test internal legacy IPv4 text-to-address function __inet_aton_exact.
|
|
Packit Service |
fd7b69 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
fd7b69 |
This file is part of the GNU C Library.
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
fd7b69 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
fd7b69 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
fd7b69 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
fd7b69 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fd7b69 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
fd7b69 |
Lesser General Public License for more details.
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
fd7b69 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
fd7b69 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
#include <arpa/inet.h>
|
|
Packit Service |
fd7b69 |
#include <support/check.h>
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
static int
|
|
Packit Service |
fd7b69 |
do_test (void)
|
|
Packit Service |
fd7b69 |
{
|
|
Packit Service |
fd7b69 |
struct in_addr addr = { };
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.1", &addr), 1);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (ntohl (addr.s_addr), 0xC0000201);
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.000.002.010", &addr), 1);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (ntohl (addr.s_addr), 0xC0000208);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("0xC0000234", &addr), 1);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (ntohl (addr.s_addr), 0xC0000234);
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
/* Trailing content is not accepted. */
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.2X", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.3 Y", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.4\nZ", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.5\tT", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.6 Y", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.7\n", &addr), 0);
|
|
Packit Service |
fd7b69 |
TEST_COMPARE (__inet_aton_exact ("192.0.2.8\t", &addr), 0);
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
return 0;
|
|
Packit Service |
fd7b69 |
}
|
|
Packit Service |
fd7b69 |
|
|
Packit Service |
fd7b69 |
#include <support/test-driver.c>
|