Merge pull request #31 from katlapinka/kasiat/initramfs-update
Add method for updating initramfs accordingly to OS version
This commit is contained in:
commit
072c72b08c
19
test_tools/initramfs.py
Normal file
19
test_tools/initramfs.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
from core.test_run import TestRun
|
||||||
|
from test_utils.os_utils import get_distro, Distro
|
||||||
|
|
||||||
|
|
||||||
|
def update():
|
||||||
|
distro = get_distro()
|
||||||
|
TestRun.LOGGER.info("Updating initramfs")
|
||||||
|
match distro:
|
||||||
|
case Distro.DEBIAN | Distro.UBUNTU:
|
||||||
|
TestRun.executor.run_expect_success("update-initramfs -u")
|
||||||
|
case Distro.OPENEULER | Distro.CENTOS | Distro.REDHAT:
|
||||||
|
TestRun.executor.run_expect_success(
|
||||||
|
"dracut -f /boot/initramfs-$(uname -r).img $(uname -r)"
|
||||||
|
)
|
@ -8,9 +8,9 @@ import math
|
|||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from datetime import timedelta, datetime
|
|
||||||
|
|
||||||
from aenum import IntFlag, Enum, IntEnum
|
from datetime import timedelta, datetime
|
||||||
|
from enum import IntFlag, Enum, IntEnum, StrEnum
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
@ -28,6 +28,14 @@ DEBUGFS_MOUNT_POINT = "/sys/kernel/debug"
|
|||||||
MEMORY_MOUNT_POINT = "/mnt/memspace"
|
MEMORY_MOUNT_POINT = "/mnt/memspace"
|
||||||
|
|
||||||
|
|
||||||
|
class Distro(StrEnum):
|
||||||
|
UBUNTU = "ubuntu"
|
||||||
|
DEBIAN = "debian"
|
||||||
|
REDHAT = "rhel"
|
||||||
|
OPENEULER = "openeuler"
|
||||||
|
CENTOS = "centos"
|
||||||
|
|
||||||
|
|
||||||
class DropCachesMode(IntFlag):
|
class DropCachesMode(IntFlag):
|
||||||
PAGECACHE = 1
|
PAGECACHE = 1
|
||||||
SLAB = 2
|
SLAB = 2
|
||||||
@ -102,6 +110,17 @@ class SystemManagerType(Enum):
|
|||||||
systemd = 1
|
systemd = 1
|
||||||
|
|
||||||
|
|
||||||
|
def get_distro():
|
||||||
|
output = TestRun.executor.run(
|
||||||
|
"cat /etc/os-release | grep -e \"^ID=\" | awk -F= '{print$2}' | tr -d '\"'"
|
||||||
|
).stdout.lower()
|
||||||
|
|
||||||
|
try:
|
||||||
|
return Distro(output)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError(f"Could not resolve distro name. Command output: {output}")
|
||||||
|
|
||||||
|
|
||||||
def get_system_manager():
|
def get_system_manager():
|
||||||
output = TestRun.executor.run_expect_success("ps -p 1").stdout
|
output = TestRun.executor.run_expect_success("ps -p 1").stdout
|
||||||
type = output.split('\n')[1].split()[3]
|
type = output.split('\n')[1].split()[3]
|
||||||
|
Loading…
Reference in New Issue
Block a user