Beispiel #1
0
 def kill_fan_controller(self):
     '''
     Helper method to kill fan controller: FSCD, fand
     '''
     self.assertNotEqual(self.kill_fan_ctrl_cmd, None, "Kill Fan Controller cmd not set")
     for cmd in self.kill_fan_ctrl_cmd:
         run_shell_cmd(cmd)
Beispiel #2
0
    def set_endpoint_sensors_attributes(self):
        self.endpoint_sensors_attrb = [
            "ncp4200-i2c-1-60",
            "ncp4200-i2c-2-60",
            "tmp75-i2c-3-48",
            "tmp75-i2c-3-49",
            "tmp75-i2c-3-4a",
            "fb_panther_plus-i2c-4-40",
            "max127-i2c-6-28",
            "ncp4200-i2c-8-60",
            "adm1278-i2c-12-10",
        ]

        psu_i2c_devices = run_shell_cmd(cmd=RestEndpointTest.PSU_I2C_CMD)
        if RestEndpointTest.PSU1_I2C_DEVICE in psu_i2c_devices:
            self.endpoint_sensors_attrb.append(
                RestEndpointTest.PSU1_I2C_DEVICE)
        if RestEndpointTest.PSU2_I2C_DEVICE in psu_i2c_devices:
            self.endpoint_sensors_attrb.append(
                RestEndpointTest.PSU2_I2C_DEVICE)

        adc_detected = run_shell_cmd(cmd=RestEndpointTest.LIST_ADC_CMD)
        for name in RestEndpointTest.ASPEED_ADC_DEVICES:
            if name in adc_detected:
                self.endpoint_sensors_attrb.append(name)

        pwm_detected = run_shell_cmd(cmd=RestEndpointTest.LIST_PWM_CMD)
        for name in RestEndpointTest.ASPEED_PWM_DEVICES:
            if name in pwm_detected:
                self.endpoint_sensors_attrb.append(name)
Beispiel #3
0
    def setUp(self):
        self.brd_type = pal_get_board_type()
        if self.brd_type is None:
            self.fail("Get board type failed!")
        elif self.brd_type == "Wedge400":
            Logger.info(
                "[FSCD Testing] skip Wedge400C fscd test on {} platform".format(
                    self.brd_type
                )
            )
            self.skipTest(
                "skip Wedge400C fscd test on {} platform".format(self.brd_type)
            )
        elif self.brd_type == "Wedge400C":
            config_file = "fsc-config-wedge400c.json"
            Logger.info(
                "[FSCD Testing] test fscd on {} platform with config file {}".format(
                    self.brd_type, config_file
                )
            )
        else:
            self.fail("Invalid platform!")

        # Backup original config
        run_shell_cmd("cp /etc/fsc/zone-w400c.fsc /etc/fsc/zone-w400c.fsc.orig")
        # Overwrite fscd config
        run_shell_cmd(
            "cp {}/zone-w400c.fsc /etc/fsc/zone-w400c.fsc".format(
                super().TEST_DATA_PATH
            )
        )
        super().setUp(config=config_file, test_data_path=super().TEST_DATA_PATH)
Beispiel #4
0
    def restart_fscd(self):
        if running_systemd():
            run_shell_cmd("/bin/systemctl restart fscd")
        else:
            run_shell_cmd("sv restart fscd")

        time.sleep(20)
Beispiel #5
0
 def start_fan_controller(self):
     '''
     Helper method to start fan controller: FSCD, fand
     '''
     self.assertNotEqual(self.start_fan_ctrl_cmd, None, "Kill Fan Controller cmd not set")
     for cmd in self.start_fan_ctrl_cmd:
         run_shell_cmd(cmd)
     time.sleep(10)  # allow time for fans to be properly set
Beispiel #6
0
    def test_kv_get_key(self):
        self.set_kv_keys()
        self.assertNotEqual(self.kv_keys, None, "Expected set of kv keys not set")

        for key in self.kv_keys:
            with self.subTest(key=key):
                cmd = "/usr/bin/kv get {} persistent".format(key)
                run_shell_cmd(cmd)
