Skip to content

Add snmpd system tests with Valgrind and fix memory leak - #19

Merged
bluecmd merged 3 commits into
bluecmd:masterfrom
SoundGoof:test/snmpd-system-valgrind
Jul 23, 2026
Merged

Add snmpd system tests with Valgrind and fix memory leak#19
bluecmd merged 3 commits into
bluecmd:masterfrom
SoundGoof:test/snmpd-system-valgrind

Conversation

@SoundGoof

Copy link
Copy Markdown
Collaborator

Summary

Add an end-to-end system-test suite that runs the public Python API against a real snmpd instance.

The suite runs normally and under Valgrind on every pull request using ubuntu-latest.

Changes

  • Add a GitHub Actions workflow for pull requests and pushes to master
  • Start an isolated SNMP agent on 127.0.0.1:1161
  • Test SNMPv1 and SNMPv2c operations
  • Test both convenience functions and Session methods
  • Cover GET, GETNEXT, GETBULK, SET, and WALK
  • Cover multiple varbinds, error paths, and session lifecycle
  • Add Varbind and VarList regression tests
  • Add a Podman environment using ubuntu:latest
  • Run all discovered tests in one Valgrind process
  • Fail CI on definite memory leaks or Valgrind errors

Memory fixes

The new Valgrind coverage found and fixed two leaks in netsnmp_walk():

  • Removed a duplicate OID buffer allocation that overwrote the original pointer
  • Freed the final unsent GETNEXT PDU when a walk completes

Verification

Tested locally with Podman using Ubuntu 26.04 LTS and Python 3.14:

Ran 31 tests ... OK
Ran 31 tests under Valgrind ... OK

definitely lost: 0 bytes
indirectly lost: 0 bytes
possibly lost: 0 bytes
ERROR SUMMARY: 0 errors

Comment thread netsnmp/client_intf.c
Comment thread .github/workflows/system-tests.yml Outdated
@SoundGoof
SoundGoof requested a review from bluecmd July 23, 2026 15:19

@bluecmd bluecmd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm but fix the awk. It's fine that the tests don't pass, we will merge it and work on fixing the issues one by one

Comment thread netsnmp/tests/system/run-coverage.sh Outdated
@bluecmd
bluecmd merged commit f1b2665 into bluecmd:master Jul 23, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants