1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from vstf.common.utils import check_call, check_output
14 LOG = logging.getLogger(__name__)
17 def get_pid_by_name(process_name):
18 out = check_output(['ps', '-A'])
20 for line in out.splitlines():
22 pid, name = values[0], values[3]
23 if process_name == name:
29 cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip()
30 cpu_num = int(cpu_num)
34 def get_default_threads():
35 cpu_num = get_cpu_num()
36 return 2 if cpu_num > 3 * 3 else 1
39 def modprobe_pktgen():
40 check_call('modprobe pktgen', shell=True)
45 check_call("ifconfig %s up" % device, shell=True)