Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PACKAGE_NAME := sonic-platform-pde
TOPDIR := $(shell pwd)
PYTHON ?= python2
PYTHON ?= python3

%:
dh $@
Expand Down
3 changes: 2 additions & 1 deletion sonic-pde-tests/sonic_pde_saiut/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ SAI_INC := /usr/include/sai
SAI_LIB := /usr/lib

CC := gcc
CFLAGS := -fPIC -I/usr/include/python2.7 -I$(SAI_INC)
CFLAGS := -fPIC -I/usr/include/python3.9 -I$(SAI_INC) -I$(SAI_INC)/experimental

LDFLAGS := -L$(SAI_LIB) -lsai

all: _saiut.so
Expand Down
2 changes: 2 additions & 0 deletions sonic-pde-tests/sonic_pde_saiut/saiut.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ uint32_t portGetSpeed(sai_object_id_t port);
sai_status_t portSetSpeed(sai_object_id_t port, uint32_t speed);
uint64_t portGetCounter(sai_object_id_t port, sai_stat_id_t id);
sai_status_t portClearCounter(sai_object_id_t port, sai_stat_id_t id);
sai_status_t portSetAttribute(sai_object_id_t port, sai_attribute_t *attr);
sai_status_t portGetAttribute(sai_object_id_t port, sai_attribute_t *attr);

uint32_t switchGetPortNumber(void);
sai_status_t switchShell(bool enable);
Expand Down
11 changes: 5 additions & 6 deletions sonic-pde-tests/sonic_pde_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def get_onie_pname():
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
id = pin.communicate()[0]
id = pin.communicate()[0].decode('ascii')
id = id.strip()
return id

# Copy template platform config JSON to targeted platform JSON
def create_platform_json(Pfname):
INPUT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -40,7 +40,7 @@ def create_platform_json(Pfname):
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

# Copy template platform test JSON to targeted platform JSON
def create_test_json(Tfname):
INPUT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -51,7 +51,7 @@ def create_test_json(Tfname):
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

def pytest_runtest_setup(item):
INPUT_DIR = os.path.dirname(os.path.abspath(__file__))
Pfname = os.path.join(INPUT_DIR, 'data/platform', "platform-" + get_onie_pname() + "-config.json")
Expand All @@ -64,7 +64,7 @@ def pytest_runtest_setup(item):
return
else:
create_test_json(Tfname)

@pytest.fixture(scope='function',autouse='True')
def json_config_data():
""" Loads json file """
Expand Down Expand Up @@ -92,4 +92,3 @@ def json_test_data():
contents=json.load(file_object)

return contents

2 changes: 1 addition & 1 deletion sonic-pde-tests/sonic_pde_tests/sai-shell
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

import os.path
import sys
Expand Down
28 changes: 22 additions & 6 deletions sonic-pde-tests/sonic_pde_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,27 @@ def test_for_required_bcm_config_file(json_test_data):
assert config_file != {}, "Chipset configuration file not found"

def test_for_required_bcm_config_settings(json_test_data):
"""Test Purpose: Verify that the platform config.bcm file contains mandatory Silicon supported features.
"""Test Purpose: Verify that the platform config.bcm file contains mandatory Silicon supported features
if adding in required list and do not contains any "not permitted" config setting

Args:
arg1 (json): test-<sonic_platform>-config.json

Example:
Parity should always be enabled for Broadcom switching silicon.
Parity_enable and parity_correction not permitted to be disabled for Broadcom switching silicon.

"PLATFORM": {
"CONFIG": {
"required": {
"config.bcm": [
"parity_enable=1"
"#####=##",
]
}
"CONFIG": {
"notpermitted": {
"config.bcm": [
"parity_enable=0",
"parity_correction=0"
]
}
}
Expand All @@ -64,10 +72,18 @@ def test_for_required_bcm_config_settings(json_test_data):
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
cnt = pin.communicate()[0]
print cnt
cnt = pin.communicate()[0].decode('ascii')

assert int(cnt)==1, "Required configuration property [" + pat[idx] + "] not detected"

pat = json_test_data["PLATFORM"]["CONFIG"]["notpermitted"]["config.bcm"]
for idx in range(len(pat)):
cmd = "cat " + config_file + " | grep -c -i " + pat[idx]
pin = subprocess.Popen(cmd,
shell=True,
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
cnt = pin.communicate()[0].decode('ascii')


assert int(cnt)==0, "configuration property [" + pat[idx] + "] is not allowed to be configured"
2 changes: 1 addition & 1 deletion sonic-pde-tests/sonic_pde_tests/test_cpld.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def load_platform_cpldutil(json_config_data):
platform_cpldutil_class = getattr(platform_cpldutil_module,class_name)
platform_cpldutil = platform_cpldutil_class()

except AttributeError, e:
except AttributeError as e:
print("Failed to instantiate '%s' class: %s" % (class_name, str(e)), True)

return
Expand Down
Loading