Skip to content

Commit

Permalink
Tests/PktGen: load pktgen module
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Tluka <[email protected]>
  • Loading branch information
jtluka committed Sep 4, 2024
1 parent f581231 commit 6e394f9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lnst/Tests/PktGen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import time
import logging
from subprocess import Popen
from subprocess import Popen, check_output, CalledProcessError
from threading import Thread
from typing import Iterator, Union

Expand Down Expand Up @@ -139,9 +139,7 @@ def __init__(self, **kwargs):
self._output_parser = None

def run(self):
if not kmod_loaded("pktgen"):
raise TestModuleError("pktgen module is not loaded")

self._load_pktgen_module()
self._pg_ctrl("reset")
self._configure_generator()

Expand All @@ -161,6 +159,15 @@ def run(self):
self._deconfigure_generator()
return True

def _load_pktgen_module(self):
try:
check_output(["/usr/sbin/modprobe", "pktgen"])
except CalledProcessError as e:
logging.debug(f"Modprobe of pktgen failed {e.output}")

if not kmod_loaded("pktgen"):
raise TestModuleError("pktgen module is not loaded")

def _configure_generator(self):
logging.debug("Configuring generator")

Expand Down

0 comments on commit 6e394f9

Please sign in to comment.