-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hostmac,bmcutil,gpiopresence tests
Summary: This diff adds 3 tests : 1) checking hostmac using wedge_us_mac.sh availability 2) Running through non disruptive shell scripts and they do no return non-zero error exit status 3) GPIO presence test: Tests presence of GPIOs present and their values - > Also adds a handy script to get this list of gpionames that have in /tmp Test Plan: [vineelak@devbig609 tools{cit_flitr}]$ python CLI.py wedge100.json rsw1dc.23.snc1 --verbose DEBUG DEBUG - Executing host MAC command: /usr/local/bin/wedge_us_mac.sh DEBUG - Received host MAC=00:90:fb:5c:97:f9: Host Mac Test [PASSED] GPIO test : .... DEBUG - GPIO name=BMC_READY_N present DEBUG - reading path=/tmp/gpionames/BMC_READY_N/active_low data=0 DEBUG - reading path=/tmp/gpionames/BMC_READY_N/direction data=in DEBUG - reading path=/tmp/gpionames/BMC_READY_N/edge data=none DEBUG - reading path=/tmp/gpionames/BMC_READY_N/value data=1 DEBUG - GPIO name=ISO_COM_PWROK present DEBUG - reading path=/tmp/gpionames/ISO_COM_PWROK/active_low data=0 DEBUG - reading path=/tmp/gpionames/ISO_COM_PWROK/direction data=in DEBUG - reading path=/tmp/gpionames/ISO_COM_PWROK/edge data=none DEBUG - reading path=/tmp/gpionames/ISO_COM_PWROK/value data=1 DEBUG - GPIO name=SWITCH_MDIO present DEBUG - reading path=/tmp/gpionames/SWITCH_MDIO/active_low data=0 DEBUG - reading path=/tmp/gpionames/SWITCH_MDIO/direction data=in DEBUG - reading path=/tmp/gpionames/SWITCH_MDIO/edge data=none DEBUG - reading path=/tmp/gpionames/SWITCH_MDIO/value data=1 GPIO test [PASSED] D10858233: flitr runs for these Reviewed By: tomrepo fbshipit-source-id: d4cd37ed9
- Loading branch information
1 parent
deb0da2
commit d46d765
Showing
13 changed files
with
734 additions
and
4 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
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,66 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
import sys | ||
import unitTestUtil | ||
import logging | ||
import os | ||
import time | ||
|
||
def read_data(path): | ||
handle = open(path, "r") | ||
data = handle.readline().rstrip() | ||
handle.close() | ||
logger.debug("reading path={} data={}".format(path, data)) | ||
return data | ||
|
||
|
||
def gpio_test(data): | ||
""" | ||
given a json of gpios and expected values, check that all of the gpios | ||
exist and its values | ||
""" | ||
for gpioname, v in data['gpios'].items(): | ||
gpio_path = "/tmp/gpionames/" + str(gpioname) | ||
if not os.path.exists(gpio_path): | ||
print("GPIO test : Missing GPIO={} [FAILED]".format(gpioname)) | ||
sys.exit(1) | ||
else: | ||
logger.debug("GPIO name={} present".format(gpioname)) | ||
checker = [ | ||
"active_low", | ||
"direction", | ||
"edge", | ||
"value" | ||
] | ||
for item in checker: | ||
vpath = gpio_path + "/" + item | ||
rdata = read_data(vpath) | ||
jdata = v[item] | ||
if rdata not in jdata: | ||
print("GPIO test : Incorrect {} for GPIO={} [FAILED]".format(item, gpioname)) | ||
sys.exit(1) | ||
print("GPIO test [PASSED]") | ||
sys.exit(0) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Input to this file should look like the following: | ||
python gpioTest.py gpiolist.json | ||
""" | ||
util = unitTestUtil.UnitTestUtil() | ||
logger = util.logger(logging.WARN) | ||
try: | ||
data = {} | ||
args = util.Argparser(['json', '--verbose'], [str, None], | ||
['json file', | ||
'output all steps from test with mode options: DEBUG, INFO, WARNING, ERROR']) | ||
if args.verbose is not None: | ||
logger = util.logger(args.verbose) | ||
data = util.JSONparser(args.json) | ||
gpio_test(data) | ||
except Exception as e: | ||
print("GPIO test [FAILED]") | ||
print("Error code returned: " + str(e)) | ||
sys.exit(1) |
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,58 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
import subprocess | ||
import sys | ||
import unitTestUtil | ||
import logging | ||
import re | ||
|
||
|
||
def mac_verify(read_mac): | ||
if re.match("[0-9a-f]{2}([:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", | ||
read_mac.lower()): | ||
return True | ||
return False | ||
|
||
|
||
def hostmacTest(util): | ||
utilCMD = util.HostMacCmd | ||
if utilCMD is None: | ||
raise Exception("Host MAC command not implemented") | ||
|
||
logger.debug("Executing host MAC command: " + str(utilCMD)) | ||
info = subprocess.check_output(utilCMD).decode() | ||
logger.debug("Received host MAC={} ".format(info)) | ||
success = mac_verify(info) | ||
if success: | ||
print("Host Mac Test [PASSED]") | ||
sys.exit(0) | ||
else: | ||
print("Host Mac Test received MAC={} [FAILED]".format(info)) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
""" | ||
Input to this file should look like the following: | ||
python hostMac_test.py type=wedge | ||
""" | ||
util = unitTestUtil.UnitTestUtil() | ||
logger = util.logger(logging.WARN) | ||
try: | ||
args = util.Argparser(['type', '--verbose'], [str, None], | ||
['a platform type', | ||
'output all steps from test with mode options: DEBUG, INFO, WARNING, ERROR']) | ||
platformType = args.type | ||
if args.verbose is not None: | ||
logger = util.logger(args.verbose) | ||
utilType = util.importUtil(platformType) | ||
hostmacTest(utilType) | ||
except Exception as e: | ||
if type(e) == KeyError: | ||
print("No support for platform type given or none given [FAILED]") | ||
else: | ||
print("Host Mac Test [FAILED]") | ||
print("Error: " + str(e)) | ||
sys.exit(1) |
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
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
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 |
---|---|---|
|
@@ -43,5 +43,6 @@ | |
"processRunningTest.py":["yes", | ||
{ | ||
"json":"../wedge/unittests/process.json" | ||
}] | ||
}], | ||
"hostMacTest.py":"yes" | ||
} |
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
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,38 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
import json | ||
import subprocess | ||
|
||
# README: Copy this file over to target and run from /tmp/gpiosnames" | ||
|
||
def gen_gpio_json(): | ||
''' | ||
Following method will read every gpio for contents and publish a json file | ||
at /tmp/gpiolist.json | ||
''' | ||
result = {} | ||
presult = {} | ||
cmd = "ls -1" | ||
gpio_list = subprocess.check_output(cmd, shell=True).decode().splitlines() | ||
for item in gpio_list: | ||
cmd = "cat /tmp/gpionames/" + item + "/" + "direction" | ||
result['direction'] = subprocess.check_output(cmd, shell=True).decode().strip('\n') | ||
cmd = "cat /tmp/gpionames/" + item + "/" + "active_low" | ||
result['active_low'] = subprocess.check_output(cmd, shell=True).decode().strip('\n') | ||
cmd = "cat /tmp/gpionames/" + item + "/" + "edge" | ||
result['edge'] = subprocess.check_output(cmd, shell=True).decode().strip('\n') | ||
cmd = "cat /tmp/gpionames/" + item + "/" + "value" | ||
result['value'] = subprocess.check_output(cmd, shell=True).decode().strip('\n') | ||
presult[item] = result | ||
result = {} | ||
fresult = { | ||
"gpios": presult | ||
} | ||
handle = open("/tmp/gpiolist.json", "a+") | ||
handle.write(json.dumps(fresult)) | ||
handle.close() | ||
|
||
if __name__ == "__main__": | ||
gen_gpio_json() |
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
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
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
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,6 @@ | ||
[ | ||
"/usr/local/bin/cp2112_i2c_flush.sh", | ||
"/usr/local/bin/cpld_rev.sh", | ||
"/usr/local/bin/ec_version.sh", | ||
"/usr/local/bin/wedge_us_mac.sh" | ||
] |
Oops, something went wrong.