t_netpgpkeys.sh revision 1.2
11.1Swiz#! /bin/sh 21.1Swiz 31.2Swiz# $NetBSD: t_netpgpkeys.sh,v 1.2 2026/01/29 16:14:45 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.2Swizcleanup_core() 351.2Swiz{ 361.2Swiz local prog 371.2Swiz 381.2Swiz prog=$1 391.2Swiz test -f "${prog}.core" || return 0 401.2Swiz readelf -rs "$(atf_get_srcdir)/${prog}" 411.2Swiz gdb -batch -ex bt -ex 'info registers' -ex disas \ 421.2Swiz "$(atf_get_srcdir)/${prog}" "${prog}.core" 431.2Swiz} 441.2Swiz 451.1Swiz# Test set 1 (rsa key) for netpgpkeys 461.1Swizatf_test_case netpgpkeys_testset_1_rsa_keys 471.1Swiz 481.1Swiznetpgpkeys_testset_1_rsa_keys_head() { 491.1Swiz atf_set "descr" "Test set 1 (rsa_keys) for netpgpkeys" 501.1Swiz} 511.1Swiznetpgpkeys_testset_1_rsa_keys_body() { 521.1Swiz atf_expect_fail "PR bin/59936 - does not support keys generated by gnugp2" 531.1Swiz # TODO: fix netpgpkeys so it doesn't need an empty keyring 541.2Swiz atf_check -s exit:0 touch pubring.gpg 551.2Swiz atf_check -s exit:0 -o file:expected_rsa.out -e empty env TZ=US/Pacific netpgpkeys --keyring pubring.gpg --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.2Swiz atf_check -s exit:0 touch pubring.gpg 681.2Swiz atf_check -s exit:0 -o file:expected_ec.out -e empty env TZ=US/Pacific netpgpkeys --keyring pubring.gpg --import-key $(atf_get_srcdir)/data/testkey-ec.pub 691.2Swiz} 701.2Swiz 711.2Swiznetpgpkeys_testset_2_ec_keys_cleanup() { 721.2Swiz cleanup_core netpgpkeys 731.1Swiz} 741.1Swiz 751.1Swiz# all test sets 761.1Swizatf_init_test_cases() { 771.1Swiz atf_add_test_case netpgpkeys_testset_1_rsa_keys 781.1Swiz atf_add_test_case netpgpkeys_testset_2_ec_keys 791.1Swiz} 80