TEST-85-NETWORK: enable NetworkdSysctlTest

Note, each test case must be prefixed with 'test_'.

This also adds one more log check for issue #40051.

Follow-up for c78bcda461.
This commit is contained in:
Yu Watanabe
2025-12-11 14:37:04 +09:00
parent 427dcb2eeb
commit 72711b76e0
3 changed files with 7 additions and 1 deletions
+4
View File
@@ -53,6 +53,8 @@ static int sysctl_event_handler(void *ctx, void *data, size_t data_sz) {
"Unexpected sysctl event, disabling sysctl monitoring: %d", we->version);
if (we->errorcode != 0) {
/* The log message is checked in test-network/systemd-networkd-tests.py. Please update the
* test when the log message is changed. */
log_warning_errno(we->errorcode, "Sysctl monitor BPF returned error: %m");
return 0;
}
@@ -69,6 +71,8 @@ static int sysctl_event_handler(void *ctx, void *data, size_t data_sz) {
return 0;
if (!strneq(value, we->newvalue, sizeof(we->newvalue)))
/* The log message is checked in test-network/systemd-networkd-tests.py. Please update the
* test when the log message is changed. */
log_struct(LOG_WARNING,
LOG_MESSAGE_ID(SD_MESSAGE_SYSCTL_CHANGED_STR),
LOG_ITEM("OBJECT_PID=" PID_FMT, we->pid),
@@ -22,6 +22,7 @@ foreach testcase : [
'NetworkdDHCPPDTests',
'NetworkdIPv6PrefixTests',
'NetworkdMTUTests',
'NetworkdSysctlTest',
]
integration_tests += [
integration_test_template + {
+2 -1
View File
@@ -9375,7 +9375,7 @@ class NetworkdSysctlTest(unittest.TestCase, Utilities):
tear_down_common()
@unittest.skipUnless(compare_kernel_version("6.12"), reason="On kernels <= 6.12, bpf_current_task_under_cgroup() isn't available for program types BPF_PROG_TYPE_CGROUP_SYSCTL")
def check_sysctl_watch(self):
def test_sysctl_monitor(self):
copy_network_unit('12-dummy.network', '12-dummy.netdev', '12-dummy.link')
start_networkd()
@@ -9398,6 +9398,7 @@ class NetworkdSysctlTest(unittest.TestCase, Utilities):
self.assertRegex(log, r"Foreign process 'sysctl\[\d+\]' changed sysctl '/proc/sys/net/ipv6/conf/dummy98/proxy_ndp' from '0' to '1', conflicting with our setting to '0'")
self.assertNotIn("changed sysctl '/proc/sys/net/ipv6/conf/dummy98/hop_limit'", log)
self.assertNotIn("changed sysctl '/proc/sys/net/ipv6/conf/dummy98/max_addresses'", log)
self.assertNotIn("Sysctl monitor BPF returned error", log)
if __name__ == '__main__':
parser = argparse.ArgumentParser()