diff --git a/.gitignore b/.gitignore index 1844bef..6a128c2 100644 --- a/.gitignore +++ b/.gitignore @@ -38,26 +38,3 @@ /v0.9.0.tar.gz /dmpd090-vendor.tar.gz /dmpd090-vendor2.tar.gz -/dmpd090-vendor3.tar.gz -/v1.0.2.tar.gz -/dmpd102-vendor.tar.gz -/v1.0.4.tar.gz -/dmpd104-vendor.tar.gz -/v1.0.5.tar.gz -/dmpd105-vendor.tar.gz -/v1.0.6.tar.gz -/dmpd106-vendor.tar.gz -/v1.0.9.tar.gz -/dmpd109-vendor.tar.gz -/v1.0.11.tar.gz -/dmpd1011-vendor.tar.gz -/v1.0.12.tar.gz -/dmpd1012-vendor.tar.gz -/v1.1.0.tar.gz -/dmpd110-vendor.tar.gz -/v1.2.1.tar.gz -/dmpd121-vendor.tar.gz -/v1.3.0.tar.gz -/dmpd130-vendor.tar.gz -/v1.3.1.tar.gz -/dmpd131-vendor.tar.gz diff --git a/0001-Update-dependencies.patch b/0001-Update-dependencies.patch new file mode 100644 index 0000000..aaca7ac --- /dev/null +++ b/0001-Update-dependencies.patch @@ -0,0 +1,25 @@ +From 4a45e1d7eafb83ec9c76f0b3278f4bc7efbdde9d Mon Sep 17 00:00:00 2001 +From: Marian Csontos +Date: Tue, 1 Sep 2020 14:55:48 +0200 +Subject: [PATCH] Update dependencies + +--- + Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Cargo.toml b/Cargo.toml +index 892ea4c..93fc807 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -9,7 +9,7 @@ license = "GPL3" + anyhow = "1.0" + byteorder = "1.3" + clap = "2.33" +-crc32c = "0.4" ++crc32c = "0.5" + flate2 = "1.0" + fixedbitset = "0.3" + libc = "0.2.71" +-- +1.8.3.1 + diff --git a/README.md b/README.md index a81396d..4c77f74 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,24 @@ -# Packaging device-mapper-persitent-data (AKA dmpd) +# Packaging dmpd -This is rust package using *vendor* file for dependencies. (Vendor file is an archive of dependencies' sources.) +This is mostly regular package except recent addition of rust to used languages. -For most of simple fixes, there is nothing special, -to add a patches simply add them to dist-git, -add a corresponding `PatchN: 000N-...` lines, -increase `Release:` or `release_suffix` for Z-stream (or for test build use suffix like `.bzNNNNNN`), -add to `%changelog`, -commit, -push, -and build the package using `fedpkg build`. +## rust-tools -Alternatively before committing anything use `fedpkg srpm` and `fedpkg scratch-build --srpm $SRPM [--arches x86_64]` to create a scratch build. +To build the rust-tools (`make rust-tools`) one needs: -However when building a new version of dmpd or when updating a dependency is -needed (e.g. because of CVE in the dependency) vendor file -has to be regenerated. +- rust >= 1.35 +- cargo with vendor subcommand (now upstream, included in latest Fedora and RHEL8) -## Updating vendor file +### cargo vendpr -To build a new version of the package following tooling is needed: - -- `rust >= 1.35` -- `cargo` providing vendor subcommand (now upstream, included in latest Fedora and RHEL8+) - -To create the vendor file: - -In the upstream directory: - -1. Run `cargo vendor` in the directory with upstream sources to create *vendor* - directory with sources. - - TODO: There is a *cargo-vendor-filterer* project used by *stratisd* to - filter out unnecessary dependencies for other operating systems. -2. Run `tar czf device-mapper-persistent-data-vendor-$VERSION.tar.gz ./vendor` to create a tarball. -3. Copy the vendor file to dist git directory. - -In the dist-git directory: - -1. Get the upstream tarball `wget https://github.com/jthornber/thin-provisioning-tools/archive/v$VERSION.tar.gz` - - NOTE: Migration to `https://github.com/device-mapper-utils/thin-provisioning-tools` is coming. -2. Update *Source0* and *Source1* to correct values. -3. Add the tarballs to koji/brew lookaside: +- run `cargo vendor` in the disrectory with sources +- run `tar czf device-mapper-persistent-data-vendor-$VERSION.tar.gz ./vendor` +- copy the file (if version changed) and run the *fedpkg new-sources* command: - `fedpkg new-sources v$VERSION.tar.gz device-mapper-persistent-data-vendor-$VERSION.tar.gz` ## TODO/NOTES -Some of the dependencies are already packaged by Fedora. Can we instruct *cargo vendor* to include only those which are not provided by Fedora? -It would be possible to include these as submodules, and the rest could be used from Fedora. -For RHEL and CentOS Stream using vendor file is the recommended way. +Some of the dependencies may be already packaged by Fedora. Can we instruct *cargo vendor* to include only those which are not provided by Fedora? -*%cargo_install* installs by default in */usr/bin* but the package expects */usr/sbin*. For now I run *make install-rust-tools*. -Now Fedora unified the */usr/sbin* and */usr/bin* directories, to this can be "fixed" in Fedora and later in CentOS Stream. +*%cargo_install* installs by defualt in */usr/bin* but the package expects */usr/sbin*. For now I run *make install-rust-tools*. diff --git a/device-mapper-persistent-data.spec b/device-mapper-persistent-data.spec index 213bfff..6f3c954 100644 --- a/device-mapper-persistent-data.spec +++ b/device-mapper-persistent-data.spec @@ -1,38 +1,30 @@ # # Copyright (C) 2011-2017 Red Hat, Inc # -%bcond_without check -#%%global debug_package %%{nil} #%%global version_suffix -rc2 #%%global release_suffix .test3 Summary: Device-mapper Persistent Data Tools Name: device-mapper-persistent-data -Version: 1.3.1 -Release: 1%{?dist}%{?release_suffix} -License: GPL-3.0-only AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-3-Clause AND MIT AND (MIT OR Apache-2.0) AND (MIT OR Zlib OR Apache-2.0) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT) - -#ExcludeArch: %%{ix86} +Version: 0.9.0 +Release: 3%{?dist}%{?release_suffix} +License: GPLv3+ URL: https://github.com/jthornber/thin-provisioning-tools #Source0: https://github.com/jthornber/thin-provisioning-tools/archive/thin-provisioning-tools-%%{version}.tar.gz Source0: https://github.com/jthornber/thin-provisioning-tools/archive/v%{version}%{?version_suffix}.tar.gz -Source1: dmpd131-vendor.tar.gz +Source1: dmpd090-vendor2.tar.gz +Patch0: device-mapper-persistent-data-avoid-strip.patch +Patch1: 0001-Update-dependencies.patch -%if %{defined rhel} -BuildRequires: rust-toolset -%else +BuildRequires: autoconf, expat-devel, libaio-devel, libstdc++-devel, boost-devel, gcc-c++ +Requires: expat +%ifarch %{rust_arches} BuildRequires: rust-packaging BuildRequires: rust >= 1.35 BuildRequires: cargo %endif BuildRequires: make -BuildRequires: systemd-devel -BuildRequires: clang-libs -BuildRequires: glibc-static -BuildRequires: device-mapper-devel -BuildRequires: clang -#BuildRequires: gcc %description thin-provisioning-tools contains check,dump,restore,repair,rmap @@ -43,46 +35,45 @@ are included and era check, dump, restore and invalidate to manage snapshot eras %prep -%autosetup -p1 -n thin-provisioning-tools-%{version}%{?version_suffix} -a1 -%cargo_prep -v vendor +%setup -q -n thin-provisioning-tools-%{version}%{?version_suffix} +%ifarch %{rust_arches} +%patch1 -p1 -b .toml_update +#%%cargo_prep +#%%cargo_generate_buildrequires +tar xf %{SOURCE1} +mkdir -p .cargo +cat > .cargo/config <> .cargo/config.toml << EOF -# -#[source."git+https://github.com/jthornber/rio?branch=master"] -#git = "https://github.com/jthornber/rio" -#branch = "master" -#replace-with = "vendored-sources" -# -#EOF +[source.vendored-sources] +directory = "vendor" +END +%endif +%patch0 -p1 -b .avoid_strip echo %{version}-%{release} > VERSION %generate_buildrequires %build -#make %{?_smp_mflags} V= +autoconf +%configure --with-optimisation= +make %{?_smp_mflags} V= +%ifarch %{rust_arches} %cargo_build -%cargo_license_summary -%{cargo_license} > LICENSE.dependencies -%cargo_vendor_manifest +%endif %install -# TODO: Check that MANDIR is unused and remove -%make_install STRIP=true MANDIR=%{_mandir} BINDIR=%{buildroot}%{_sbindir} - -%if %{with check} -%check -%cargo_test -#cargo test --test thin_shrink -- --nocapture --test-threads=1 +make DESTDIR=%{buildroot} MANDIR=%{_mandir} install +%ifarch %{rust_arches} +make DESTDIR=%{buildroot} MANDIR=%{_mandir} install-rust-tools +# cargo_install installs into /usr/bin +#%%cargo_install %endif %files -%doc README.md -%license COPYING -%license LICENSE.dependencies -%license cargo-vendor.txt +%doc COPYING README.md %{_mandir}/man8/cache_check.8.gz %{_mandir}/man8/cache_dump.8.gz %{_mandir}/man8/cache_metadata_size.8.gz @@ -98,13 +89,14 @@ echo %{version}-%{release} > VERSION %{_mandir}/man8/thin_dump.8.gz %{_mandir}/man8/thin_ls.8.gz %{_mandir}/man8/thin_metadata_size.8.gz -%{_mandir}/man8/thin_migrate.8.gz %{_mandir}/man8/thin_repair.8.gz %{_mandir}/man8/thin_restore.8.gz %{_mandir}/man8/thin_rmap.8.gz %{_mandir}/man8/thin_trim.8.gz +%ifarch %{rust_arches} %{_mandir}/man8/thin_metadata_pack.8.gz %{_mandir}/man8/thin_metadata_unpack.8.gz +%endif %{_sbindir}/pdata_tools %{_sbindir}/cache_check %{_sbindir}/cache_dump @@ -121,110 +113,17 @@ echo %{version}-%{release} > VERSION %{_sbindir}/thin_dump %{_sbindir}/thin_ls %{_sbindir}/thin_metadata_size -%{_sbindir}/thin_migrate %{_sbindir}/thin_repair %{_sbindir}/thin_restore %{_sbindir}/thin_rmap %{_sbindir}/thin_trim +%ifarch %{rust_arches} %{_sbindir}/thin_metadata_pack %{_sbindir}/thin_metadata_unpack +%endif #% {_sbindir}/thin_show_duplicates %changelog -* Tue Dec 02 2025 Marian Csontos - 1.3.1-1 -- Update to latest upstream release 1.3.1. - -* Wed Oct 22 2025 Marian Csontos - 1.3.0-1 -- Update to latest upstream release 1.3.0. - -* Thu Sep 04 2025 Marian Csontos - 1.2.1-1 -- Update to latest upstream release 1.2.1. - -* Wed Jul 23 2025 Fedora Release Engineering - 1.1.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Thu Jan 16 2025 Fedora Release Engineering - 1.1.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Sun Jan 12 2025 Zbigniew Jędrzejewski-Szmek - 1.1.0-2 -- Rebuilt for the bin-sbin merge (2nd attempt) - -* Mon Sep 02 2024 Marian Csontos - 1.1.0-1 -- Update to latest upstream release 1.1.0. - -* Wed Jul 17 2024 Fedora Release Engineering - 1.0.12-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Tue Jul 09 2024 Zbigniew Jędrzejewski-Szmek - 1.0.12-2 -- Rebuilt for the bin-sbin merge - -* Tue Feb 27 2024 Marian Csontos - 1.0.12-1 -- Update to latest upstream release 1.0.12. - -* Tue Feb 13 2024 Marian Csontos - 1.0.11-4 -- Add licenses for statically linked libraries. - -* Tue Feb 13 2024 Marian Csontos - 1.0.11-3 -- SPDX migration - -* Thu Feb 08 2024 Yaakov Selkowitz - 1.0.11-2 -- Update Rust macro usage - -* Thu Feb 08 2024 Marian Csontos - 1.0.11-1 -- Update to latest upstream release 1.0.11. - -* Wed Jan 24 2024 Fedora Release Engineering - 1.0.9-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Fri Jan 19 2024 Fedora Release Engineering - 1.0.9-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Mon Dec 11 2023 Marian Csontos - 1.0.9-1 -- Update to latest upstream release 1.0.9. - -* Thu Aug 31 2023 Marian Csontos - 1.0.6-2 -- Fix broken installation on ppc64le caused by incorrect ioctl call. - -* Wed Aug 09 2023 Marian Csontos - 1.0.6-1 -- Update to latest upstream release 1.0.6. - -* Thu Jul 27 2023 Marian Csontos - 1.0.5-1 -- Update to latest upstream release 1.0.5. - -* Wed Jul 19 2023 Fedora Release Engineering - 1.0.4-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Tue May 30 2023 Yaakov Selkowitz - 1.0.4-2 -- Use rust-toolset in RHEL builds - -* Fri Apr 28 2023 Marian Csontos - 1.0.4-1 -- Update to latest upstream release 1.0.4. - -* Wed Mar 22 2023 Marian Csontos - 1.0.3-1 -- Update to latest upstream release 1.0.3. - -* Sun Feb 05 2023 Fabio Valentini - 0.9.0-10 -- Rebuild for fixed frame pointer compiler flags in Rust RPM macros. - -* Thu Jan 19 2023 Fedora Release Engineering - 0.9.0-9 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Thu Jul 21 2022 Fedora Release Engineering - 0.9.0-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Thu Jan 20 2022 Fedora Release Engineering - 0.9.0-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Thu Jul 22 2021 Marian Csontos - 0.9.0-6 -- Fix rust-1.53 compilation issues. - -* Wed Jul 21 2021 Fedora Release Engineering - 0.9.0-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Thu Jun 10 2021 Marian Csontos - 0.9.0-4 -- Fix gating test syntax. -- Fix important issues found by static analysis. - * Tue Jan 26 2021 Fedora Release Engineering - 0.9.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild diff --git a/sources b/sources index 4ddfdfb..87073b3 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (v1.3.1.tar.gz) = ff0758b21b50702568cad88522ee4c2b6b4433cec0a5f5074c9d1791c13e630e5c516601d7a68c51ac34e036091fc82fe831dbe51e6776737571d90ed266878e -SHA512 (dmpd131-vendor.tar.gz) = 0e1b8e501e330b64415c9097c94dfc1f1b43d2900a66258e40b6c8f28c51fd61247d60495f594f14550fb349ed4ad435f8959a8808fea1d363a206c5ead7db1e +SHA512 (v0.9.0.tar.gz) = e1796fb3948847d72ca8247cae58017507c0a847a00201b93668eeb8fbfea4107c4c2affa5c211c149798a89b10474e83d2bd61a5545a668299be97aed591e0f +SHA512 (dmpd090-vendor2.tar.gz) = 47e22d34e34345ae5c91e66063c2f78865b055fccd47c34a97e2bd2fed1f64fc7f13ad27071a149fefba53f5b437beeda3bacde25b690431e1ae50f77cec440c diff --git a/tests/functions_test/Makefile b/tests/functions_test/Makefile index 6b14a2f..85cc8dd 100644 --- a/tests/functions_test/Makefile +++ b/tests/functions_test/Makefile @@ -40,7 +40,7 @@ export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) BUILT_FILES= # data files, .c files, scripts anything needed to either compile the test and/or run it. -FILES=$(METADATA) runtest.sh PURPOSE testinfo.desc dmpd_functions.py dmpd_library.py Makefile +FILES=$(METADATA) runtest.sh PURPOSE run: $(FILES) build ./runtest.sh @@ -62,7 +62,7 @@ include /usr/share/rhts/lib/rhts-make.include $(METADATA): Makefile @touch $(METADATA) # Change to the test owner's name - @echo "Owner: Filip Suba " > $(METADATA) + @echo "Owner: Jakub Krysl " > $(METADATA) @echo "Name: $(TEST)" >> $(METADATA) @echo "Path: $(TEST_DIR)" >> $(METADATA) @echo "License: GPL" >> $(METADATA) @@ -71,5 +71,6 @@ $(METADATA): Makefile @echo "TestTime: 1h" >> $(METADATA) @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "RhtsRequires: kernel-kernel-storage-misc-env_setup" >> $(METADATA) rhts-lint $(METADATA) diff --git a/tests/functions_test/dmpd_functions.py b/tests/functions_test/dmpd_functions.py index 4d23f70..a908bcf 100755 --- a/tests/functions_test/dmpd_functions.py +++ b/tests/functions_test/dmpd_functions.py @@ -39,7 +39,7 @@ def thin_init(args): atomic_run("Creating thin pool", vg_name=args["group"], lv_name=args["pool"], - options=["-T", "-L 1500"], + options=["-T", "-L 500"], command=lvm.lv_create, errors=errors) @@ -48,7 +48,7 @@ def thin_init(args): atomic_run("Creating thin LV No. %s" % i, vg_name=args["group"] + "/" + args["pool"], lv_name=args["vol"] + str(i), - options=["-T", "-V 300"], + options=["-T", "-V 100"], command=lvm.lv_create, errors=errors) @@ -58,37 +58,36 @@ def thin_init(args): command=create_filesystem, errors=errors) + atomic_run("Deactivating thin LV No. %s" % i, + lv_name=args["vol"] + str(i), + vg_name=args["group"], + command=lvm.lv_deactivate, + errors=errors) + atomic_run("Creating metadata snapshot", lv_name=args["pool"], vg_name=args["group"], command=metadata_snapshot, errors=errors) - atomic_run("Creating swap LV", - vg_name=args["group"], - lv_name=args["swap"], - options=["-L 300"], - command=lvm.lv_create, - errors=errors) - - atomic_run("Deactivating swap", - lv_name=args["swap"], - vg_name=args["group"], - command=lvm.lv_deactivate, - errors=errors) - atomic_run("Deactivating pool", lv_name=args["pool"], vg_name=args["group"], command=lvm.lv_deactivate, errors=errors) - for i in range(args["number of vols"]): - atomic_run("Deactivating thin LV No. %s" % i, - lv_name=args["vol"] + str(i), - vg_name=args["group"], - command=lvm.lv_deactivate, - errors=errors) + atomic_run("Creating swap LV", + vg_name=args["group"], + lv_name=args["swap"], + options=["-L 100"], + command=lvm.lv_create, + errors=errors) + + atomic_run("Deactivating swap", + lv_name=args["swap"], + vg_name=args["group"], + command=lvm.lv_deactivate, + errors=errors) atomic_run("Swapping metadata", vg_name=args["group"], @@ -196,7 +195,7 @@ def thin_clean(args): def thin_test(args): print("\n#######################################\n") - print( + print ( "INFO: Testing thin tools runtime provided by device_mapper_persistent_data") errors = [] @@ -282,8 +281,7 @@ def thin_test(args): command=run, errors=errors) - atomic_run("Outputting reverse map of metadata device with negative number in region", - False, + atomic_run("Outputting reverse map of metadata device", source_vg=args["group"], source_lv=args["swap"], region="0..-1", @@ -417,7 +415,7 @@ def thin_test(args): def thin_errors_test(args): print("\n#######################################\n") - print( + print ( "INFO: Testing thin tools errors provided by device_mapper_persistent_data") errors = [] @@ -847,7 +845,7 @@ def cache_clean(args): def cache_test(args): print("\n#######################################\n") - print("INFO: Testing cache tools runtime provided by device_mapper_persistent_data") + print ("INFO: Testing cache tools runtime provided by device_mapper_persistent_data") errors = [] @@ -967,7 +965,7 @@ def cache_test(args): def cache_errors_test(args): print("\n#######################################\n") - print("INFO: Testing cache tools errors provided by device_mapper_persistent_data") + print ("INFO: Testing cache tools errors provided by device_mapper_persistent_data") errors = [] @@ -1113,7 +1111,6 @@ def cache_errors_test(args): # errors=errors) #FIXME: Find other way to corrupt metadata, this exploits a bug - """ atomic_run("Corrupting mappings on metadata device", False, source_file="Makefile", @@ -1142,7 +1139,7 @@ def cache_errors_test(args): source_lv=args['swap'], target_file="/tmp/metadata_repair", command=dmpd.cache_repair, - errors=errors)""" + errors=errors) atomic_run("Corrupting metadata on device", cmd="echo 'nothing' >> /dev/mapper/%s-%s" % (args['group'], args['swap']), @@ -1211,7 +1208,6 @@ def main(): "swap": "swapvol"} # Initialization - install_package("lvm2") install_package("device-mapper-persistent-data") # Tests for thin tools provided by device-mapper-persistent-data @@ -1227,10 +1223,10 @@ def main(): cache_clean(args) if not TC.tend(): - print("FAIL: test failed") + print "FAIL: test failed" sys.exit(1) - print("PASS: Test pass") + print "PASS: Test pass" sys.exit(0) diff --git a/tests/functions_test/dmpd_library.py b/tests/functions_test/dmpd_library.py index 1cf44df..e8f1ed9 100755 --- a/tests/functions_test/dmpd_library.py +++ b/tests/functions_test/dmpd_library.py @@ -16,8 +16,6 @@ """dmpd_library.py: Complete library providing functionality for device-mapper-persistent-data upstream test.""" -from __future__ import print_function - import platform from os.path import expanduser import re #regex @@ -25,8 +23,6 @@ import sys, os import subprocess import time import fileinput -# TODO: Is this really necessary? Unlikely we will run into python2 in rawhide -# again... def _print(string): @@ -56,7 +52,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): date = "date \"+%Y-%m-%d %H:%M:%S\"" p = subprocess.Popen(date, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p.communicate() - stdout = stdout.decode('ascii', 'ignore').rstrip("\n") + stdout = stdout.rstrip("\n") _print("INFO: [%s] Running: '%s'..." % (stdout, cmd)) #enabling shell=True, because was the only way I found to run command with '|' @@ -78,7 +74,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): retcode = p.returncode - output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore') + output = stdout + stderr #remove new line from last line output = output.rstrip() @@ -156,11 +152,11 @@ def dist_release(): """ Find out the release number of Linux distribution. """ - dist = platform.release() - if not dist: + dist = platform.linux_distribution() + if not dist or dist[1] == "": _print("WARN: dist_release() - Could not determine dist release") return None - return dist + return dist[1] def dist_ver(): @@ -195,8 +191,7 @@ def show_sys_info(): if run("rpm -q device-mapper-multipath") == 0: #Abort test execution if multipath is not working well if run("multipath -l 2>/dev/null") != 0: - print("WARN: Multipath is not configured correctly") - return + sys.exit(1) #Flush all unused multipath devices before starting the test run("multipath -F") run("multipath -r") @@ -607,7 +602,7 @@ class LogChecker: _print("WARN: Could not open %s" % log_msg_file) return True - log_file = open(log_msg_file, encoding="utf-8", errors="ignore") + log_file = open(log_msg_file) log = log_file.read() begin_tag = "\\[ cut here \\]" @@ -1047,7 +1042,7 @@ class LoopDev: _print("WARN: Could not create loop device image file") return ret_fail except OSError as e: - print("command failed: ", e, file=sys.err) + print >> sys.err, "command failed: ", e return ret_fail loop_path = self._get_loop_path(name) @@ -1130,7 +1125,7 @@ class LoopDev: name = self._standardize_name(name) # Just try to detach if device is connected, otherwise ignore - # print("INFO: Checking if ", loop_path, " exists, to be detached") + # print "INFO: Checking if ", loop_path, " exists, to be detached" dev_path = self._get_loop_path(name) if dev_path in devs: cmd = "losetup -d %s" % dev_path @@ -1204,7 +1199,7 @@ class LVM: cmd = "vgcreate %s %s %s" % (options, vg_name, pv_name) retcode = run(cmd, verbose=verbose) if (retcode != 0): - # _print("WARN: Could not create %s" % vg_name) + # _print ("WARN: Could not create %s" % vg_name) return False return True @@ -1282,7 +1277,7 @@ class LVM: _print("WARN: (%s) does not match lvs output format" % lv) continue lv_info_dict = {} - for index in range(len(param_names)): + for index in xrange(len(param_names)): lv_info_dict[param_names[index]] = m.group(index + 1) lv_list.append(lv_info_dict) @@ -1326,7 +1321,7 @@ class LVM: cmd = "lvcreate %s %s -n %s" % (" ".join(str(i) for i in options), vg_name, lv_name) retcode = run(cmd, verbose=verbose) if (retcode != 0): - # _print("WARN: Could not create %s" % lv_name) + # _print ("WARN: Could not create %s" % lv_name) return False return True @@ -1519,7 +1514,7 @@ class DMPD: _print("WARN: Could not create file to %s metadata to." % command_message) return False except OSError as e: - print("command failed: ", e, file=sys.err) + print >> sys.err, "command failed: ", e return False return True diff --git a/tests/tools_not_linked_usr/tools_not_linked_usr.py b/tests/tools_not_linked_usr/tools_not_linked_usr.py index 7be6393..7acb804 100755 --- a/tests/tools_not_linked_usr/tools_not_linked_usr.py +++ b/tests/tools_not_linked_usr/tools_not_linked_usr.py @@ -14,27 +14,25 @@ # # Author: Bruno Goncalves +from os import walk import subprocess import sys import re def run(cmd): - print("INFO: Running '%s'..." % cmd) + print "INFO: Running '%s'..." % cmd p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p.communicate() retcode = p.returncode - output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore') - - # remove new line from last line - output = output.rstrip() - print(output) + output = stdout + stderr + print output return retcode, output def start_test(): #if uses any library linked to /usr this my affect the tools during boot - print("INFO: Making sure tools provided by device-mapper-persistent-data " + print ("INFO: Making sure tools provided by device-mapper-persistent-data " "are not linked to /usr") #Paths where we should have no libraries linked from @@ -56,7 +54,7 @@ def start_test(): continue tool_error = 0 for lib_path in lib_paths: - print("INFO: Checking if %s is not linked to libraries at %s" % (tool, lib_path)) + print "INFO: Checking if %s is not linked to libraries at %s" % (tool, lib_path) ret, linked_lib = run("ldd %s" % tool) if ret != 0: print("FAIL: Could not list dynamically libraries for %s" % (tool)) @@ -85,10 +83,10 @@ def start_test(): def main(): if not start_test(): - print("FAIL: test failed") + print "FAIL: test failed" sys.exit(1) - print("PASS: Test pass") + print "PASS: Test pass" sys.exit(0) main()