src/tests/cli-complete.ksh
changeset 135 a1e20e9a9845
child 141 3b3b5501d66b
equal deleted inserted replaced
134:6887274c15a3 135:a1e20e9a9845
       
     1 #!/bin/ksh -px
       
     2 #
       
     3 # CDDL HEADER START
       
     4 #
       
     5 # The contents of this file are subject to the terms of the
       
     6 # Common Development and Distribution License (the "License").
       
     7 # You may not use this file except in compliance with the License.
       
     8 #
       
     9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    10 # or http://www.opensolaris.org/os/licensing.
       
    11 # See the License for the specific language governing permissions
       
    12 # and limitations under the License.
       
    13 #
       
    14 # When distributing Covered Code, include this CDDL HEADER in each
       
    15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    16 # If applicable, add the following below this CDDL HEADER, with the
       
    17 # fields enclosed by brackets "[[]]" replaced with your own identifying
       
    18 # information: Portions Copyright [[yyyy]] [name of copyright owner]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 
       
    23 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
       
    24 # Use is subject to license terms.
       
    25 
       
    26 # cli-complete.ksh - basic sanity test exercising all basic pkg(1) operations
       
    27 #
       
    28 # cli-complete.ksh runs out of $HG/src/tests, and runs an depot server
       
    29 # and issues pkg(1) commands from the $HG/proto directory relevant to
       
    30 # the executing system.
       
    31 #
       
    32 # XXX Should really select which cases to run.
       
    33 
       
    34 REPO_PORT=${REPO_PORT:-8000}
       
    35 REPO_DIR=/tmp/repo.$$
       
    36 REPO_URL=http://localhost:$REPO_PORT
       
    37 IMAGE_DIR=/tmp/image.$$
       
    38 
       
    39 restore_dir=$PWD
       
    40 
       
    41 ROOT=$PWD/../../proto/root_$(uname -p)
       
    42 
       
    43 export PYTHONPATH=$ROOT/usr/lib/python2.4/vendor-packages/
       
    44 export PATH=$ROOT/usr/bin:$PATH
       
    45 
       
    46 $ROOT/usr/lib/pkg.depotd -p $REPO_PORT -d $REPO_DIR &
       
    47 
       
    48 DEPOT_PID=$!
       
    49 
       
    50 sleep 1
       
    51 
       
    52 usage () {
       
    53 	cli-complete.ksh
       
    54 	exit 2
       
    55 }
       
    56 
       
    57 depot_cleanup () {
       
    58 	kill $DEPOT_PID
       
    59 	sleep 1
       
    60 	if ps -p $DEPOT_PID > /dev/null; then
       
    61 		kill -9 $DEPOT_PID
       
    62 	fi
       
    63 	rm -fr $REPO_DIR
       
    64 	exit $1
       
    65 }
       
    66 
       
    67 image_cleanup () {
       
    68 	cd $restore_dir
       
    69 	rm -fr $IMAGE_DIR
       
    70 }
       
    71 
       
    72 fail () {
       
    73 	echo "*** case $tcase: $@"
       
    74 	exit 1
       
    75 }
       
    76 
       
    77 trap "ret=$?; image_cleanup; depot_cleanup $ret" EXIT
       
    78 
       
    79 # Case 1.  Send empty package [email protected], install and uninstall.
       
    80 # {{{1
       
    81 
       
    82 tcase=1
       
    83 trans_id=$(pkgsend -s $REPO_URL open [email protected],5.11-0)
       
    84 if [[ $? != 0 ]]; then
       
    85 	fail pkgsend open failed
       
    86 fi
       
    87 
       
    88 eval $trans_id
       
    89 
       
    90 if ! pkgsend -s $REPO_URL close; then
       
    91 	fail pkgsend close failed
       
    92 fi
       
    93 
       
    94 if ! pkg image-create -F -a test=$REPO_URL $IMAGE_DIR; then
       
    95 	fail pkg image-create failed
       
    96 fi
       
    97 
       
    98 find $IMAGE_DIR
       
    99 
       
   100 cd $IMAGE_DIR
       
   101 
       
   102 if ! pkg status -a; then
       
   103 	fail pkg status -a failed
       
   104 fi
       
   105 
       
   106 if ! pkg install foo; then
       
   107 	fail pkg install foo failed
       
   108 fi
       
   109 
       
   110 find $IMAGE_DIR
       
   111 
       
   112 if ! pkg status; then
       
   113 	fail pkg status failed
       
   114 fi
       
   115 
       
   116 if ! pkg uninstall foo; then
       
   117 	fail pkg uninstall foo failed
       
   118 fi
       
   119 
       
   120 find $IMAGE_DIR
       
   121 
       
   122 if ! pkg status -a; then
       
   123 	fail pkg status -a failed
       
   124 fi
       
   125 
       
   126 # }}}1
       
   127 
       
   128 # Case 2.  Send package [email protected], containing a directory and a file,
       
   129 # install and uninstall.
       
   130 # {{{1
       
   131 
       
   132 tcase=2
       
   133 trans_id=$(pkgsend -s $REPO_URL open [email protected],5.11-0)
       
   134 if [[ $? != 0 ]]; then
       
   135 	fail pkgsend open failed
       
   136 fi
       
   137 
       
   138 eval $trans_id
       
   139 
       
   140 if ! pkgsend -s $REPO_URL add dir mode=0755 owner=root group=bin path=/lib; then
       
   141 	fail pkgsend add dir failed
       
   142 fi
       
   143 
       
   144 if ! pkgsend -s $REPO_URL add file /lib/libc.so.1 mode=0555 owner=root group=bin \
       
   145 	path=/lib/libc.so.1; then
       
   146 	fail pkgsend add file failed
       
   147 fi
       
   148 
       
   149 if ! pkgsend -s $REPO_URL close; then
       
   150 	fail pkgsend close failed
       
   151 fi
       
   152 
       
   153 if ! pkg image-create -F -a test=$REPO_URL $IMAGE_DIR; then
       
   154 	fail pkg image-create failed
       
   155 	image_cleanup
       
   156 fi
       
   157 
       
   158 find $IMAGE_DIR
       
   159 
       
   160 cd $IMAGE_DIR
       
   161 
       
   162 if ! pkg status -a; then
       
   163 	fail pkg status -a failed
       
   164 fi
       
   165 
       
   166 if ! pkg install foo; then
       
   167 	fail pkg install foo failed
       
   168 fi
       
   169 
       
   170 find $IMAGE_DIR
       
   171 
       
   172 if ! pkg status; then
       
   173 	fail pkg status failed
       
   174 fi
       
   175 
       
   176 if ! pkg uninstall foo; then
       
   177 	fail pkg uninstall foo failed
       
   178 fi
       
   179 
       
   180 find $IMAGE_DIR
       
   181 
       
   182 if ! pkg status -a; then
       
   183 	fail pkg status -a failed
       
   184 fi
       
   185 
       
   186 # }}}1
       
   187 
       
   188 # Case 3.  Install [email protected], upgrade to [email protected], uninstall.
       
   189 # {{{1
       
   190 
       
   191 tcase=3
       
   192 
       
   193 if ! pkg image-create -F -a test=$REPO_URL $IMAGE_DIR; then
       
   194 	fail pkgsend close failed
       
   195 fi
       
   196 
       
   197 find $IMAGE_DIR
       
   198 
       
   199 cd $IMAGE_DIR
       
   200 
       
   201 if ! pkg status -a; then
       
   202 	fail pkg status -a failed
       
   203 fi
       
   204 
       
   205 if ! pkg install [email protected]; then
       
   206 	fail pkg install foo failed
       
   207 fi
       
   208 
       
   209 find $IMAGE_DIR
       
   210 
       
   211 if ! pkg status; then
       
   212 	fail pkg status failed
       
   213 fi
       
   214 
       
   215 if ! pkg install [email protected]; then
       
   216 	fail pkg install foo \(1.0 -\> 1.1\) failed
       
   217 fi
       
   218 
       
   219 find $IMAGE_DIR
       
   220 
       
   221 if ! pkg uninstall foo; then
       
   222 	fail pkg status failed
       
   223 fi
       
   224 
       
   225 find $IMAGE_DIR
       
   226 
       
   227 if ! pkg status -a; then
       
   228 	fail pkg status -a failed
       
   229 fi
       
   230 
       
   231 # }}}1
       
   232 
       
   233 # Case 4.  Add [email protected], dependent on [email protected], install, uninstall.
       
   234 # {{{1
       
   235 
       
   236 tcase=4
       
   237 trans_id=$(pkgsend -s $REPO_URL open [email protected],5.11-0)
       
   238 if [[ $? != 0 ]]; then
       
   239 	fail pkgsend open failed
       
   240 fi
       
   241 
       
   242 eval $trans_id
       
   243 
       
   244 if ! pkgsend -s $REPO_URL add depend type=require fmri=pkg:/[email protected]; then
       
   245 	fail pkgsend add depend require failed
       
   246 fi
       
   247 
       
   248 if ! pkgsend -s $REPO_URL add dir mode=0755 owner=root group=bin path=/bin; then
       
   249 	fail pkgsend add dir failed
       
   250 fi
       
   251 
       
   252 if ! pkgsend -s $REPO_URL add file /bin/cat mode=0555 owner=root group=bin \
       
   253 	path=/bin/cat; then
       
   254 	fail pkgsend add file failed
       
   255 fi
       
   256 
       
   257 if ! pkgsend -s $REPO_URL close; then
       
   258 	fail pkgsend close failed
       
   259 fi
       
   260 
       
   261 if ! pkg image-create -F -a test=$REPO_URL $IMAGE_DIR; then
       
   262 	fail pkgsend close failed
       
   263 fi
       
   264 
       
   265 find $IMAGE_DIR
       
   266 
       
   267 cd $IMAGE_DIR
       
   268 
       
   269 if ! pkg status -a; then
       
   270 	fail pkg status -a failed
       
   271 fi
       
   272 
       
   273 if ! pkg install [email protected]; then
       
   274 	fail pkg install bar failed
       
   275 fi
       
   276 
       
   277 find $IMAGE_DIR
       
   278 
       
   279 if ! pkg status; then
       
   280 	fail pkg status failed
       
   281 fi
       
   282 
       
   283 find $IMAGE_DIR
       
   284 
       
   285 if ! pkg uninstall -v bar foo; then
       
   286 	fail pkg uninstall failed
       
   287 fi
       
   288 
       
   289 find $IMAGE_DIR
       
   290 
       
   291 if ! pkg status -a; then
       
   292 	fail pkg status -a failed
       
   293 fi
       
   294 
       
   295 # }}}1
       
   296 
       
   297 # Case 5.  Install [email protected], dependent on [email protected], uninstall recursively.
       
   298 # {{{1
       
   299 
       
   300 tcase=5
       
   301 
       
   302 if ! pkg image-create -F -a test=$REPO_URL $IMAGE_DIR; then
       
   303 	fail pkg image-create failed
       
   304 fi
       
   305 
       
   306 find $IMAGE_DIR
       
   307 
       
   308 cd $IMAGE_DIR
       
   309 
       
   310 if ! pkg status -a; then
       
   311 	fail pkg status -a failed
       
   312 fi
       
   313 
       
   314 if ! pkg install [email protected]; then
       
   315 	fail pkg install bar failed
       
   316 fi
       
   317 
       
   318 find $IMAGE_DIR
       
   319 
       
   320 if ! pkg status; then
       
   321 	fail pkg status failed
       
   322 fi
       
   323 
       
   324 find $IMAGE_DIR
       
   325 
       
   326 if ! pkg uninstall -vr bar; then
       
   327 	fail pkg uninstall -vr failed
       
   328 fi
       
   329 
       
   330 find $IMAGE_DIR
       
   331 
       
   332 if ! pkg status -a; then
       
   333 	fail pkg status -a failed
       
   334 fi
       
   335 
       
   336 # }}}1
       
   337 
       
   338 exit 0