Skip to content

Commit

Permalink
ELBERT: remove weutil SUP calculated offset (#31)
Browse files Browse the repository at this point in the history
Summary:
ELBERT:
- Remove Local Mac eeprom special case for SUP. This is not needed for elbert and there is no SFP port.
- Added Elbert EEPROM CIT Test Case for Supervisor (Chassis/LC/SCD/runBMC eeprom not ready yet). This checks for local mac address for SUP being BASE + 1.

Testing:
root@bmc-oob:/usr/local/bin/tests2# python cit_runner.py --platform elbert
test_asset_tag (tests.elbert.test_eeprom.SupervisorEepromTest) ... skipped 'Test not supported on platform'
test_extended_mac_base (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_local_mac (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_location_on_fabric (tests.elbert.test_eeprom.SupervisorEepromTest) ... skipped 'Test not supported on platform'
test_mac_offset (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_odm_pcb (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_product_name (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_product_part_number (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_product_serial_number (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_system_assembly_part_number (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_system_manufacturer (tests.elbert.test_eeprom.SupervisorEepromTest) ... skipped 'Test not supported on platform'
test_system_manufacturer_date (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_version (tests.elbert.test_eeprom.SupervisorEepromTest) ... ok
test_host_mac (tests.elbert.test_host_mac.HostMacTest) ... ok
test_host_mac_zero_test (tests.elbert.test_host_mac.HostMacTest) ... ok
test_i2c_tree (tests.elbert.test_i2c.ElbertI2cTest)
check if i2c devices are created and drivers are binded properly. ... ok
test_eeprom_read (tests.elbert.test_oob_eeprom.OobEepromTest) ... ok

Ran 17 tests in 7.841s

OK (skipped=3)
Pull Request resolved: facebookexternal/openbmc.arista#31

Reviewed By: benwei13

fbshipit-source-id: dbe3654fe8
  • Loading branch information
joancaneus authored and facebook-github-bot committed Apr 22, 2020
1 parent 60aeae5 commit 0666bc0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ int main(int argc, const char *argv[])
int rc;
char local_mac[20];
uint8_t parsed_mac[6];
uint8_t sup_mac[6];

if (argc >= 2) {
fn = argv[1];
Expand All @@ -64,10 +63,6 @@ int main(int argc, const char *argv[])

read_local_mac(local_mac);
elbert_parse_mac(parsed_mac,local_mac,0);
elbert_calculate_mac(parsed_mac, -1, sup_mac);
if (!strcmp(fn, "SUP"))
for (int i = 0; i < 6; i++)
parsed_mac[i] = sup_mac[i];

printf("Wedge EEPROM %s:\n", fn ? fn : "");
printf("Version: %d\n", eeprom.fbw_version);
Expand Down
105 changes: 105 additions & 0 deletions tests2/tests/elbert/test_eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
#
# Copyright 2020-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#

import re
import unittest

from common.base_eeprom_test import CommonEepromTest
from utils.cit_logger import Logger
from utils.shell_util import run_shell_cmd


class ELBERTEepromTest(CommonEepromTest):
"""
Base Class for ELBERT EEPROM fields.
"""

# On all ELBERT EEPROM, product name is always ELBERT, even PIMs (LCs)
def set_product_name(self):
self.product_name = ["ELBERT"]

# Masking out the fields that is not populated in ELBERT
def test_odm_pcb(self):
self.get_eeprom_info()
self.assertIn("ODM PCBA Part Number", self.eeprom_info)

@unittest.skip("Test not supported on platform")
def test_asset_tag(self):
return

@unittest.skip("Test not supported on platform")
def test_system_manufacturer(self):
return

def test_system_manufacturer_date(self):
self.get_eeprom_info()
# Only Manufacturing date is populated
self.assertIn("System Manufacturing Date", self.eeprom_info)

@unittest.skip("Test not supported on platform")
def test_location_on_fabric(self):
return

def test_system_assembly_part_number(self):
self.get_eeprom_info()
self.assertIn("System Assembly Part Number", self.eeprom_info)


# ELBERT SUP has even fewer fields populated. So we will not test against
# those empty fields.
class SupervisorEepromTest(ELBERTEepromTest, unittest.TestCase):
"""
Test for weutil SUP
"""

def set_eeprom_cmd(self):
self.eeprom_cmd = ["/usr/bin/weutil SUP"]

def run_eeprom_cmd(self):
self.assertNotEqual(self.eeprom_cmd, None, "EEPROM command not set")
Logger.info("Running EEPROM command: " + str(self.eeprom_cmd))
self.eeprom_info = run_shell_cmd(cmd=self.eeprom_cmd, ignore_err=True)
Logger.info(self.eeprom_info)
return self.eeprom_info

def test_mac_offset(self):
# Make sure LocalMac is the same as Base + 1
#
self.get_eeprom_info()
macRe = r"[0-9a-fA-F:]{17}"
localMacRe = r"Local MAC: ({})".format(macRe)
baseMacRe = r"Extended MAC Base: ({})".format(macRe)
localMac = re.search(localMacRe, self.eeprom_info)
self.assertNotEqual(localMac, None, "Local MAC address not found")
baseMac = re.search(baseMacRe, self.eeprom_info)
self.assertNotEqual(baseMac, None, "Extended MAC base address not found")

# Convert MAC to hex
localMac = hex(int(localMac.group(1).replace(":", ""), 16))
baseMac = hex(int(baseMac.group(1).replace(":", ""), 16))

# We expect Local mac to be BASE + 1 for ELBERT
expectedBaseMac = hex((int(baseMac, 16) + 1))
self.assertEqual(
localMac, expectedBaseMac, "Local Mac is does not match expected value"
)


# ELBERTTODO Chassis/LC/SCD/AST2620 Support

0 comments on commit 0666bc0

Please sign in to comment.