Skip to content

Add test coverage for serial driver implementation#32

Closed
Copilot wants to merge 4 commits intogtu7from
copilot/sub-pr-16-f97cc57e-cbb0-458b-b2c0-80a16f7848bb
Closed

Add test coverage for serial driver implementation#32
Copilot wants to merge 4 commits intogtu7from
copilot/sub-pr-16-f97cc57e-cbb0-458b-b2c0-80a16f7848bb

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 16, 2026

The serial driver implementation (drivers/serial_linux.go) lacked test coverage for critical low-level logic including termios configuration, baud rate mapping, and file descriptor management.

Changes

drivers/serial_test.go - Platform-agnostic validation tests:

  • Configuration validation (empty port, zero/negative baud rates)
  • Zero value behavior
  • Edge case handling with table-driven tests

drivers/serial_linux_test.go - Linux-specific driver tests:

  • Baud rate to Unix constant conversion for all 6 supported rates (4800-115200)
  • Unsupported baud rate error handling
  • Interface compliance verification
  • Invalid configuration rejection

All tests are hermetic (no hardware interaction) and follow repository patterns (testify assertions, parallel execution, table-driven where applicable).

// Example: baud rate conversion testing
func TestBaudToUnix(t *testing.T) {
    tests := []struct {
        baud     int
        expected uint32
        wantErr  bool
    }{
        {9600, unix.B9600, false},
        {115200, unix.B115200, false},
        {230400, 0, true}, // unsupported
    }
    // ...
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 16, 2026 17:58
Added test coverage for serial driver implementation including:
- Configuration validation tests (empty port, zero/negative baud)
- Baud rate conversion tests (all supported rates + error cases)
- Error handling for invalid configs and unsupported baud rates
- Interface compliance tests
- String formatting tests

All tests are hermetic and follow testify patterns per AGENTS.md

Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Fixed test name generation in TestBaudToUnixAllSupportedRates to use
fmt.Sprintf instead of string(rune(baud)), which was producing
non-printable characters. Test names now correctly display as
"4800", "9600", etc.

Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy ions =0 ux_amd64/link go_.�� x64/src/net ache/go/1.24.11/-ifaceassert /bin/java -p internal/nettracrev-parse -lang=go1.24 /bin/java -o b:/usr/lib -trimpath nfig/composer/vendor/bin/as -p compress/flate -lang=go1.24 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-18712d6c44f9 -j DROP ertum_EC-384_CA.pem eroutfiles.txt test s/drivers/ads111git s/drivers/doc.go-c s/drivers/gpiocdlog.showsignature=false test -e 2888f65.0 s/drivers/vpio_f--format=format:%H %ct %D /usr/bin/test -v ication_Authorit--wait ache/go/1.24.11/-t test (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy ions =0 ux_amd64/link go_.�� x64/src/net ache/go/1.24.11/-ifaceassert /bin/java -p internal/nettracrev-parse -lang=go1.24 /bin/java -o b:/usr/lib -trimpath nfig/composer/vendor/bin/as -p compress/flate -lang=go1.24 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-18712d6c44f9 -j DROP ertum_EC-384_CA.pem eroutfiles.txt test s/drivers/ads111git s/drivers/doc.go-c s/drivers/gpiocdlog.showsignature=false test -e 2888f65.0 s/drivers/vpio_f--format=format:%H %ct %D /usr/bin/test -v ication_Authorit--wait ache/go/1.24.11/-t test (dns block)
  • periph.io
    • Triggering command: /update-job-proxy /update-job-proxy ions =0 ux_amd64/link go_.�� x64/src/net ache/go/1.24.11/-ifaceassert /bin/java -p internal/nettracrev-parse -lang=go1.24 /bin/java -o b:/usr/lib -trimpath nfig/composer/vendor/bin/as -p compress/flate -lang=go1.24 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-18712d6c44f9 -j DROP ertum_EC-384_CA.pem eroutfiles.txt test s/drivers/ads111git s/drivers/doc.go-c s/drivers/gpiocdlog.showsignature=false test -e 2888f65.0 s/drivers/vpio_f--format=format:%H %ct %D /usr/bin/test -v ication_Authorit--wait ache/go/1.24.11/-t test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on Gtu7 sensor and serial drivers integration Add test coverage for serial driver implementation Jan 16, 2026
Copilot AI requested a review from rustyeddy January 16, 2026 18:02
@rustyeddy rustyeddy closed this Jan 17, 2026
@rustyeddy rustyeddy deleted the copilot/sub-pr-16-f97cc57e-cbb0-458b-b2c0-80a16f7848bb branch January 17, 2026 16:34
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