Provide a harness driving rust-openssl's regress tests
authortb <tb@openbsd.org>
Thu, 20 Oct 2022 07:33:14 +0000 (07:33 +0000)
committertb <tb@openbsd.org>
Thu, 20 Oct 2022 07:33:14 +0000 (07:33 +0000)
rust-openssl is an integral part of the Rust ecosystem and more than a
dozen ports, including lang/rust itself, depend on it. We need to ensure
that it keeps working with LibreSSL.

If the rust and rust-openssl-tests packages are installed, create a cargo
workspace under obj/ that compiles and runs the rust-openssl regress tests
much like what is done for the openssl-ruby tests. This expands our regress
coverage: for instance, this would have caught the broken ASN.1 indefinite
length encoding caused by asn1/tasn_enc.c r1.25.

Positive feedback beck jsing semarie
Testing and ok anton

regress/lib/libssl/rust-openssl/Cargo.toml [new file with mode: 0644]
regress/lib/libssl/rust-openssl/Makefile [new file with mode: 0644]
regress/lib/libssl/rust-openssl/config [new file with mode: 0644]

diff --git a/regress/lib/libssl/rust-openssl/Cargo.toml b/regress/lib/libssl/rust-openssl/Cargo.toml
new file mode 100644 (file)
index 0000000..c33c347
--- /dev/null
@@ -0,0 +1,8 @@
+[workspace]
+members = [
+    "openssl",
+    "openssl-errors",
+    "openssl-macros",
+    "openssl-sys",
+    "systest",
+]
diff --git a/regress/lib/libssl/rust-openssl/Makefile b/regress/lib/libssl/rust-openssl/Makefile
new file mode 100644 (file)
index 0000000..88e231e
--- /dev/null
@@ -0,0 +1,48 @@
+#      $OpenBSD: Makefile,v 1.1.1.1 2022/10/20 07:33:14 tb Exp $
+
+RUST_OPENSSL_TESTS =   /usr/local/share/rust-openssl-tests
+CARGO =                        /usr/local/bin/cargo
+
+.if !exists(${RUST_OPENSSL_TESTS}) || !exists(${CARGO})
+regress:
+       @echo packages rust-openssl-tests and rust are required for this regress
+       @echo SKIPPED
+.else
+
+REGRESS_TARGETS +=     rust-openssl-test
+
+WORKSPACE_LINKS = openssl openssl-errors openssl-macros openssl-sys systest
+
+_WORKSPACE_COOKIE =    .workspace
+
+${_WORKSPACE_COOKIE}:
+. if ${.CURDIR} != ${.OBJDIR}
+       cp ${.CURDIR}/Cargo.toml ${.OBJDIR}/
+. endif
+       mkdir -p .cargo
+       cp ${.CURDIR}/config .cargo/
+       cd ${.OBJDIR} && ln -sf ${WORKSPACE_LINKS:S,^,${RUST_OPENSSL_TESTS}/,} .
+       touch $@
+
+CLEANFILES += Cargo.lock
+
+. if ${.CURDIR} != ${.OBJDIR}
+CLEANFILES += Cargo.toml
+. endif
+
+rust-openssl-test: ${_WORKSPACE_COOKIE}
+       cd ${.OBJDIR} && cargo test --offline --color=never -- --color=never
+
+CLEANFILES +=  ${_WORKSPACE_COOKIE} ${WORKSPACE_LINKS}
+
+. if make(clean) || make(cleandir)
+.  if exists(.cargo) || exists(target)
+.BEGIN:
+       rm -rf .cargo
+       rm -rf target
+.  endif
+. endif
+
+.endif
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libssl/rust-openssl/config b/regress/lib/libssl/rust-openssl/config
new file mode 100644 (file)
index 0000000..a474747
--- /dev/null
@@ -0,0 +1,6 @@
+[net]
+       offline = true
+[source.modcargo]
+       directory = '/usr/local/share/rust-openssl-tests/modcargo-crates'
+[source.crates-io]
+       replace-with = 'modcargo'