diff options
Diffstat (limited to 'src/yum/test/yum_package.sh')
-rwxr-xr-x | src/yum/test/yum_package.sh | 278 |
1 files changed, 0 insertions, 278 deletions
diff --git a/src/yum/test/yum_package.sh b/src/yum/test/yum_package.sh deleted file mode 100755 index 5d81955..0000000 --- a/src/yum/test/yum_package.sh +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/bash - -dir=`dirname $0` -[ -z "$dir" ] && dir=. - -CLASS_NAME="LMI_YumPackage" -. $dir/test_common.sh - -declare -A pkg1 pkg2 -if [[ "$fedora_release" = 16 ]]; then - pkg1=( \ - [name]=python-xlib-doc - [epoch]=0 \ - [ver]=0.15 \ - [rel]=0.6.rc1.fc16 \ - [arch]=noarch \ - [updatable]=0 \ - ) - pkg2=( \ - [name]=ruby-ri \ - [epoch]=0 \ - [ver]=1.8.7.352 \ - [rel]=1.fc16 \ - [arch]=x86_64 \ - [updatable]=1 \ - [up_epoch]=0 \ - [up_ver]=1.8.7.358 \ - [up_rel]=2.fc16 \ - ) -elif [[ "$fedora_release" = 17 ]]; then - pkg1=( \ - [name]=python-xlib-doc - [epoch]=0 \ - [ver]=0.15 \ - [rel]=0.6.rc1.fc17 \ - [arch]=noarch \ - [updatable]=0 \ - ) - pkg2=( \ - [name]=slv2 \ - [epoch]=0 \ - [ver]=0.6.6 \ - [rel]=8.fc17 \ - [arch]=x86_64 \ - [updatable]=1 \ - [up_epoch]=0 \ - [up_ver]=0.6.6 \ - [up_rel]=9.fc17 \ - ) -elif [[ -z "$fedora_release" ]]; then - echo "failed to get Fedora release number!" 2>&1 - exit 1 -else - echo "no packages defined for Fedora release $fedora_release" 2>&1 - exit 1 -fi -keys=(name epoch ver rel arch updatable up_epoch up_ver up_rel) - -make_inst_keys() { - # accepts arguments: name, epoch, ver, rel, arch - # in this order - local path='Name="%s",SoftwareElementID="%s",SoftwareElementState="%s",' - path+='TargetOperatingSystem="%s",Version="%s"' - printf $path $1 `make_nevra "$@"` 2 36 $3 -} - -test_install() { - local name epoch ver rel arch updatable up_epoch up_ver up_rel; - read name epoch ver rel arch updatable \ - up_epoch up_ver up_rel <<< "$@" - - echo "********************************************************************" - echo " * TEST INSTALL" - nevra_arr=($name $epoch $ver $rel $arch) - nevra=`make_nevra ${nevra_arr[@]}` - echo -n "$nevra is " - [ "$updatable" == 0 ] && echo -n "not " - echo -n "updatable and " - is_installed $name || echo -n "not " - echo "installed" - - if is_installed $name; then - echo "removing package \"${nevra}\" with rpm" - remove $name - fi - - local keys=`make_inst_keys ${nevra_arr[@]}` - local url="$url/$op.${keys}" - - echo "trying to get instance" - if ! wbemerr gi "$url" |& \ - grep -q '\<SoftwareElementState="\?1"\?'; then - echo "wrong SoftwareElementState" - exit 1 - fi - - echo "installing $CLASS_NAME: $url" - if ! wbemerr cm "$url" Install |& \ - grep -q '\<Install:\s*1\s\+Installed'; then - echo "wrong return code" - exit 1 - fi - - if is_installed $name; then - echo "successful installation" - else - echo "package not installed" - exit 1 - fi - - echo "checking get instance" - if ! wbemerr gi "$url" |& \ - grep -q '\<SoftwareElementState="\?2"\?'; then - echo "wrong SoftwareElementState" - exit 1 - fi - - echo "testing installation of already installed package" - if ! wbemcli cm "${url}" Install |& \ - grep -q '\<Install:\s*0\s\+Installed'; then - echo "wrong return code" - exit 1 - fi -} - -test_update() { - read name epoch ver rel arch updatable \ - up_epoch up_ver up_rel <<< "$@" - - echo "********************************************************************" - echo " * TEST UPDATE" - if [ "$updatable" == 0 ]; then - echo "package not updatable" - exit 1 - fi - - nevra_arr=($name $epoch $ver $rel $arch) - nevra=`make_nevra ${nevra_arr[@]}` - echo -n "$nevra is " - [ "$updatable" == 0 ] && echo -n "not " - echo -n "updatable and " - is_installed $name || echo -n "not " - echo "installed" - - if is_installed $name; then - echo "removing package \"${name}\" with rpm" - remove $name - fi - - local keys=`make_inst_keys ${nevra_arr[@]}` - local package_url="$url/$op.$keys" - echo "intalling older package with $CLASS_NAME: $package_url" - wbemerr cm "$package_url" Install - - if is_installed $name; then - echo "successful installation" - else - echo "package not installed" - exit 1 - fi - - echo "updating with LMI_YumInstalledPackage.Update()" - - local installed_keys="Software=$op.$keys,System=$computer_system_op" - local installed_url="$url/`make_op LMI_YumInstalledPackage $installed_keys`" - if ! wbemerr cm "$installed_url" "Update" | \ - grep -q '\<Update:\s*1\s\+Installed'; then - echo "wrong return code" - exit 1 - fi - - if is_installed_nevra $name $up_epoch $up_ver $up_rel $arch; then - echo "successful update" - else - echo "update failed" - exit 1 - fi - - keys=`make_inst_keys $name $up_epoch $up_ver $up_rel $arch` - installed_keys="Software=$op.$keys,System=$computer_system_op" - local installed_url2="$url/`make_op LMI_YumInstalledPackage $installed_keys`" - echo "trying to update once more to: $installed_url2" - if ! wbemerr cm "$installed_url2" "Update" | \ - grep -q '\<Update:\s*0\s\+Installed'; then - echo "wrong return code" - exit 1 - fi - - echo "removing updated package" - wbemerr di "$installed_url2" - if is_installed $name; then - echo "failed to remove ${name}" - exit 1 - else - echo "success" - fi - - echo "installing older package" - install_pkg "$@" || exit 1 - - echo "trying to update to not existing version-release" - wbemerr cm "$installed_url" "Update.Version=\"not-existing-version\"" |& - grep -q CIM_ERR_NOT_FOUND && echo "ok" || echo "failed" - - echo "trying to update to the same version-release" - wbemerr cm "$installed_url" \ - "Update.Version=\"${ver}\",Release=\"${rel}\"" | \ - grep -q '\<Update:\s*0\s\+Installed' || \ - echo "wrong return code" - - if is_installed_nevra $name $epoch $ver $rel $arch; then - echo "success" - else - echo "failed" - exit 1 - fi - - echo "trying to update to the specific version" - wbemerr cm "$installed_url" \ - "Update.Version=\"${up_ver}\",Release=\"${up_rel}\"" | - grep -q '\<Update:\s*1\s\+Installed' || \ - echo "wrong return code" - - if is_installed_nevra $name $up_epoch $up_ver $up_rel $arch; then - echo "success" - else - echo "failed" - exit 1 - fi -} - -test_remove() { - read name epoch ver rel arch updatable \ - up_epoch up_ver up_rel <<< "$@" - - echo "********************************************************************" - echo " * TEST REMOVE" - nevra_arr=($name $epoch $ver $rel $arch) - nevra=`make_nevra ${nevra_arr[@]}` - - if ! is_installed $name; then - echo "installing package \"${nevra}\" with yum" - install_pkg "$@" || exit 1 - fi - - local keys=`make_inst_keys ${nevra_arr[@]}` - local installed_keys="Software=$op.$keys,System=$computer_system_op" - local installed_url="$url/`make_op LMI_YumInstalledPackage $installed_keys`" - wbemerr di "$installed_url" - if is_installed $name; then - echo "failed to remove ${name}" - exit 1 - else - echo "success" - fi - local url="$url/$op.$keys" - if ! wbemerr gi "$url" |& \ - grep -q '\<SoftwareElementState="\?1"\?'; then - echo "wrong SoftwareElementState" - exit 1 - fi -} - - -for p in 1 2 -do - declare -a args - for ((i=0; i < ${#keys[@]}; i++)) do - key=${keys[$i]} - eval "args[\$i]=\${pkg${p}[\$key]}" - done - - test_install "${args[@]}" - test_remove "${args[@]}" - eval "updatable=\${pkg${p}[updatable]}" - [ "$updatable" == 1 ] && test_update "${args[@]}" -done - |