]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-arphrd-list.c
libudev: hide definition of struct udev_list from other libudev components
[thirdparty/systemd.git] / src / test / test-arphrd-list.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
da8ba721 2
01234e1f 3#include <linux/if_arp.h>
da8ba721
DM
4#include <string.h>
5
6#include "macro.h"
07630cea 7#include "string-util.h"
da8ba721 8
cfe5b071 9_unused_ \
c9f7b4d3 10static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
da8ba721 11
07630cea 12#include "arphrd-from-name.h"
da8ba721
DM
13#include "arphrd-list.h"
14#include "arphrd-to-name.h"
da8ba721
DM
15
16int main(int argc, const char *argv[]) {
17
14cb109d 18 unsigned i;
da8ba721
DM
19
20 for (i = 1; i < ELEMENTSOF(arphrd_names); i++) {
21 if (arphrd_names[i]) {
22 assert_se(streq(arphrd_to_name(i), arphrd_names[i]));
23 assert_se(arphrd_from_name(arphrd_names[i]) == (int) i);
24 }
25 }
26
27 assert_se(arphrd_to_name(arphrd_max()) == NULL);
28 assert_se(arphrd_to_name(0) == NULL);
acf4d158
YW
29 assert_se(arphrd_from_name("huddlduddl") == -EINVAL);
30 assert_se(arphrd_from_name("") == -EINVAL);
da8ba721
DM
31
32 return 0;
07630cea 33}