diff options
author | Ravineet Singh <ravineet.a.singh@est.tech> | 2023-02-01 16:20:49 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-02 09:51:00 +0000 |
commit | a08c791bae13bda56ee71e9023329473e8d5baa5 (patch) | |
tree | b26f44baf0e9c95c56d1acda71b0821c5fe2e6f2 /meta/recipes-support/gnutls | |
parent | 729c16b00e0e9036218a18a7234d90706542f4ab (diff) | |
download | poky-a08c791bae13bda56ee71e9023329473e8d5baa5.tar.gz |
gnutls: add ptest support
Add gnutls unit-tests into ptest. Only self-contained
tests (no external file system dependencies) are included.
Some tests have been put in a disallow list in the run-ptest;
these tests either require additional files (certificates) or
environment setup prior to being run, via wrapper shell script.
As autotools packages are built out-of-tree, it is cumbersome
to add additional files. With regards to tests requiring wrapper
scripts, it is possible to add logic to run these tests under
run-ptests but that will require more effort to maintain, hence
skipped.
Verified via:
$ runqemu qemux86-64 kvm nographic serial qemuparams='-m 4096 -smp 32'
root@qemux86-64:~# ptest-runner gnutls
START: ptest-runner
BEGIN: /usr/lib64/gnutls/ptest
PASS: aead-cipher-vec
PASS: alerts
PASS: anti_replay
...
gnutls test summary:
--------------------
total: 375
pass : 364
fail : 0
skip : 11
DURATION: 184
END: /usr/lib64/gnutls/ptest
2023-02-01T13:55
STOP: ptest-runner
TOTAL: 1 FAIL: 0
(From OE-Core rev: 6061df3084b991ba4a54a3dca5dadda97e2364ac)
Signed-off-by: Ravineet Singh <ravineet.a.singh@est.tech>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-support/gnutls')
-rw-r--r-- | meta/recipes-support/gnutls/gnutls/Add-ptest-support.patch | 60 | ||||
-rw-r--r-- | meta/recipes-support/gnutls/gnutls/run-ptest | 90 | ||||
-rw-r--r-- | meta/recipes-support/gnutls/gnutls_3.7.8.bb | 8 |
3 files changed, 157 insertions, 1 deletions
diff --git a/meta/recipes-support/gnutls/gnutls/Add-ptest-support.patch b/meta/recipes-support/gnutls/gnutls/Add-ptest-support.patch new file mode 100644 index 0000000000..8ad6ba5ad5 --- /dev/null +++ b/meta/recipes-support/gnutls/gnutls/Add-ptest-support.patch | |||
@@ -0,0 +1,60 @@ | |||
1 | From 74080376904713a8e6cceefbc25c81512796bf0c Mon Sep 17 00:00:00 2001 | ||
2 | From: Ravineet Singh <ravineet.a.singh@est.tech> | ||
3 | Date: Tue, 10 Jan 2023 16:11:10 +0100 | ||
4 | Subject: [PATCH] gnutls: add ptest support | ||
5 | |||
6 | Upstream-Status: Inappropriate [embedded specific] | ||
7 | Signed-off-by: Ravineet Singh <ravineet.a.singh@est.tech> | ||
8 | --- | ||
9 | Makefile.am | 3 +++ | ||
10 | configure.ac | 2 ++ | ||
11 | tests/Makefile.am | 6 ++++++ | ||
12 | 3 files changed, 11 insertions(+) | ||
13 | |||
14 | diff --git a/Makefile.am b/Makefile.am | ||
15 | index 843193f9f..816b09fec 100644 | ||
16 | --- a/Makefile.am | ||
17 | +++ b/Makefile.am | ||
18 | @@ -191,6 +191,9 @@ dist-hook: | ||
19 | mv ChangeLog $(distdir) | ||
20 | touch -c $(distdir)/doc/*.html $(distdir)/doc/*.pdf $(distdir)/doc/*.info | ||
21 | |||
22 | +install-ptest: | ||
23 | + $(MAKE) -C tests DESTDIR=$(DESTDIR)/tests $@ | ||
24 | + | ||
25 | .PHONY: abi-check abi-dump-versioned abi-dump-latest pic-check symbol-check local-code-coverage-output files-update AUTHORS | ||
26 | |||
27 | include $(top_srcdir)/cligen/cligen.mk | ||
28 | diff --git a/configure.ac b/configure.ac | ||
29 | index baff1c007..f9f596abf 100644 | ||
30 | --- a/configure.ac | ||
31 | +++ b/configure.ac | ||
32 | @@ -1150,6 +1150,8 @@ AC_SUBST(LIBGNUTLS_CFLAGS) | ||
33 | |||
34 | AM_CONDITIONAL(NEEDS_LIBRT, test "$gnutls_needs_librt" = "yes") | ||
35 | |||
36 | +AM_EXTRA_RECURSIVE_TARGETS([buildtest-TESTS]) | ||
37 | + | ||
38 | AC_DEFINE([GNUTLS_INTERNAL_BUILD], 1, [We allow temporarily usage of deprecated functions - until they are removed.]) | ||
39 | |||
40 | hw_features= | ||
41 | diff --git a/tests/Makefile.am b/tests/Makefile.am | ||
42 | index 573e911a0..e8a26f8b9 100644 | ||
43 | --- a/tests/Makefile.am | ||
44 | +++ b/tests/Makefile.am | ||
45 | @@ -644,6 +644,12 @@ SH_LOG_COMPILER = $(SHELL) | ||
46 | AM_VALGRINDFLAGS = --suppressions=$(srcdir)/suppressions.valgrind | ||
47 | LOG_COMPILER = $(LOG_VALGRIND) | ||
48 | |||
49 | +install-ptest: $(check_PROGRAMS) | ||
50 | + @$(INSTALL) -d $(DESTDIR) | ||
51 | + @for file in $^; do \ | ||
52 | + $(INSTALL_PROGRAM) $$file $(DESTDIR) ; \ | ||
53 | + done | ||
54 | + | ||
55 | distclean-local: | ||
56 | rm -rf softhsm-*.db softhsm-*.config *.tmp tmp-* x509-crt-list-import-url.config.db port.lock.d | ||
57 | |||
58 | -- | ||
59 | 2.31.1 | ||
60 | |||
diff --git a/meta/recipes-support/gnutls/gnutls/run-ptest b/meta/recipes-support/gnutls/gnutls/run-ptest new file mode 100644 index 0000000000..84948f487d --- /dev/null +++ b/meta/recipes-support/gnutls/gnutls/run-ptest | |||
@@ -0,0 +1,90 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | rjob() { | ||
4 | local job=$1 | ||
5 | local log=$2 | ||
6 | |||
7 | # TODO: Output will be garbled | ||
8 | ./${job} >> ${log} 2>&1 | ||
9 | |||
10 | ret=$? | ||
11 | case $ret in | ||
12 | 0) | ||
13 | echo "PASS: $t" >> ${log} | ||
14 | echo "PASS: $t" | ||
15 | ;; | ||
16 | 77) | ||
17 | echo "SKIP: $t" >> ${log} | ||
18 | echo "SKIP: $t" | ||
19 | ;; | ||
20 | *) | ||
21 | echo "FAIL: $t" >> ${log} | ||
22 | echo "FAIL: $t" | ||
23 | ;; | ||
24 | esac | ||
25 | } | ||
26 | |||
27 | is_disallowed() { | ||
28 | local key=$1 | ||
29 | $(echo ${test_disallowlist} | grep -w -q ${key}) | ||
30 | return $? | ||
31 | } | ||
32 | |||
33 | # TODO | ||
34 | # This list should probably be in a external file | ||
35 | # Testcases defined here either take very long time (dtls-stress) | ||
36 | # or are dependent on local files (certs, etc) in local file system | ||
37 | # currently not exported to target. | ||
38 | |||
39 | test_disallowlist="" | ||
40 | test_disallowlist="${test_disallowlist} dtls-stress" | ||
41 | test_disallowlist="${test_disallowlist} handshake-large-cert" | ||
42 | test_disallowlist="${test_disallowlist} id-on-xmppAddr" | ||
43 | test_disallowlist="${test_disallowlist} mini-x509-cas" | ||
44 | test_disallowlist="${test_disallowlist} pkcs12_simple" | ||
45 | test_disallowlist="${test_disallowlist} protocol-set-allowlist" | ||
46 | test_disallowlist="${test_disallowlist} psk-file" | ||
47 | test_disallowlist="${test_disallowlist} rawpk-api" | ||
48 | test_disallowlist="${test_disallowlist} set_pkcs12_cred" | ||
49 | test_disallowlist="${test_disallowlist} system-override-curves-allowlist" | ||
50 | test_disallowlist="${test_disallowlist} system-override-hash" | ||
51 | test_disallowlist="${test_disallowlist} system-override-sig" | ||
52 | test_disallowlist="${test_disallowlist} system-override-sig-tls" | ||
53 | test_disallowlist="${test_disallowlist} system-prio-file" | ||
54 | test_disallowlist="${test_disallowlist} x509cert-tl" | ||
55 | |||
56 | LOG=${PWD}/tests.log | ||
57 | cd tests | ||
58 | max_njobs=$(grep -c ^processor /proc/cpuinfo) | ||
59 | njobs=0 | ||
60 | |||
61 | for t in *; do | ||
62 | [ -x $t ] || continue | ||
63 | [ -f $t ] || continue | ||
64 | |||
65 | is_disallowed ${t} | ||
66 | [ $? -eq 0 ] && continue | ||
67 | |||
68 | rjob ${t} ${LOG} & | ||
69 | one=1 | ||
70 | njobs=$(expr ${njobs} + ${one}) | ||
71 | if [ ${njobs} -eq ${max_njobs} ]; then | ||
72 | wait | ||
73 | njobs=0 | ||
74 | fi | ||
75 | done | ||
76 | wait | ||
77 | |||
78 | skipped=$(grep -c SKIP ${LOG}) | ||
79 | passed=$(grep -c PASS ${LOG}) | ||
80 | failed=$(grep -c FAIL ${LOG}) | ||
81 | total=$(expr ${passed} + ${failed} + ${skipped}) | ||
82 | |||
83 | echo | ||
84 | echo "gnutls test summary:" | ||
85 | echo "--------------------" | ||
86 | echo "total: ${total}" | ||
87 | echo "pass : ${passed}" | ||
88 | echo "fail : ${failed}" | ||
89 | echo "skip : ${skipped}" | ||
90 | echo | ||
diff --git a/meta/recipes-support/gnutls/gnutls_3.7.8.bb b/meta/recipes-support/gnutls/gnutls_3.7.8.bb index 8f979a5b99..fee06393bd 100644 --- a/meta/recipes-support/gnutls/gnutls_3.7.8.bb +++ b/meta/recipes-support/gnutls/gnutls_3.7.8.bb | |||
@@ -22,11 +22,13 @@ SHRT_VER = "${@d.getVar('PV').split('.')[0]}.${@d.getVar('PV').split('.')[1]}" | |||
22 | SRC_URI = "https://www.gnupg.org/ftp/gcrypt/gnutls/v${SHRT_VER}/gnutls-${PV}.tar.xz \ | 22 | SRC_URI = "https://www.gnupg.org/ftp/gcrypt/gnutls/v${SHRT_VER}/gnutls-${PV}.tar.xz \ |
23 | file://arm_eabi.patch \ | 23 | file://arm_eabi.patch \ |
24 | file://0001-Creating-.hmac-file-should-be-excuted-in-target-envi.patch \ | 24 | file://0001-Creating-.hmac-file-should-be-excuted-in-target-envi.patch \ |
25 | file://run-ptest \ | ||
26 | file://Add-ptest-support.patch \ | ||
25 | " | 27 | " |
26 | 28 | ||
27 | SRC_URI[sha256sum] = "c58ad39af0670efe6a8aee5e3a8b2331a1200418b64b7c51977fb396d4617114" | 29 | SRC_URI[sha256sum] = "c58ad39af0670efe6a8aee5e3a8b2331a1200418b64b7c51977fb396d4617114" |
28 | 30 | ||
29 | inherit autotools texinfo pkgconfig gettext lib_package gtk-doc | 31 | inherit autotools texinfo pkgconfig gettext lib_package gtk-doc ptest |
30 | 32 | ||
31 | PACKAGECONFIG ??= "libidn ${@bb.utils.filter('DISTRO_FEATURES', 'seccomp', d)}" | 33 | PACKAGECONFIG ??= "libidn ${@bb.utils.filter('DISTRO_FEATURES', 'seccomp', d)}" |
32 | 34 | ||
@@ -68,6 +70,10 @@ do_install:append:class-target() { | |||
68 | fi | 70 | fi |
69 | } | 71 | } |
70 | 72 | ||
73 | do_compile:append() { | ||
74 | oe_runmake ${PARALLEL_MAKE} -C tests buildtest-TESTS | ||
75 | } | ||
76 | |||
71 | PACKAGES =+ "${PN}-openssl ${PN}-xx ${PN}-fips" | 77 | PACKAGES =+ "${PN}-openssl ${PN}-xx ${PN}-fips" |
72 | 78 | ||
73 | FILES:${PN}-dev += "${bindir}/gnutls-cli-debug" | 79 | FILES:${PN}-dev += "${bindir}/gnutls-cli-debug" |