unregister.sh
1 #! /usr/bin/env atf-sh 2 3 . $(atf_get_srcdir)/test_environment.sh 4 5 tests_init \ 6 unregister_all \ 7 unregister_pkg \ 8 unregister_with_directory_owned \ 9 simple_unregister \ 10 simple_unregister_prefix_ending_with_slash 11 12 unregister_all_body() { 13 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1" 14 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkg" "pkg" "1" 15 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" 16 17 atf_check -o ignore pkg register -M foo.ucl 18 atf_check -o ignore pkg register -M pkg.ucl 19 atf_check -o ignore pkg register -M test.ucl 20 21 atf_check -o ignore pkg unregister -ay 22 } 23 24 unregister_pkg_body() { 25 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkg" "pkg" "1" 26 atf_check -o ignore pkg register -M pkg.ucl 27 atf_check -o ignore -e ignore -s exit:3 pkg unregister -y pkg 28 atf_check -o ignore -e ignore pkg unregister -yf pkg 29 } 30 31 simple_unregister_body() { 32 touch file1 33 mkdir dir1 34 mkdir dir2 35 touch dir1/file2 36 37 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}" 38 cat << EOF >> test.ucl 39 files: { 40 ${TMPDIR}/file1: "", 41 ${TMPDIR}/dir1/file2: "", 42 } 43 directories: { 44 ${TMPDIR}/dir1: { 45 uname: "", 46 gname: "", 47 perm: "0000", 48 fflags: 0 49 } 50 ${TMPDIR}/dir2: { 51 uname: "", 52 gname: "", 53 perm: "0000", 54 fflags: 0 55 } 56 } 57 EOF 58 59 atf_check \ 60 -o match:".*Installing.*\.\.\.$" \ 61 -e empty \ 62 -s exit:0 \ 63 pkg register -M test.ucl 64 65 atf_check \ 66 -o match:".*Deinstalling.*" \ 67 -e empty \ 68 -s exit:0 \ 69 pkg unregister -y test 70 71 atf_check \ 72 -o ignore \ 73 -e ignore \ 74 -s exit:0 \ 75 test -f file1 76 77 atf_check \ 78 -o ignore \ 79 -e ignore \ 80 -s exit:0 \ 81 test -f dir1/file2 82 83 atf_check \ 84 -o ignore \ 85 -e ignore \ 86 -s exit:0 \ 87 test -d dir1 88 89 atf_check \ 90 -o ignore \ 91 -e ignore \ 92 -s exit:0 \ 93 test -d dir2 94 } 95 96 simple_unregister_prefix_ending_with_slash_body() { 97 touch file1 98 mkdir dir 99 touch dir/file2 100 101 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}/" 102 cat << EOF >> test.ucl 103 files: { 104 ${TMPDIR}/file1: "", 105 ${TMPDIR}/dir/file2: "", 106 } 107 EOF 108 109 atf_check \ 110 -o match:".*Installing.*\.\.\.$" \ 111 -e empty \ 112 -s exit:0 \ 113 pkg register -M test.ucl 114 115 atf_check \ 116 -o match:".*Deinstalling.*" \ 117 -e empty \ 118 -s exit:0 \ 119 pkg unregister -y test 120 121 test -f file1 || atf_fail "'file1' is not present" 122 test -f dir/file2 || atf_fail "'dir/file2' is not present" 123 test -d dir || atf_fail "'dir' is not present" 124 test -d ${TMPDIR} || atf_fail "Prefix have been removed" 125 } 126 127 unregister_with_directory_owned_body() { 128 touch file1 129 mkdir dir 130 touch dir/file2 131 132 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}/" 133 cat << EOF >> test.ucl 134 files: { 135 ${TMPDIR}/file1: "", 136 ${TMPDIR}/dir/file2: "", 137 } 138 EOF 139 140 atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test2" "test2" "1" "${TMPDIR}/" 141 cat << EOF >> test2.ucl 142 directories: { 143 ${TMPDIR}/dir: 'y', 144 } 145 EOF 146 atf_check \ 147 -o match:".*Installing.*\.\.\.$" \ 148 -e empty \ 149 -s exit:0 \ 150 pkg register -M test.ucl 151 152 atf_check \ 153 -o match:".*Installing.*\.\.\.$" \ 154 -e empty \ 155 -s exit:0 \ 156 pkg register -M test2.ucl 157 158 atf_check \ 159 -o match:".*Deinstalling.*" \ 160 -e empty \ 161 -s exit:0 \ 162 pkg unregister -y test 163 164 test -f file1 || atf_fail "'file1' is not present" 165 test -f dir/file2 || atf_fail "'dir/file2' is not present" 166 test -d dir || atf_fail "'dir' has been removed" 167 168 atf_check \ 169 -o match:".*Deinstalling.*" \ 170 -e empty \ 171 -s exit:0 \ 172 pkg unregister -y test2 173 174 test -d dir || atf_fail "'dir' is not present" 175 test -d ${TMPDIR} || atf_fail "Prefix has been removed" 176 }