Skip to content

Add testing infrastructure - #37

Open
JeremiahM37 wants to merge 7 commits into
wolfSSL:masterfrom
JeremiahM37:go-testing
Open

JeremiahM37 wants to merge 7 commits into
wolfSSL:masterfrom
JeremiahM37:go-testing

Conversation

@JeremiahM37

@JeremiahM37 JeremiahM37 commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds a Go test suite and CI infrastructure for go-wolfssl

Tests — ~80 unit tests across crypto wrappers (AES, Blake2, ChaCha20-Poly1305, Curve25519, ECC, hashes, HMAC, RNG, X509, SSL boundary), plus differential and panic-recovery suites. All gate cleanly on notCompiledIn (-174) for minimal builds.

Source fixes (separate commits, each fixing a real bug):

  • Wc_Curve25519_AllocKey / Wc_Ecc_AllocKey — allocate keys on the C heap so wolfSSL's pointer-typed struct fields don't trip cgo's "Go pointer to unpinned Go pointer" check
  • #ifndef HAVE_ALPN / WOLFSSL_CERT_EXT cgo stubs in ssl.go / x509.go so non---enable-all configs link
  • wolfx509 / wolftls now build and test cleanly across all matrix configs (sentinel error for cert generation, skip on missing ALPN)

CI — build matrix now Go 1.21/1.22/1.23 × 3 wolfSSL configures (full, modern TLS 1.3 stack, DTLS 1.3); adds AddressSanitizer + linters (vet + staticcheck) workflows. Build/test now covers the handles, wolftls, and wolfx509 subpackages.

@JeremiahM37 JeremiahM37 self-assigned this Apr 30, 2026
@JeremiahM37
JeremiahM37 force-pushed the go-testing branch 12 times, most recently from a82d158 to 3888aa6 Compare May 1, 2026 16:25
@JeremiahM37
JeremiahM37 marked this pull request as ready for review May 1, 2026 16:37
@JeremiahM37 JeremiahM37 assigned lealem47 and unassigned JeremiahM37 May 8, 2026
Copilot AI balanced review requested due to automatic review settings November 4, 2026 00:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Certificate-generation tests still fail rather than skip when WOLFSSL_CERT_GEN is unavailable, and the sanitizer job lacks Go’s -asan flag, leaving native out-of-bounds accesses to Go-allocated buffers potentially undetected.

2 open issues
What changed in this PR

Adds testing infrastructure for go-wolfssl’s crypto wrappers and higher-level packages, with compatibility fixes for reduced-feature wolfSSL builds.

Changes:

  • Adds known-answer, round-trip, differential, and boundary tests.
  • Adds C-heap key allocation helpers and missing-feature error handling.
  • Expands CI configuration coverage, adds sanitizer testing and staticcheck, and updates Go dependencies.
File Description
x509.go Adds a fallback for unavailable object parsing.
x509_test.go Tests X509, BIO, and ASN.1 boundaries.
wolfx509/​skip_test.go Adds a missing-certgen skip helper.
wolfx509/​parsecerts_test.go Skips selected tests without certgen.
wolfx509/​name.go Removes unused comparison helpers.
wolfx509/​certgen_wolfcrypt.go Adds certgen stubs and sentinel errors.
wolfx509/​certgen_test.go Adds missing-feature skips to selected tests.
wolftls/​tls_test.go Skips ALPN testing when unavailable.
wolftls/​conn.go Exposes a missing-feature sentinel for ALPN.
testing_helpers_test.go Shares feature-gating helpers.
ssl_test.go Tests error strings and library version.
random_test.go Tests RNG output and size boundaries.
misc.go Exports NOT_COMPILED_IN.
misc_test.go Tests comparison and memory clearing.
hmac_test.go Adds HMAC and HKDF tests.
hash_test.go Tests hash vectors, streaming, and bounds.
go.sum Records dependency checksums.
go.mod Raises minimum Go version and declares dependencies.
ecc.go Adds C-heap ECC key lifecycle helpers.
ecc_test.go Tests ECC signing and key operations.
curve25519.go Adds C-heap Curve25519 key lifecycle helpers.
curve25519_test.go Tests shared-secret agreement.
correctness_test.go Tests crypto input dependence and authentication.
chacha_poly_test.go Tests ChaCha variants and authentication failures.
boundary_test.go Tests invalid-input rejection without panics.
blake2_test.go Tests Blake2s hashing and MAC behavior.
aes_test.go Tests AES modes and PBKDF2 behavior.
.github/​workflows/​linters.yml Expands vet coverage and adds staticcheck.
.github/​workflows/​build.yml Expands wolfSSL configurations and runs package tests.
.github/​workflows/​address-sanitizer.yml Adds sanitizer-instrumented builds and testing.

Review effort: Balanced

Comment thread wolfx509/certgen_test.go
}
der, err := CreateCertificate(tmpl, tmpl, k, k)
if err != nil {
skipIfCertGenMissing(t, err)
CGO_LDFLAGS: "-L/usr/local/lib -fsanitize=address"
# Detect leaks at exit; abort on any error.
ASAN_OPTIONS: "detect_leaks=1:halt_on_error=1:strict_string_checks=1:print_stacktrace=1"
run: go test -count=1 -v . ./handles ./wolftls ./wolfx509
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.

3 participants