Skip to content

Commit

Permalink
Tests For Linux
Browse files Browse the repository at this point in the history
- okay, perhaps now they pass on Linux.
  • Loading branch information
carlkidcrypto committed Nov 25, 2024
1 parent 21c0f9d commit 0ec5308
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ jobs:
pip install . --verbose
- name: Start SNMP daemon
uses: carlkidcrypto/[email protected]
with:
linux: mibdir="-M +/var/lib/snmp/mibs";
SNMPD=$(which snmpd);
$SNMPD --version;
$SNMPD -C -c tests/snmpd.conf -r -Le $mibdir -m ALL

macos: mibdir="";
SNMPD=$(which snmpd);
$SNMPD --version;
$SNMPD -C -c tests/snmpd.conf -r -Le $mibdir -m ALL
run: |
if [ "$RUNNER_OS" == "Linux" ]
then
mibdir="-M +/var/lib/snmp/mibs"
SNMPD=$(which snmpd)
elif [ "$RUNNER_OS" == "macOS" ]
then
mibdir=""
SNMPD=$(which snmpd)
else
mibdir=""
SNMPD=$(which.exe snmpd)
fi
$SNMPD -C -c tests/snmpd.conf -r -Le $mibdir -m ALL
- name: Lint with flake8
uses: py-actions/flake8@v2
Expand Down
10 changes: 5 additions & 5 deletions tests/test_netsnmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def test_snmpbulkget(netsnmp_args):
res = snmpbulkget(netsnmp_args)

assert len(res) == 50
if platform.system() == "Darwin": # Check if running on macOS
assert res[0].oid == "DISMAN-EVENT-MIB::sysUpTimeInstance"

else: # For other operating systems (e.g., Linux)
assert res[0].oid == "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"

# Checking if "sysUpTimeInstance" is in "oid" is enough. The preamble
# changes per OS system
# "DISMAN-EVENT-MIB::sysUpTimeInstance" MacOS
# "DISMAN-EXPRESSION-MIB::sysUpTimeInstance" Linux
assert "sysUpTimeInstance" in res[0].oid
assert res[0].index == ""
assert res[0].type == "Timeticks"

Expand Down
22 changes: 10 additions & 12 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ def test_session_get(sess):
for oid in ["sysUpTime.0", "sysContact.0", "sysLocation.0"]:
res = sess.get(oid)
if oid == "sysUpTime.0":
if platform.system() == "Darwin": # Check if running on macOS
assert res[0].oid == "DISMAN-EVENT-MIB::sysUpTimeInstance"

else: # For other operating systems (e.g., Linux)
assert res[0].oid == "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"

# Checking if "sysUpTimeInstance" is in "oid" is enough. The preamble
# changes per OS system
# "DISMAN-EVENT-MIB::sysUpTimeInstance" MacOS
# "DISMAN-EXPRESSION-MIB::sysUpTimeInstance" Linux
assert "sysUpTimeInstance" in res[0].oid
assert res[0].index == ""
assert res[0].type == "Timeticks"

Expand Down Expand Up @@ -286,12 +285,11 @@ def test_session_bulk_get(sess):
["sysUpTime", "sysORLastChange", "sysORID", "sysORDescr", "sysORUpTime"]
)

if platform.system() == "Darwin": # Check if running on macOS
assert res[0].oid == "DISMAN-EVENT-MIB::sysUpTimeInstance"

else: # For other operating systems (e.g., Linux)
assert res[0].oid == "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"

# Checking if "sysUpTimeInstance" is in "oid" is enough. The preamble
# changes per OS system
# "DISMAN-EVENT-MIB::sysUpTimeInstance" MacOS
# "DISMAN-EXPRESSION-MIB::sysUpTimeInstance" Linux
assert "sysUpTimeInstance" in res[0].oid
assert res[0].index == ""
assert res[0].type == "Timeticks"

Expand Down

0 comments on commit 0ec5308

Please sign in to comment.