blob: c18f07cfed57b0fa924f6de06e7a48eb9ffb7665 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include "errno-util.h"
#include "log.h"
#include "loopback-setup.h"
#include "tests.h"
TEST_RET(loopback_setup) {
int r;
if (unshare(CLONE_NEWUSER | CLONE_NEWNET) < 0) {
if (ERRNO_IS_PRIVILEGE(errno) || ERRNO_IS_NOT_SUPPORTED(errno)) {
log_notice("Skipping test, lacking privileges or namespaces not supported");
return EXIT_TEST_SKIP;
}
return log_error_errno(errno, "Failed to create user+network namespace: %m");
}
r = loopback_setup();
if (r < 0)
return log_error_errno(r, "loopback: %m");
log_info("> ipv6 main");
system("ip -6 route show table main");
log_info("> ipv6 local");
system("ip -6 route show table local");
log_info("> ipv4 main");
system("ip -4 route show table main");
log_info("> ipv4 local");
system("ip -4 route show table local");
return EXIT_SUCCESS;
}
static int intro(void) {
log_show_color(true);
return EXIT_SUCCESS;
}
DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
|