Beispiel #7
0
 def set_fan_speed(self, fan_id, pwm):
     '''
     Helper function to set fan speed
     '''
     cmd = '/usr/local/bin/fan-util --set ' + str(pwm)  + ' ' + str(fan_id)
     Logger.debug("Executing: {}".format(cmd))
     run_shell_cmd(cmd)
     time.sleep(10)  # allow time for fans to be properly set
Beispiel #8
0
 def set_all_fans_speed(self, pwm):
     """
     Helper function to set fan speed
     """
     cmd = "/usr/local/bin/fan-util --set " + str(pwm)
     Logger.debug("Executing: {}".format(cmd))
     run_shell_cmd(cmd)
     time.sleep(10)  # allow time for fans to be properly set
Beispiel #9
0
 def test_psumuxmon_runit_sv_status(self):
     if running_systemd():
         cmd = ["/bin/systemctl status psumuxmon"]
         data = run_shell_cmd(cmd)
         self.assertIn("running", data, "psumuxmon unit not running")
     else:
         cmd = ["/usr/bin/sv status psumuxmon"]
         data = run_shell_cmd(cmd)
         self.assertIn("run", data, "psumuxmon process not running")
Beispiel #10
0
 def set_fan_speed(self, fan_id, pwm):
     """
     Helper function to set fan speed
     """
     self.assertNotEqual(self.write_fans_cmd, None, "Set Fan cmd not set")
     cmd = self.write_fans_cmd + " " + str(pwm) + " " + str(fan_id)
     Logger.debug("Executing: {}".format(cmd))
     run_shell_cmd(cmd)
     time.sleep(10)  # allow time for fans to be properly set
Beispiel #11
0
 def kill_watchdog_daemon(self):
     '''
     Helper method to kill watchdog daemon: FSCD, fand, healthd
     '''
     self.set_kill_watchdog_daemon_cmd()
     self.assertNotEqual(self.kill_watchdog_daemon_cmd, None,
         "Kill watchdog daemon controller cmd not set")
     Logger.info("killing watchdog-kicking daemon processes")
     for cmd in self.kill_watchdog_daemon_cmd:
         run_shell_cmd(cmd)
Beispiel #12
0
 def test_eeprom_read(self):
     data = run_shell_cmd("{} read 0x0".format(
         self.eeprom_util)).split("\n")
     self.assertIn("0x0: 0xa8", data[0], "OOB EEPROM magic code missing")
     data = run_shell_cmd("{} read 0x3ff".format(
         self.eeprom_util)).split("\n")
     m = re.match(r"0x3ff: (0x[0-9a-f]+)", data[0])
     self.assertIsNotNone(
         m, "Could not parse version word: {}".format(data[0]))
     version = int(m.group(1), 0)
     self.assertGreater(version, 0, "Invalid version: {}".format(version))
Beispiel #13
0
 def tearDown(self):
     #
     # Step 6: restore watchdog-kicking daemon process.
     #
     Logger.info("Restoring watchdog-kicking process")
     self.set_start_watchdog_daemon_cmd()
     self.assertNotEqual(self.start_watchdog_daemon_cmd, None,
         "Starting watchdog daemon controller cmd not set")
     for cmd in self.start_watchdog_daemon_cmd:
         run_shell_cmd(cmd)
     sleep(10) # wait before daemon started back
Beispiel #14
0
    def run_pwm_test(
        self,
        userver_temp=DEFAULT_TEMP,
        switch_temp=DEFAULT_TEMP,
        intake_temp=DEFAULT_TEMP,
        outlet_temp=DEFAULT_TEMP,
        expected_pwm=28,
    ):

        PWM_VAL = expected_pwm
        Logger.info("[FSCD Testing] Setting (userver={}C, switch={}C ,"
                    "intake={}C, outlet={}C, expected pwm={})".format(
                        int(userver_temp) / 1000,
                        int(switch_temp) / 1000,
                        int(intake_temp) / 1000,
                        int(outlet_temp) / 1000,
                        int(expected_pwm),
                    ))
        run_shell_cmd("echo {} > {}/userver/temp1_input".format(
            userver_temp, self.TEST_DATA_PATH))
        run_shell_cmd("echo {} > {}/switch/temp1_input".format(
            switch_temp, self.TEST_DATA_PATH))
        run_shell_cmd("echo {} > {}/intake/temp1_input".format(
            intake_temp, self.TEST_DATA_PATH))
        run_shell_cmd("echo {} > {}/outlet/temp1_input".format(
            outlet_temp, self.TEST_DATA_PATH))

        # Wait for fans to change PWM
        time.sleep(10)
        return self.get_fan_pwm(pwm_val=PWM_VAL)
