t_sets.sh revision 1.8
1# $NetBSD: t_sets.sh,v 1.8 2024/05/07 14:53:59 martin Exp $ 2# 3# Copyright (c) 2024 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27 28check_mtree() 29{ 30 local set=$1 31 32 cd / 33 atf_check -o empty -s exit:0 \ 34 mtree -e </etc/mtree/set."$set" 35} 36 37set_case() 38{ 39 local set=$1 40 41 eval "set_${set}_head() { atf_set descr \"/etc/mtree/set.${set}\"; }" 42 eval "set_${set}_body() { check_mtree ${set}; }" 43 eval "set_${set}_defined=" 44} 45 46set_case base 47set_case comp 48set_case debug 49set_case dtb 50#set_case etc 51set_case games 52set_case gpufw 53set_case man 54set_case manhtml 55set_case misc 56set_case modules 57set_case rescue 58set_case tests 59set_case text 60set_case xbase 61set_case xcomp 62set_case xdebug 63#set_case xetc 64set_case xfont 65set_case xserver 66 67sets_unknown= 68 69sets_unknown_head() 70{ 71 atf_set descr "Verify this tests lists all sets" 72} 73sets_unknown_body() 74{ 75 test -z "$sets_unknown" || atf_fail "Unknown sets: ${sets_unknown}" 76} 77 78atf_init_test_cases() 79{ 80 local mtree set defined 81 82 atf_add_test_case sets_unknown 83 84 # base is always installed -- hard-code this in case we make a 85 # mistake with the automatic set detection. 86 atf_add_test_case set_base 87 88 # Test all of the sets that are installed, except for some 89 # special cases. 90 for mtree in /etc/mtree/set.*; do 91 set=${mtree#/etc/mtree/set.} 92 case $set in 93 base) # Handled above already. 94 continue 95 ;; 96 dtb) 97 # contents of this set go to the boot partition, 98 # which may not be mounted during normal operation 99 if [ ! -d /boot/dtb ]; then 100 continue; 101 fi 102 ;; 103 etc|xetc) 104 # etc and xetc have files that may be modified 105 # on installation, and also contain log files, 106 # so let's skip them for now. 107 continue 108 ;; 109 *) ;; 110 esac 111 112 # If we have a test for this set, add it. Otherwise, 113 # add it to the unknown list to make the test suite 114 # fail. 115 eval 'defined=${set_'"$set"'_defined+yes}' 116 if [ -n "$defined" ]; then 117 atf_add_test_case set_"${set}" 118 else 119 sets_unknown="${sets_unknown}${sets_unknown:+ }${set}" 120 fi 121 done 122} 123