Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
oec-hardware
提交
55b97616
O
oec-hardware
项目概览
openeuler
/
oec-hardware
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oec-hardware
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
55b97616
编写于
6月 04, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
6月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
!8 fix bug of failing to get CPU nums with LANG=zh_CN.UTF8
Merge pull request !8 from Air9/master
上级
8f95bae3
bbb93f16
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
16 deletion
+26
-16
tests/cpufreq/cpufreq.py
tests/cpufreq/cpufreq.py
+26
-16
未找到文件。
tests/cpufreq/cpufreq.py
100755 → 100644
浏览文件 @
55b97616
...
...
@@ -17,12 +17,11 @@ from time import sleep
from
hwcompatible.env
import
CertEnv
from
hwcompatible.test
import
Test
from
hwcompatible.command
import
Command
from
hwcompatible.command
import
Command
,
CertCommandError
class
CPU
:
def
__init__
(
self
):
self
.
requirements
=
[
'util-linux'
,
'kernel-tools'
]
self
.
cpu
=
None
self
.
nums
=
None
self
.
list
=
None
...
...
@@ -35,8 +34,9 @@ class CPU:
def
get_info
(
self
):
cmd
=
Command
(
"lscpu"
)
try
:
nums
=
cmd
.
get_str
(
'CPU\(s\):\s+(?P<cpus>\d+)'
,
'cpus'
,
False
)
except
:
nums
=
cmd
.
get_str
(
r
'^CPU\S*:\s+(?P<cpus>\d+)$'
,
'cpus'
,
False
)
except
CertCommandError
as
e
:
print
(
e
)
return
False
self
.
nums
=
int
(
nums
)
self
.
list
=
range
(
self
.
nums
)
...
...
@@ -44,14 +44,16 @@ class CPU:
cmd
=
Command
(
"cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
)
try
:
max_freq
=
cmd
.
get_str
()
except
:
except
CertCommandError
as
e
:
print
(
e
)
return
False
self
.
max_freq
=
int
(
max_freq
)
cmd
=
Command
(
"cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
)
try
:
min_freq
=
cmd
.
get_str
()
except
:
except
CertCommandError
as
e
:
print
(
e
)
return
False
self
.
min_freq
=
int
(
min_freq
)
...
...
@@ -62,14 +64,16 @@ class CPU:
try
:
cmd
.
run
()
return
cmd
.
returncode
except
:
except
CertCommandError
as
e
:
print
(
e
)
return
False
def
get_freq
(
self
,
cpu
):
cmd
=
Command
(
"cpupower -c %s frequency-info -w"
%
cpu
)
try
:
return
int
(
cmd
.
get_str
(
'.* frequency: (?P<freq>\d+) .*'
,
'freq'
,
False
))
except
:
return
int
(
cmd
.
get_str
(
r
'.* frequency: (?P<freq>\d+) .*'
,
'freq'
,
False
))
except
CertCommandError
as
e
:
print
(
e
)
return
False
def
set_governor
(
self
,
governor
,
cpu
=
'all'
):
...
...
@@ -77,14 +81,16 @@ class CPU:
try
:
cmd
.
run
()
return
cmd
.
returncode
except
:
except
CertCommandError
as
e
:
print
(
e
)
return
False
def
get_governor
(
self
,
cpu
):
cmd
=
Command
(
"cpupower -c %s frequency-info -p"
%
cpu
)
try
:
return
cmd
.
get_str
(
'.* governor "(?P<governor>\w+)".*'
,
'governor'
,
False
)
except
:
return
cmd
.
get_str
(
r
'.* governor "(?P<governor>\w+)".*'
,
'governor'
,
False
)
except
CertCommandError
as
e
:
print
(
e
)
return
False
def
find_path
(
self
,
parent_dir
,
target_name
):
...
...
@@ -92,7 +98,8 @@ class CPU:
try
:
cmd
.
run
()
return
cmd
.
returncode
except
:
except
CertCommandError
as
e
:
print
(
e
)
return
False
...
...
@@ -119,6 +126,12 @@ class Load:
class
CPUFreqTest
(
Test
):
def
__init__
(
self
):
Test
.
__init__
(
self
)
self
.
requirements
=
[
'util-linux'
,
'kernel-tools'
]
self
.
cpu
=
CPU
()
self
.
original_governor
=
self
.
cpu
.
get_governor
(
0
)
def
test_userspace
(
self
):
target_cpu
=
randint
(
0
,
self
.
cpu
.
nums
-
1
)
target_freq
=
randint
(
self
.
cpu
.
min_freq
,
self
.
cpu
.
max_freq
)
...
...
@@ -335,9 +348,6 @@ class CPUFreqTest(Test):
return
True
def
test
(
self
):
self
.
cpu
=
CPU
()
self
.
original_governor
=
self
.
cpu
.
get_governor
(
0
)
if
not
self
.
cpu
.
get_info
():
print
(
"[X] Fail to get CPU info."
\
" Please check if the CPU supports cpufreq."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录