Beispiel #15
0
    def test_mdio_read(self):
        # Test the IMP port state register
        data = run_shell_cmd("{} read8 0x0 0xe".format(
            self.mdio_util)).split("\n")
        self.assertIn("0x0/0xe 0x87", data[0],
                      "unexpected OOB MDIO IMP port state value")

        # Test writing/reading to unused port-2
        run_shell_cmd("{} write8 0x0 0x2 0x3".format(self.mdio_util))
        data = run_shell_cmd("{} read8 0x0 0x2".format(
            self.mdio_util)).split("\n")
        self.assertIn("0x0/0x2 0x3", data[0],
                      "unexpected OOB MDIO port 2 state value")
        run_shell_cmd("{} write8 0x0 0x2 0x0".format(self.mdio_util))
        data = run_shell_cmd("{} read8 0x0 0x2".format(
            self.mdio_util)).split("\n")
        self.assertIn("0x0/0x2 0x0", data[0],
                      "unexpected OOB MDIO port 2 state value")

        # Validate 64-bit counter register. Only validate the format, not the value itself.
        data = run_shell_cmd("{} read64 0x28 0x0".format(
            self.mdio_util)).split("\n")
        m = re.match(r"0x28/0x0 \S+ ==( [01]{4}){16}", data[0])
        self.assertIsNotNone(m,
                             "Failed to retrieve OOB MDIO 64-bit TX counter")
Beispiel #16
0
 def test_cpld_version_sysfs_path_access(self):
     for path in self.cpld_paths:
         with self.subTest(path=path):
             cmd = "head -n 1 " + path
             data = run_shell_cmd(cmd).rstrip("\n")
             self.assertTrue(int(data, 16),
                             "CPLD major version is not digit")
Beispiel #17
0
 def get_fan_speed(self, fan_id=None):
     self.assertNotEqual(self.read_fans_cmd, None, "Get Fan cmd not set")
     cmd = self.read_fans_cmd
     if fan_id:
         cmd = self.read_fans_cmd + " " + str(fan_id)
     Logger.debug("Executing: {}".format(cmd))
     return run_shell_cmd(cmd)
Beispiel #18
0
 def get_installed_kmods(self):
     self.set_kmod_cmd()
     self.assertNotEqual(self.kmod_cmd, None,
                         "Command to get kmod is not set")
     Logger.info("Executing cmd={}".format(self.kmod_cmd))
     info = run_shell_cmd(cmd=self.kmod_cmd)
     return info
Beispiel #19
0
    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)
        Logger.info(self.eeprom_info)
        return self.eeprom_info
Beispiel #20
0
    def setUp(self, config=None, test_data_path=None):
        """
        Series of tests that are driven by changing the temperature sensors
        """
        Logger.start(name=self._testMethodName)
        self.assertNotEqual(config, None, "FSC TEST config needs to be set")
        self.assertNotEqual(test_data_path, None, "FSC TEST data path needs to be set")

        # Backup original config
        run_shell_cmd("cp /etc/fsc-config.json /etc/fsc-config.json.orig")
        # Copy test config to fsc-config and restart fsc

        run_shell_cmd(
            "cp {}/{} /etc/fsc-config.json".format(test_data_path, str(config))
        )
        self.restart_fscd()
 def test_cpld_revision_format(self):
     '''
     cpld_rev returns X.X
     '''
     version = run_shell_cmd(self.cpld_rev).rstrip('\n').split(".")
     self.assertTrue(version[0].isdigit(),"CPLD major version is not digit, received={}".format(version))
     self.assertTrue(version[1].isdigit(),"CPLD minor version is not digit, received={}".format(version))
