forked from crosswalk-project/chromium-crosswalk
-
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.
[Telemetry] Consider linux distribution number is 0 when it cannot be…
… parsed On some linux distributions, the DISTRIB_RELEASE field of /etc/lsb-release cannot be parsed as a float. In that case, consider it will be 0 R= BUG=393022 Review URL: https://codereview.chromium.org/381293003 Cr-Commit-Position: refs/heads/master@{#291481} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291481 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
1 parent
9cfb9ff
commit bc0b4d2
Showing
4 changed files
with
90 additions
and
8 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
72 changes: 72 additions & 0 deletions
72
tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.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,72 @@ | ||
# Copyright 2014 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import os | ||
import unittest | ||
|
||
from telemetry import decorators | ||
from telemetry.core import util | ||
from telemetry.core.platform import linux_platform_backend | ||
|
||
class TestBackend( | ||
linux_platform_backend.LinuxPlatformBackend): | ||
|
||
def __init__(self): | ||
super(TestBackend, self).__init__() | ||
self._mock_files = {} | ||
|
||
def SetMockFile(self, filename, output): | ||
self._mock_files[filename] = output | ||
|
||
def _GetFileContents(self, filename): | ||
return self._mock_files[filename] | ||
|
||
def StartRawDisplayFrameRateMeasurement(self): | ||
raise NotImplementedError() | ||
|
||
def StopRawDisplayFrameRateMeasurement(self): | ||
raise NotImplementedError() | ||
|
||
def GetRawDisplayFrameRateMeasurements(self): | ||
raise NotImplementedError() | ||
|
||
def IsThermallyThrottled(self): | ||
raise NotImplementedError() | ||
|
||
def HasBeenThermallyThrottled(self): | ||
raise NotImplementedError() | ||
|
||
def GetSystemCommitCharge(self): | ||
raise NotImplementedError() | ||
|
||
def StopVideoCapture(self): | ||
raise NotImplementedError() | ||
|
||
def StartVideoCapture(self, min_bitrate_mbps): | ||
raise NotImplementedError() | ||
|
||
def GetSystemTotalPhysicalMemory(self): | ||
raise NotImplementedError() | ||
|
||
|
||
class LinuxPlatformBackendTest(unittest.TestCase): | ||
@decorators.Enabled('linux') | ||
def testGetOSVersionNameSaucy(self): | ||
backend = TestBackend() | ||
path = os.path.join(util.GetUnittestDataDir(), 'ubuntu-saucy-lsb-release') | ||
with open(path) as f: | ||
backend.SetMockFile('/etc/lsb-release', f.read()) | ||
|
||
self.assertEqual(backend.GetOSVersionName(), 'saucy') | ||
|
||
@decorators.Enabled('linux') | ||
def testGetOSVersionNameArch(self): | ||
backend = TestBackend() | ||
path = os.path.join(util.GetUnittestDataDir(), 'arch-lsb-release') | ||
with open(path) as f: | ||
backend.SetMockFile('/etc/lsb-release', f.read()) | ||
|
||
# a distribution may not have a codename or a release number. We just check | ||
# that GetOSVersionName doesn't raise an exception | ||
backend.GetOSVersionName() |
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,4 @@ | ||
LSB_VERSION=1.4 | ||
DISTRIB_ID=Arch | ||
DISTRIB_RELEASE=rolling | ||
DISTRIB_DESCRIPTION="Arch Linux" |
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,4 @@ | ||
DISTRIB_ID=Ubuntu | ||
DISTRIB_RELEASE=13.10 | ||
DISTRIB_CODENAME=saucy | ||
DISTRIB_DESCRIPTION="Ubuntu 13.10" |