video_VideoDecodeMemoryUsage: Use graphic_utils to get memory usage.
BUG=chromium:593495
TEST=Run the test on peach_pi.
Change-Id: I4fac89b8ab612a83640990849e9b343a0ef39f16
Reviewed-on: https://chromium-review.googlesource.com/451168
Commit-Ready: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
(cherry picked from commit 15c4b3f3e036cdd7b4db2bbaa61884d0cfce22ea)
Reviewed-on: https://chromium-review.googlesource.com/505863
Reviewed-by: Owen Lin <owenlin@chromium.org>
Commit-Queue: Owen Lin <owenlin@chromium.org>
diff --git a/client/site_tests/video_VideoDecodeMemoryUsage/video_VideoDecodeMemoryUsage.py b/client/site_tests/video_VideoDecodeMemoryUsage/video_VideoDecodeMemoryUsage.py
index c264d49..7a3377b 100644
--- a/client/site_tests/video_VideoDecodeMemoryUsage/video_VideoDecodeMemoryUsage.py
+++ b/client/site_tests/video_VideoDecodeMemoryUsage/video_VideoDecodeMemoryUsage.py
@@ -12,6 +12,7 @@
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import chrome
+from autotest_lib.client.cros.graphics import graphics_utils
TEST_PAGE = 'content.html'
@@ -68,30 +69,10 @@
MEM_TOTAL_ENTRY = 'MemTotal'
-# Paths of files to read graphics memory usage from
-AMDGPU_GEM_OBJECTS_PATH = '/sys/kernel/debug/dri/0/amdgpu_gem_info'
-ARM_GEM_OBJECTS_PATH = '/sys/kernel/debug/dri/0/exynos_gem_objects'
-X86_GEM_OBJECTS_PATH = '/sys/kernel/debug/dri/0/i915_gem_objects'
-
-GEM_OBJECTS_PATH = {'amdgpu' : AMDGPU_GEM_OBJECTS_PATH,
- 'exynos5' : ARM_GEM_OBJECTS_PATH,
- 'x86_64' : X86_GEM_OBJECTS_PATH}
-
-
-# To parse the content of the files abvoe. The first line looks like:
-# "432 objects, 272699392 bytes"
-GEM_OBJECTS_RE = re.compile('(\d+)\s+objects,\s+(\d+)\s+bytes')
-
-# To parse the content of amdgpu_gem_info.
-# Example : bo[0x000000af] 1024kB
-AMDGPU_GEM_OBJECTS_RE = re.compile(r'(bo\[\w+\])\s+(\d+)')
# The default sleep time, in seconds.
SLEEP_TIME = 1.5
-_AMD_PCI_IDS_FILE_PATH = '/usr/local/autotest/bin/amd_pci_ids.json'
-_INTEL_PCI_IDS_FILE_PATH = '/usr/local/autotest/bin/intel_pci_ids.json'
-
def _get_kernel_memory_usage():
with file(MEMINFO_PATH) as f:
mem_info = {x.group(1): int(x.group(2))
@@ -99,47 +80,17 @@
# Sum up the kernel memory usage (in KB) in mem_info
return sum(map(mem_info.get, KERNEL_MEMORY_ENTRIES))
-def get_gem_path_from_gpu(gpu):
- if 'mali' in gpu:
- if utils.get_cpu_soc_family() == 'exynos5':
- return 'exynos5'
- if gpu in open(_AMD_PCI_IDS_FILE_PATH).read():
- return 'amdgpu'
- if gpu in open(_INTEL_PCI_IDS_FILE_PATH).read():
- return 'x86_64'
- return None
-
def _get_graphics_memory_usage():
"""Get the memory usage (in KB) of the graphics module."""
- gpu = utils.get_gpu_family()
- gem_path = get_gem_path_from_gpu(gpu)
- if gem_path in GEM_OBJECTS_PATH:
- path = GEM_OBJECTS_PATH[gem_path]
- else:
- raise error.TestFail('Error: gem_path for gpu "%s" not specified.' % gpu)
- try:
- with open(path, 'r') as input:
- if gem_path is 'amdgpu':
- usage = 0
- for line in input:
- result = AMDGPU_GEM_OBJECTS_RE.match(line)
- if result:
- usage += int(result.group(2))
- if usage:
- return usage # in KB
- else :
- for line in input:
- result = GEM_OBJECTS_RE.match(line)
- if result:
- return int(result.group(2)) / 1024 # in KB
- except IOError as e:
- if e.errno == os.errno.ENOENT: # no such file
- logging.warning('graphics memory info is not available.')
- return 0
- raise
+ key = 'gem_objects_bytes'
+ graphics_kernel_memory = graphics_utils.GraphicsKernelMemory()
+ usage = graphics_kernel_memory.get_memory_keyvals().get(key, 0)
- raise error.TestError('Cannot parse the content')
+ if graphics_kernel_memory.num_errors:
+ logging.warning('graphics memory info is not available')
+ return 0
+ return usage
def _get_linear_regression_slope(x, y):
"""