-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e74ec9
commit 125beaf
Showing
4 changed files
with
226 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# tdnf-test-doc spec file | ||
# | ||
Summary: basic install test file. | ||
Name: tdnf-test-doc | ||
Version: 1.0.1 | ||
Release: 2 | ||
Vendor: VMware, Inc. | ||
Distribution: Photon | ||
License: VMware | ||
Url: http://www.vmware.com | ||
Group: Applications/tdnftest | ||
|
||
%description | ||
Part of tdnf test spec. Basic install/remove/upgrade test | ||
|
||
%prep | ||
|
||
%build | ||
|
||
%install | ||
mkdir -p %_topdir/%buildroot/usr/share/doc/tdnf-test-doc | ||
echo "hello" > %_topdir/%buildroot/usr/share/doc/tdnf-test-doc/README | ||
mkdir -p %_topdir/%buildroot/lib/systemd/system/ | ||
cat << EOF >> %_topdir/%buildroot/lib/systemd/system/tdnf-test-doc.service | ||
[Unit] | ||
Description=tdnf-test-doc.service for whatprovides test. | ||
EOF | ||
|
||
%files | ||
%doc /usr/share/doc/tdnf-test-doc/README | ||
/lib/systemd/system/tdnf-test-doc.service | ||
|
||
%changelog | ||
* Tue Nov 15 2016 Xiaolin Li <[email protected]> 1.0.1-2 | ||
- Add a service file for whatprovides test. | ||
* Tue Dec 15 2015 Priyesh Padmavilasom <[email protected]> 1.0 | ||
- Initial build. First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# | ||
# Copyright (C) 2019 - 2022 VMware, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the GNU General Public License v2 (the "License"); | ||
# you may not use this file except in compliance with the License. The terms | ||
# of the License are located in the COPYING file of this distribution. | ||
# | ||
|
||
import os | ||
import subprocess | ||
import pytest | ||
import shutil | ||
|
||
|
||
WORKDIR = '/root/test_tsflags' | ||
TEST_CONF_FILE = 'tdnf.conf' | ||
TEST_CONF_PATH = os.path.join(WORKDIR, TEST_CONF_FILE) | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=True) | ||
def setup_test(utils): | ||
yield | ||
teardown_test(utils) | ||
|
||
|
||
def teardown_test(utils): | ||
packages = ["tdnf-bad-pre", utils.config["mulversion_pkgname"], "tdnf-test-doc"] | ||
utils.run(['tdnf', 'erase', '-y'] + packages) | ||
|
||
try: | ||
os.remove(TEST_CONF_PATH) | ||
except OSError: | ||
pass | ||
|
||
|
||
# Verify that the package is really bad: | ||
def test_install_normal(utils): | ||
pkgname = 'tdnf-bad-pre' | ||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', pkgname]) | ||
assert ret['retval'] == 1525 | ||
|
||
|
||
def test_install_noscripts(utils): | ||
pkgname = 'tdnf-bad-pre' | ||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=noscripts', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
|
||
def test_install_noscripts_nodocs(utils): | ||
pkgname = 'tdnf-bad-pre' | ||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=noscripts', '--setopt=tsflags=nodocs', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
|
||
def test_install_justdb(utils): | ||
pkgname = utils.config["mulversion_pkgname"] | ||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=justdb', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
# package should look like it's installed, but no files should be installed | ||
assert utils.check_package(pkgname) | ||
process = subprocess.run(['rpm', '-ql', pkgname], stdout=subprocess.PIPE, text=True) | ||
for f in process.stdout.split(): | ||
assert not os.path.exists(f) | ||
|
||
|
||
# opposite of --justdb | ||
def test_install_nodb(utils): | ||
pkgname = utils.config["mulversion_pkgname"] | ||
utils.erase_package(pkgname) | ||
|
||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=nodb', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
# package should appear to not be installed, but files should be there: | ||
assert not utils.check_package(pkgname) | ||
process = subprocess.run(['tdnf', 'repoquery', '--list', pkgname], stdout=subprocess.PIPE, text=True) | ||
for f in process.stdout.split(): | ||
if f.startswith("/"): | ||
assert os.path.exists(f) | ||
|
||
|
||
# opposite of --justdb | ||
def test_install_nodocs(utils): | ||
pkgname = "tdnf-test-doc" | ||
utils.erase_package(pkgname) | ||
|
||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=nodocs', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
# make sure packe is installed | ||
assert utils.check_package(pkgname) | ||
# but no doc file | ||
assert not os.path.exists("/usr/share/doc/tdnf-test-doc/README") | ||
|
||
|
||
def test_install_multiple(utils): | ||
pkgname = utils.config["mulversion_pkgname"] | ||
utils.erase_package(pkgname) | ||
|
||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'--setopt=tsflags=nodb nodocs', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
# package should appear to not be installed, but files should be there: | ||
assert not utils.check_package(pkgname) | ||
process = subprocess.run(['tdnf', 'repoquery', '--list', pkgname], stdout=subprocess.PIPE, text=True) | ||
for f in process.stdout.split(): | ||
if f.startswith("/"): | ||
assert os.path.exists(f) | ||
|
||
# no doc file | ||
assert not os.path.exists("/usr/share/doc/tdnf-test-doc/README") | ||
|
||
|
||
def test_install_multiple_from_config(utils): | ||
pkgname = utils.config["mulversion_pkgname"] | ||
utils.erase_package(pkgname) | ||
|
||
tdnf_conf = os.path.join(utils.config['repo_path'], 'tdnf.conf') | ||
|
||
utils.makedirs(WORKDIR) | ||
shutil.copy(tdnf_conf, TEST_CONF_PATH) | ||
utils.edit_config({'tsflags': "nodb nodocs"}, section='main', filename=TEST_CONF_PATH) | ||
|
||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'-c', TEST_CONF_PATH, pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
# package should appear to not be installed, but files should be there: | ||
assert not utils.check_package(pkgname) | ||
process = subprocess.run(['tdnf', 'repoquery', '--list', pkgname], stdout=subprocess.PIPE, text=True) | ||
for f in process.stdout.split(): | ||
if f.startswith("/"): | ||
assert os.path.exists(f) | ||
|
||
# no doc file | ||
assert not os.path.exists("/usr/share/doc/tdnf-test-doc/README") | ||
|
||
# do this again, but override config settings to "normal": | ||
ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', | ||
'-c', TEST_CONF_PATH, '--setopt=tsflags=', pkgname]) | ||
assert ret['retval'] == 0 | ||
|
||
assert utils.check_package(pkgname) | ||
|
||
# check all files exist - that includes doc files: | ||
process = subprocess.run(['tdnf', 'repoquery', '--list', pkgname], stdout=subprocess.PIPE, text=True) | ||
for f in process.stdout.split(): | ||
if f.startswith("/"): | ||
assert os.path.exists(f) |