t_netpgpkeys.sh revision 1.3
11.1Swiz#! /bin/sh 21.1Swiz 31.3Swiz# $NetBSD: t_netpgpkeys.sh,v 1.3 2026/01/31 22:35:10 wiz Exp $ 41.1Swiz 51.1Swiz# 61.1Swiz# Copyright (c) 2026 The NetBSD Foundation, Inc. 71.1Swiz# All rights reserved. 81.1Swiz# 91.1Swiz# This code is derived from software contributed to The NetBSD Foundation 101.1Swiz# by Thomas Klausner <wiz@NetBSD.org> 111.1Swiz# 121.1Swiz# Redistribution and use in source and binary forms, with or without 131.1Swiz# modification, are permitted provided that the following conditions 141.1Swiz# are met: 151.1Swiz# 1. Redistributions of source code must retain the above copyright 161.1Swiz# notice, this list of conditions and the following disclaimer. 171.1Swiz# 2. Redistributions in binary form must reproduce the above copyright 181.1Swiz# notice, this list of conditions and the following disclaimer in the 191.1Swiz# documentation and/or other materials provided with the distribution. 201.1Swiz# 211.1Swiz# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 221.1Swiz# AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 231.1Swiz# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 241.1Swiz# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 251.1Swiz# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 261.1Swiz# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 271.1Swiz# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 281.1Swiz# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 291.1Swiz# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 301.1Swiz# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 311.1Swiz# POSSIBILITY OF SUCH DAMAGE. 321.1Swiz# 331.1Swiz 341.3Swizcleanup_core() { 351.2Swiz local prog 361.2Swiz 371.2Swiz prog=$1 381.2Swiz test -f "${prog}.core" || return 0 391.3Swiz readelf -rs "/usr/bin/${prog}" 401.2Swiz gdb -batch -ex bt -ex 'info registers' -ex disas \ 411.3Swiz "/usr/bin/${prog}" "${prog}.core" 421.2Swiz} 431.2Swiz 441.1Swiz# Test set 1 (rsa key) for netpgpkeys 451.1Swizatf_test_case netpgpkeys_testset_1_rsa_keys 461.1Swiz 471.1Swiznetpgpkeys_testset_1_rsa_keys_head() { 481.1Swiz atf_set "descr" "Test set 1 (rsa_keys) for netpgpkeys" 491.1Swiz} 501.1Swiznetpgpkeys_testset_1_rsa_keys_body() { 511.3Swiz atf_expect_fail "PR bin/59936 - does not support keys generated by gnugp2" 521.1Swiz # TODO: fix netpgpkeys so it doesn't need an empty keyring 531.3Swiz atf_check touch pubring.gpg 541.3Swiz atf_check netpgpkeys --keyring pubring.gpg \ 551.3Swiz --import-key "$(atf_get_srcdir)"/data/testkey-rsa.pub 561.1Swiz} 571.1Swiz 581.1Swiz# Test set 2 (elliptic curve keys) for netpgpkeys 591.2Swizatf_test_case netpgpkeys_testset_2_ec_keys cleanup 601.1Swiz 611.1Swiznetpgpkeys_testset_2_ec_keys_head() { 621.1Swiz atf_set "descr" "Test set 2 (ec_keys) for netpgpkeys" 631.1Swiz} 641.1Swiznetpgpkeys_testset_2_ec_keys_body() { 651.2Swiz atf_expect_fail "PR bin/59936 - does not support keys generated by gnugp2 - dumps core for EC keys" 661.1Swiz # TODO: fix netpgpkeys so it doesn't need an empty keyring 671.3Swiz atf_check touch pubring.gpg 681.3Swiz atf_check netpgpkeys --keyring pubring.gpg \ 691.3Swiz --import-key "$(atf_get_srcdir)"/data/testkey-ec.pub \ 701.3Swiz --coredumps 711.2Swiz} 721.2Swiz 731.2Swiznetpgpkeys_testset_2_ec_keys_cleanup() { 741.2Swiz cleanup_core netpgpkeys 751.1Swiz} 761.1Swiz 771.1Swiz# all test sets 781.1Swizatf_init_test_cases() { 791.1Swiz atf_add_test_case netpgpkeys_testset_1_rsa_keys 801.1Swiz atf_add_test_case netpgpkeys_testset_2_ec_keys 811.1Swiz} 82