From 4941afb4f96a20df7dc8b6688f7921a3d713b77d Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Wed, 7 Feb 2024 13:29:51 +0000 Subject: [PATCH] tests: Add support for getting corefile patterns on FreeBSD Type: improvement Change-Id: I960edc05a9a77eb55f67cb1ec01d2b3122298ef8 Signed-off-by: Tom Jones --- test/requirements.txt | 1 + test/util.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/requirements.txt b/test/requirements.txt index beb338dea7c..c01d31161f7 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -23,3 +23,4 @@ dataclasses; python_version == '3.6' # Apache-2.0 black # MIT https://github.com/psf/black pycryptodome # BSD, Public Domain sh # MIT https://github.com/amoffat/sh +sysctl; platform_system == "FreeBSD" # BSD diff --git a/test/util.py b/test/util.py index 8e4c9079631..59957a74e91 100644 --- a/test/util.py +++ b/test/util.py @@ -5,6 +5,7 @@ import logging import socket from socket import AF_INET6 import os.path +import platform from copy import deepcopy from collections import UserDict @@ -109,8 +110,13 @@ def is_core_present(tempdir): def get_core_pattern(): - with open("/proc/sys/kernel/core_pattern", "r") as f: - corefmt = f.read().strip() + if platform.uname().system == "FreeBSD": + import sysctl + + corefmt = sysctl.filter("kern.corefile")[0].value + elif platform.uname().system == "Linux": + with open("/proc/sys/kernel/core_pattern", "r") as f: + corefmt = f.read().strip() return corefmt