1d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy#!/usr/bin/python2 2ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikas# Copyright 2017 The Chromium Authors. All rights reserved. 3d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy# Use of this source code is governed by a BSD-style license that can be 4d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy# found in the LICENSE file. 5d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 6d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy"""Unittests for the lsbrelease_utils module.""" 7d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 8d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedyimport unittest 9d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 10d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedyimport common 11d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedyfrom autotest_lib.client.common_lib import lsbrelease_utils 12d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 13d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 14d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy# pylint: disable=line-too-long 15d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy_GUADO_MOBLAB_LSB_RELEASE_REDACTED = """ 16d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyDEVICETYPE=CHROMEBOX 17ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas LiutikasCHROMEOS_RELEASE_BUILDER_PATH=guado_moblab-release/R61-9641.0.0 18d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyGOOGLE_RELEASE=9641.0.0 19d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_DEVSERVER= 20d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BOARD=guado_moblab 21d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILD_NUMBER=9641 22d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BRANCH_NUMBER=0 23d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_CHROME_MILESTONE=61 24d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_PATCH_NUMBER=0 25d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_TRACK=testimage-channel 26d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_DESCRIPTION=9641.0.0 (Official Build) dev-channel guado_moblab test 27d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILD_TYPE=Official Build 28320113721c2e14bbc2403809046fa2959a665c11Aurimas LiutikasCHROMEOS_RELEASE_NAME=Chrome OS 29320113721c2e14bbc2403809046fa2959a665c11Aurimas LiutikasCHROMEOS_RELEASE_VERSION=9641.0.0 30320113721c2e14bbc2403809046fa2959a665c11Aurimas LiutikasCHROMEOS_AUSERVER=https://tools.google.com/service/update2 31320113721c2e14bbc2403809046fa2959a665c11Aurimas Liutikas""" 32d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 33d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy_LINK_LSB_RELEASE_REDACTED = """ 34d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyDEVICETYPE=CHROMEBOOK 35d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILDER_PATH=link-release/R61-9641.0.0 36d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyGOOGLE_RELEASE=9641.0.0 378491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_DEVSERVER= 388491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BOARD=link 398491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BUILD_NUMBER=9641 408491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BRANCH_NUMBER=0 41d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_CHROME_MILESTONE=61 42d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_PATCH_NUMBER=0 438491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_TRACK=testimage-channel 44d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_DESCRIPTION=9641.0.0 (Official Build) dev-channel link test 45d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILD_TYPE=Official Build 46d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_NAME=Chrome OS 47d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_VERSION=9641.0.0 48c05db2551709fb74903cce69f3e4b9f553e607afJake WhartonCHROMEOS_AUSERVER=https://tools.google.com/service/update2 49d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy""" 50d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 51d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy_GALE_LSB_RELEASE_REDACTED = """ 528491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyDEVICETYPE=OTHER 53d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyHWID_OVERRIDE=GALE DOGFOOD 54d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILDER_PATH=gale-release/R61-9641.0.0 55d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyGOOGLE_RELEASE=9641.0.0 568491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_DEVSERVER= 578491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BOARD=gale 588491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BUILD_NUMBER=9641 59d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BRANCH_NUMBER=0 60d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_CHROME_MILESTONE=61 61d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_PATCH_NUMBER=0 62d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_TRACK=testimage-channel 638491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_DESCRIPTION=9641.0.0 (Official Build) dev-channel gale test 648491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_BUILD_TYPE=Official Build 6538f4f4174d9cd53c553f14c19746500cb861b089Ian LakeCHROMEOS_RELEASE_NAME=Chrome OS 6638f4f4174d9cd53c553f14c19746500cb861b089Ian LakeCHROMEOS_RELEASE_VERSION=9641.0.0 678491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_AUSERVER=https://tools.google.com/service/update2 6838f4f4174d9cd53c553f14c19746500cb861b089Ian Lake""" 69d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 7038f4f4174d9cd53c553f14c19746500cb861b089Ian Lake# pylint: disable=line-too-long 71d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy_WHIRLWIND_LSB_RELEASE_REDACTED = """ 72d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyDEVICETYPE=OTHER 738491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyHWID_OVERRIDE=WHIRLWIND DOGFOOD 74a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_RELEASE_BUILDER_PATH=whirlwind-release/R61-9641.0.0 75a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickGOOGLE_RELEASE=9641.0.0 76a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_DEVSERVER= 77470243f1dda6e10d8157712905c5d08b47f4fbecAbhinav BaidCHROMEOS_RELEASE_BOARD=whirlwind 78a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_RELEASE_BUILD_NUMBER=9641 79a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_RELEASE_BRANCH_NUMBER=0 80a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_RELEASE_CHROME_MILESTONE=61 81a76a4339be2f27431a167381187c3f0b0d08f1b7Daniel ResnickCHROMEOS_RELEASE_PATCH_NUMBER=0 82470243f1dda6e10d8157712905c5d08b47f4fbecAbhinav BaidCHROMEOS_RELEASE_TRACK=testimage-channel 838491eb62f621cd5de4b4caed839be09c77011f53Todd KennedyCHROMEOS_RELEASE_DESCRIPTION=9641.0.0 (Official Build) dev-channel whirlwind test 84d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_BUILD_TYPE=Official Build 8590b15311c0461be519432794b7f8e8132fb7a72cGeorge MountCHROMEOS_RELEASE_NAME=Chrome OS 86d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_RELEASE_VERSION=9641.0.0 87d608cf6e08769bf320c1b595cbbd9a7664160449Todd KennedyCHROMEOS_AUSERVER=https://tools.google.com/service/update2 888491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy""" 898491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy 908491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy 91d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedyclass LsbreleaseUtilsTestCase(unittest.TestCase): 9290b15311c0461be519432794b7f8e8132fb7a72cGeorge Mount """Validates the helper free functions in lsbrelease_utils.""" 93d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 94d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy def test_is_jetstream_with_link_lsbrelease(self): 958491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy """Test helper function.""" 968491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy self.assertFalse(lsbrelease_utils.is_jetstream( 978491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy _LINK_LSB_RELEASE_REDACTED)) 988491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy 99d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy def test_is_jetstream_with_moblab_lsbrelease(self): 100d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy """Test helper function.""" 101d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy self.assertFalse(lsbrelease_utils.is_jetstream( 102d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy _GUADO_MOBLAB_LSB_RELEASE_REDACTED)) 103d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 1048491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy def test_is_jestream_with_gale_lsbrelease(self): 1058491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy """Test helper function.""" 1068491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy self.assertTrue(lsbrelease_utils.is_jetstream( 1078491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy _GALE_LSB_RELEASE_REDACTED)) 1088491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy 1098491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy def test_is_jestream_with_whirlwind_lsbrelease(self): 1108491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy """Test helper function.""" 1118491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy self.assertTrue(lsbrelease_utils.is_jetstream( 1128491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy _WHIRLWIND_LSB_RELEASE_REDACTED)) 1138491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy 1148491eb62f621cd5de4b4caed839be09c77011f53Todd Kennedy def test_is_moblab_with_empty_lsbrelease(self): 115d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy """is_moblab correctly validates trivial lsb-release information.""" 116d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy self.assertFalse(lsbrelease_utils.is_moblab('')) 117d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 118d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy def test_is_moblab_with_link_lsbrelease(self): 119d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy """is_moblab correctly validates the contents from some other board.""" 120d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy self.assertFalse(lsbrelease_utils.is_moblab( 121d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy _LINK_LSB_RELEASE_REDACTED)) 122d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 123d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy def test_is_moblab_with_moblab_lsbrelease(self): 124d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy """is_moblab correctly validates the contents from a moblab device.""" 125d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy self.assertTrue(lsbrelease_utils.is_moblab( 126d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy _GUADO_MOBLAB_LSB_RELEASE_REDACTED)) 127d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 128d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy def test_get_chromeos_release_version(self): 129d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy """Test helper function.""" 130d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy result = lsbrelease_utils.get_chromeos_release_builder_path( 131d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy _GUADO_MOBLAB_LSB_RELEASE_REDACTED) 132d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 133d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy self.assertEqual(result, 'guado_moblab-release/R61-9641.0.0') 134d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 135d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy 136d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedyif __name__ == '__main__': 137d608cf6e08769bf320c1b595cbbd9a7664160449Todd Kennedy unittest.main() 138c077b4cd990a9f220a27ad5eca04828e17136064Adam Powell