]> git.ipfire.org Git - thirdparty/glibc.git/blame - inet/tst-ether_aton.c
x86: Remove arch-specific low level lock implementation
[thirdparty/glibc.git] / inet / tst-ether_aton.c
CommitLineData
52ec8aab 1#include <stdio.h>
c0a0f9a3 2#include <string.h>
6739da7f
UD
3#include <netinet/ether.h>
4
c1f41083
AS
5static int
6do_test (void)
6739da7f 7{
c0a0f9a3
UD
8 struct ether_addr *valp, val;
9 int result, r;
10 char hostname[32], buf[64], *p;
6739da7f 11
c0a0f9a3 12 valp = ether_aton ("12:34:56:78:9a:bc");
6739da7f
UD
13
14 printf ("ether_aton (\"12:34:56:78:9a:bc\") = %hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
c0a0f9a3
UD
15 valp->ether_addr_octet[0],
16 valp->ether_addr_octet[1],
17 valp->ether_addr_octet[2],
18 valp->ether_addr_octet[3],
19 valp->ether_addr_octet[4],
20 valp->ether_addr_octet[5]);
21
22 result = (valp->ether_addr_octet[0] != 0x12
23 || valp->ether_addr_octet[1] != 0x34
24 || valp->ether_addr_octet[2] != 0x56
25 || valp->ether_addr_octet[3] != 0x78
26 || valp->ether_addr_octet[4] != 0x9a
27 || valp->ether_addr_octet[5] != 0xbc);
28
29 if ((r = ether_line ("0:c0:f0:46:5f:97 host.ether.com \t# comment",
30 &val, hostname)) == 0)
31 {
32 ether_ntoa_r (&val, buf);
33 p = strchr (buf, '\0');
34 *p++ = ' ';
35 strcpy (p, hostname);
36
37 printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = \"%s\"\n",
38 buf);
39
40 result |= strcmp ("0:c0:f0:46:5f:97 host.ether.com", buf) != 0;
41 }
42 else
43 {
44 printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = %d\n", r);
45 result |= 1;
46 }
47
48 r = ether_line ("0:c0:2:d0 foo.bar ", &val, hostname);
49 printf ("ether_line (\"0:c0:2:d0 foo.bar \") = %d\n", r);
50 result |= r != -1;
51
52 r = ether_line ("0:c0:2:d0:1a:2a ", &val, hostname);
53 printf ("ether_line (\"0:c0:2:d0:1a:2a \") = %d\n", r);
54 result |= r != -1;
6739da7f
UD
55
56 return result;
57}
c1f41083
AS
58
59#define TEST_FUNCTION do_test ()
60#include "../test-skeleton.c"