Beispiel #22
0
    def parse_sensors(self):
        self.set_sensors_cmd()
        data = run_shell_cmd(self.sensors_cmd)
        if "not present" in data:
            return {"present": False}
        result = {"present": True}
        # VCCGBE VR Vol                (0x54) :    1.05 Volts | (ok)
        # SOC DIMMA1 Temp              (0xB5) : NA | (na)
        name_regex = re.compile(r"^(.+)\s+\(0x.+\)\s*")

        for edata in data.split("\n"):
            try:
                adata = edata.split(" : ")
                sensor_name = name_regex.match(adata[0]).group(1).strip()
                value_group = adata[1].split(" | ")
                value_units = value_group[0].strip().split(" ")
                sensor_value = value_units[0].strip()
                if sensor_value == "NA":
                    sensor_value = str(0)
                result[sensor_name] = sensor_value
                # Save for future use.
                # sensor_status = value_group[1]
                # sensor_units = "NA"
                # if len(value_units) == 2:
                #     sensor_units = value_units[1].strip()
            except Exception:
                Logger.error("Cannot parse: {}".format(edata))
        return result
Beispiel #23
0
    def run_pem_cmd(self):
        self.set_pem_cmd()
        self.assertNotEqual(self.pem_cmd, None, "PEM command not set")

        Logger.info("Running PEM command: " + str(self.pem_cmd))
        self.pem_info = run_shell_cmd(cmd=self.pem_cmd)
        Logger.info(self.pem_info)
        return self.pem_info
Beispiel #24
0
 def get_json_threshold_result(self):
     self.set_sensors_cmd()
     self.sensors_cmd[0] += " --json --threshold"
     data = run_shell_cmd(self.sensors_cmd)
     if "not present" in data:
         return {"present": False}
     result = {"present": True}
     result.update(json.loads(data))
     return result
 def test_host_mac(self):
     self.set_host_mac()
     self.assertNotEqual(self.host_mac_cmd, None,
                         "Host MAC command not set")
     Logger.info("Executing cmd={}".format(self.host_mac_cmd))
     info = run_shell_cmd(cmd=self.host_mac_cmd)
     self.assertTrue(
         mac_verify(info), "Host MAC is incorrectly formatted to \
                     {}".format(info))
 def test_host_mac_zero_test(self):
     self.set_host_mac()
     self.assertNotEqual(self.host_mac_cmd, None,
                         "Host MAC command not set")
     Logger.info("Executing cmd={}".format(self.host_mac_cmd))
     info = run_shell_cmd(cmd=self.host_mac_cmd)
     zero_mac = '00:00:00:00:00:00'
     self.assertNotEqual(info, zero_mac,
                         "Host MAC is zeros {}".format(info))
 def test_ec_revision_format(self):
     '''
     ec version returns version and date
     '''
     data = run_shell_cmd(self.ec_version).split("\n")
     self.assertIn("EC Released Version", data[0],
                   "EC released version missing received={}".format(data))
     self.assertIn("EC Released Date", data[1],
                   "EC released date missing received={}".format(data))
Beispiel #28
0
 def get_fw_upgrade_utils(self):
     self.set_fw_upgrade_utils_cmd()
     self.assertNotEqual(
         self.fw_upgrade_utils_cmd,
         None,
         "Command to get fw upgrade utils is not set",
     )
     Logger.info("Executing cmd={}".format(self.fw_upgrade_utils_cmd))
     info = run_shell_cmd(cmd=self.fw_upgrade_utils_cmd)
     return info
Beispiel #29
0
 def get_fan_speed(self, fan_id=None):
     """
     Helper function to get fan speed
     """
     cmd = "/usr/local/bin/fan-util --get"
     if fan_id is not None:
         cmd = cmd + " " + str(fan_id)
     Logger.debug("Executing: {}".format(cmd))
     ret = run_shell_cmd(cmd)
     return ret
Beispiel #30
0
    def test_scd_fpga_revision_format(self):
        data = run_shell_cmd(self.fpga_version).split("\n")
        self.assertIn("SCD_FPGA", data[3],
                      "SCD_FPGA missing received={}".format(data))

        value = data[3].split(":")[1]
        self.assertRegex(
            value,
            r"\b[0-9]+\.[0-9]+\b",
            "SCD_FPGA version {} isn't numeric".format(value),
        )