-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tc-testing: use a plugin to build eBPF program
use a TDC plugin, instead of building eBPF programs in the 'setup' stage. '-B' argument can be used to build eBPF programs in $EBPFDIR directory, in the 'pre-suite' stage. Binaries are then cleaned in 'post-suite' stage. Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Davide Caratti
authored and
David S. Miller
committed
Oct 5, 2018
1 parent
cf5eafb
commit 4c2d39b
Showing
3 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
''' | ||
build ebpf program | ||
''' | ||
|
||
import os | ||
import signal | ||
from string import Template | ||
import subprocess | ||
import time | ||
from TdcPlugin import TdcPlugin | ||
from tdc_config import * | ||
|
||
class SubPlugin(TdcPlugin): | ||
def __init__(self): | ||
self.sub_class = 'buildebpf/SubPlugin' | ||
self.tap = '' | ||
super().__init__() | ||
|
||
def pre_suite(self, testcount, testidlist): | ||
super().pre_suite(testcount, testidlist) | ||
|
||
if self.args.buildebpf: | ||
self._ebpf_makeall() | ||
|
||
def post_suite(self, index): | ||
super().post_suite(index) | ||
|
||
self._ebpf_makeclean() | ||
|
||
def add_args(self, parser): | ||
super().add_args(parser) | ||
|
||
self.argparser_group = self.argparser.add_argument_group( | ||
'buildebpf', | ||
'options for buildebpfPlugin') | ||
self.argparser_group.add_argument( | ||
'-B', '--buildebpf', action='store_true', | ||
help='build eBPF programs') | ||
|
||
return self.argparser | ||
|
||
def _ebpf_makeall(self): | ||
if self.args.buildebpf: | ||
self._make('all') | ||
|
||
def _ebpf_makeclean(self): | ||
if self.args.buildebpf: | ||
self._make('clean') | ||
|
||
def _make(self, target): | ||
command = 'make -C {} {}'.format(self.args.NAMES['EBPFDIR'], target) | ||
proc = subprocess.Popen(command, | ||
shell=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
env=ENVIR) | ||
(rawout, serr) = proc.communicate() | ||
|
||
if proc.returncode != 0 and len(serr) > 0: | ||
foutput = serr.decode("utf-8") | ||
else: | ||
foutput = rawout.decode("utf-8") | ||
|
||
proc.stdout.close() | ||
proc.stderr.close() | ||
return proc, foutput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters