Commit 2cd67b5b authored by romax's avatar romax Committed by Commit bot

Getting OS version numbers for Linux.

Implementing the method to get OS version numbers for Linux and enabled
corresponding unit test.

BUG=NONE

Review-Url: https://codereview.chromium.org/2764593002
Cr-Commit-Position: refs/heads/master@{#458854}
parent dac09c03
......@@ -80,8 +80,6 @@ class BASE_EXPORT SysInfo {
static std::string OperatingSystemVersion();
// Retrieves detailed numeric values for the OS version.
// TODO(port): Implement a Linux version of this method and enable the
// corresponding unit test.
// DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release
// for OS version-specific feature checks and workarounds. If you must use
// an OS version check instead of a feature check, use the base::mac::IsOS*
......
......@@ -183,6 +183,30 @@ std::string SysInfo::OperatingSystemVersion() {
}
#endif
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// static
void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
int32_t* minor_version,
int32_t* bugfix_version) {
struct utsname info;
if (uname(&info) < 0) {
NOTREACHED();
*major_version = 0;
*minor_version = 0;
*bugfix_version = 0;
return;
}
int num_read = sscanf(info.release, "%d.%d.%d", major_version, minor_version,
bugfix_version);
if (num_read < 1)
*major_version = 0;
if (num_read < 2)
*minor_version = 0;
if (num_read < 3)
*bugfix_version = 0;
}
#endif
// static
std::string SysInfo::OperatingSystemArchitecture() {
struct utsname info;
......
......@@ -71,7 +71,7 @@ TEST_F(SysInfoTest, AmountOfTotalDiskSpace) {
EXPECT_GT(SysInfo::AmountOfTotalDiskSpace(tmp_path), 0) << tmp_path.value();
}
#if defined(OS_WIN) || defined(OS_MACOSX)
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
TEST_F(SysInfoTest, OperatingSystemVersionNumbers) {
int32_t os_major_version = -1;
int32_t os_minor_version = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment