2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2015-07-30 21:07:25 +02:00
|
|
|
|
2019-04-10 12:55:53 +02:00
|
|
|
#include <linux/if_arp.h>
|
2015-07-30 21:07:25 +02:00
|
|
|
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "string-util.h"
|
2019-09-25 11:39:10 +02:00
|
|
|
#include "tests.h"
|
2015-07-30 21:07:25 +02:00
|
|
|
|
|
|
|
#include "arphrd-list.h"
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
2019-09-25 11:39:10 +02:00
|
|
|
test_setup_logging(LOG_INFO);
|
2015-07-30 21:07:25 +02:00
|
|
|
|
2019-09-25 12:06:05 +02:00
|
|
|
for (int i = 0; i <= ARPHRD_VOID + 1; i++) {
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = arphrd_to_name(i);
|
|
|
|
if (name) {
|
|
|
|
log_info("%i: %s", i, name);
|
2019-09-25 11:39:10 +02:00
|
|
|
|
2019-09-25 12:06:05 +02:00
|
|
|
assert_se(arphrd_from_name(name) == i);
|
2015-07-30 21:07:25 +02:00
|
|
|
}
|
2019-09-25 12:06:05 +02:00
|
|
|
}
|
2015-07-30 21:07:25 +02:00
|
|
|
|
2019-09-25 12:06:05 +02:00
|
|
|
assert_se(arphrd_to_name(ARPHRD_VOID + 1) == NULL);
|
2018-11-28 09:54:04 +01:00
|
|
|
assert_se(arphrd_from_name("huddlduddl") == -EINVAL);
|
|
|
|
assert_se(arphrd_from_name("") == -EINVAL);
|
2015-07-30 21:07:25 +02:00
|
|
|
|
|
|
|
return 0;
|
2015-10-24 22:58:24 +02:00
|
|
|
}
|