staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / tc-testing / plugin-lib / buildebpfPlugin.py
blobe98c36750faedcb5084fa15c9bcb55afda270112
1 '''
2 build ebpf program
3 '''
5 import os
6 import signal
7 from string import Template
8 import subprocess
9 import time
10 from TdcPlugin import TdcPlugin
11 from tdc_config import *
13 class SubPlugin(TdcPlugin):
14 def __init__(self):
15 self.sub_class = 'buildebpf/SubPlugin'
16 self.tap = ''
17 super().__init__()
19 def pre_suite(self, testcount, testidlist):
20 super().pre_suite(testcount, testidlist)
22 if self.args.buildebpf:
23 self._ebpf_makeall()
25 def post_suite(self, index):
26 super().post_suite(index)
28 self._ebpf_makeclean()
30 def add_args(self, parser):
31 super().add_args(parser)
33 self.argparser_group = self.argparser.add_argument_group(
34 'buildebpf',
35 'options for buildebpfPlugin')
36 self.argparser_group.add_argument(
37 '--nobuildebpf', action='store_false', default=True,
38 dest='buildebpf',
39 help='Don\'t build eBPF programs')
41 return self.argparser
43 def _ebpf_makeall(self):
44 if self.args.buildebpf:
45 self._make('all')
47 def _ebpf_makeclean(self):
48 if self.args.buildebpf:
49 self._make('clean')
51 def _make(self, target):
52 command = 'make -C {} {}'.format(self.args.NAMES['EBPFDIR'], target)
53 proc = subprocess.Popen(command,
54 shell=True,
55 stdout=subprocess.PIPE,
56 stderr=subprocess.PIPE,
57 env=ENVIR)
58 (rawout, serr) = proc.communicate()
60 if proc.returncode != 0 and len(serr) > 0:
61 foutput = serr.decode("utf-8")
62 else:
63 foutput = rawout.decode("utf-8")
65 proc.stdout.close()
66 proc.stderr.close()
67 return proc, foutput