]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-arphrd-util.c
tree-wide: make sure net/if.h is included before any linux/ header
[thirdparty/systemd.git] / src / test / test-arphrd-util.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 /* Make sure the net/if.h header is included before any linux/ one */
4 #include <net/if.h>
5 #include <linux/if_arp.h>
6
7 #include "arphrd-util.h"
8 #include "string-util.h"
9 #include "tests.h"
10
11 TEST(arphrd) {
12 for (int i = 0; i <= ARPHRD_VOID + 1; i++) {
13 const char *name;
14
15 name = arphrd_to_name(i);
16 if (name) {
17 log_info("%i: %s", i, name);
18
19 ASSERT_EQ(arphrd_from_name(name), i);
20 }
21 }
22
23 ASSERT_NULL(arphrd_to_name(ARPHRD_VOID + 1));
24 assert_se(arphrd_from_name("huddlduddl") == -EINVAL);
25 assert_se(arphrd_from_name("") == -EINVAL);
26 }
27
28 DEFINE_TEST_MAIN(LOG_INFO);