tests: Add a differential test against the reference protobuf


Golden-file tests record whatever the generator currently emits, so they
cannot detect a wire-format regression. Nothing in the test suite
compared QtProtobuf's encoding against libprotobuf, which is why a
proto2 required field being dropped from the wire went unnoticed.

Serialize with both implementations and compare bytes, then cross-parse
each side's output. protoc and qtprotobufgen derive the same C++ names
from a .proto, so the QtProtobuf side is generated with EXTRA_NAMESPACE.
Sharing a namespace makes both define the same symbols, and the linker
then binds calls to whichever it sees first, which surfaces as a null
d-pointer rather than a link error. Distinct namespaces also let one
translation unit hold both implementations, so the comparison needs no
indirection.

The reference sources are generated with the protoc of the libprotobuf
package rather than WrapProtoc. protoc's C++ output only compiles
against libprotobuf of the same release, and a cross build would
otherwise pick up an unrelated host protoc.

The upstream conformance suite is not a substitute here. It never drives
TestAllRequiredTypesProto2, so proto2 required fields are invisible to
it.

Skipped when libprotobuf is unavailable, or when cross-compiling and the
package's protoc does not run on the host.

Task-number: QTBUG-150054
Change-Id: I38eb8211833de16f6c216d83a8127fa1c80cd39a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
commit5cfae81f9ac9906e6834588e47c8ca970e4854d9
parent054664a1a918b495d439044f3a317c76ed902c05
authorDennis Oberst <dennis.oberst@qt.io>
committerDennis Oberst <dennis.oberst@qt.io>
commit timeFri, 9 Oct 2026 12:59:15 +0000