Commit graph

377 commits

Author SHA1 Message Date
morganamilo
aff98a2bd9
Add tests for partial upgrades 2024-03-16 20:30:50 +00:00
morganamilo
a22d07b177
Fix tests that perform partial upgrades 2024-03-16 20:30:47 +00:00
Allan McRae
d55b47e551 Update copyright years
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-02-24 18:40:44 +10:00
Andrew Gregory
0a394144b2 validate package metadata after loading
alpm has certain requirements for package metadata necessary for proper
functioning, name and version in particular.  These requirements are
already enforced in makepkg, but nowhere in alpm.

Exceptions are treated as errors for non-local packages because they
cannot be installed without potentially resulting in undefined behavior.
Exceptions for local packages are treated as warnings because they are
already installed, so any damage has already been done, and the user
would otherwise have no way to uninstall them.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2024-02-07 12:27:26 +00:00
Andrew Gregory
dc91476555 pacman: add cache server support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Andrew Gregory
45e94e2dae pmtest: return pkg from addpkg2db
Allows more compact syntax:

p1 = self.addpkg2db('sync', pmpkg("foo"))

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2023-12-02 04:56:25 +00:00
Xiretza
05f283b5ad tests: fix order of fakechroot + fakeroot nesting
As noted in the fakechroot(1) man page, fakeroot and fakechroot
might wrap the same C library functions. Arch Linux hit this
recently with calls to stat(). It is important to start the fake
environment in proper order - fakeroot should be started inside
fakechroot.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-09-19 17:55:24 +10:00
Allan McRae
a81ec016d7 Update pactest README
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 19:25:23 +10:00
Allan McRae
c89f42f17b meson: do not use meson.source_root() and meson.build_root()
Using meson.source_root() and meson.build_root() are deprectated in
meson-0.56.  Using current_source_dir() or current_build_dir() (which
have been available in all Meson versions) would require manually
adding "../" in some places.  Instead, use project_source_root() and
project_build_root() and require meson-0.56.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-03-06 16:26:34 +10:00
Allan McRae
90df85e9cf Update copyright years
./build-aux/update-copyright 2021 2022

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-01-02 13:34:52 +10:00
morganamilo
b0a2fd75b2 Update mailing list url
change pacman-dev@archlinux.org to pacmandev@lists.archlinux.org

Most of this is copyright notices but this also fixes FS#72129 by
updating the address in docs/index.asciidoc.
2021-11-20 12:38:25 -08:00
morganamilo
f951282bec pactest: add tests for downloading packages from a cdn
Test for downloads that redirect to some sort of cdn where the
redirected url does not relate to the original filename.

Signed-off-by: Allan McRae <allan@archlinux.org>
2021-09-04 10:34:00 +10:00
morganamilo
2e83a52205 pactest: add test case for servers returning 404 with body
Signed-off-by: morganamilo <morganamilo@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-06-07 14:14:08 +10:00
Andrew Gregory
0ff94ae85d fix downloading multiple urls with XferCommand
An extra break causes _alpm_download to break out of the payload loop as
soon as it sees a successful url download with XferCommand.

Fixes: FS#70608 - -U fails to download all files with XferCommand

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2021-05-01 12:08:14 +10:00
Andrew Gregory
8faf749fd1 pmserve: allow serving byte objects directly
Useful for serving in-memory package files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2021-05-01 12:08:14 +10:00
Andrew Gregory
ab622b4881 pmpkg: add makepkg_bytes
Builds the package file in memory.  Useful with the built-in server.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2021-05-01 12:08:14 +10:00
Dan McGee
3179db108a Add support for multiple 'Architecture' values
This allows architecture to be multivalued. On x86-64 machines, this
could be something like:
    Architecture = x86-64-v3 x86-64

We use the first specified Architecture value in mirrorlist $arch
variable replacement, as this is backwards-compatible and sane.

Original-patch-by: Dan McGee <dan@archlinux.org>
Patch-updated-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-22 00:15:21 +10:00
Jelle van der Waa
f09047f0b0 test: update mailing list url
The Arch Linux mailing lists are these days served from the lists
subdomain.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-08 10:14:30 +10:00
Eli Schwartz
d6f8659443 ensure tests are parsed as TAP since they are, in fact, TAP
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-04-07 22:38:52 +10:00
Allan McRae
17f9911ffc Update copyright year
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-03-01 12:22:20 +10:00
Andrew Gregory
b40c5553b4 add --upgrade download tests
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-21 17:19:26 +10:00
Andrew Gregory
b82a975e76 pmtest: add ability to spawn simple http servers
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-21 17:19:16 +10:00
Andrew Gregory
ad84a572aa pmdb: add option to skip populating file:// server
Populating a file:// Server prevents any manually registered HTTP
servers from ever being used.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-21 17:19:01 +10:00
Andrew Gregory
743e041dbc add CACHE_FEXISTS and CACHE_FCONTENTS test rules
The existing CACHE_EXISTS rule takes a package, which is not suitable
for -U tests that need to be able to check for specific files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-21 17:18:37 +10:00
Andrew Gregory
f9bc6c2b09 pactest.py: read options from PACTEST_OPTS
Makes it easier to pass options when not running pactest directly.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2021-01-21 17:18:14 +10:00
Allan McRae
454ea02438 Remove autotools support
This removes support for autotools in favour of meson.
2020-06-01 10:59:08 +10:00
Dave Reisner
cebda6d0ee meson: handle XFAIL tests outside of TAP
This change causes expected fail tests to actually fail by eliding the
'# TODO' from the test plan. In turn, we can now properly use
'should_fail' in the meson test() rule and see these expected fail
tests in the output:

Before:
  ...
  320/332 upgrade077.py                   OK 0.12679290771484375 s
  321/332 upgrade078.py                   OK 0.12620115280151367 s
  322/332 upgrade080.py                   OK 0.1252129077911377 s
  ...

  Ok:                 332
  Expected Fail:      0
  Fail:               0
  Unexpected Pass:    0
  Skipped:            0
  Timeout:            0

After:
  ...
  320/332 upgrade077.py                   OK 0.12679290771484375 s
  321/332 upgrade078.py                   EXPECTEDFAIL0.12620115280151367 s
  322/332 upgrade080.py                   OK 0.1252129077911377 s
  ...

  Ok:                 326
  Expected Fail:      6
  Fail:               0
  Unexpected Pass:    0
  Skipped:            0
  Timeout:            0

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-05-05 09:14:32 +10:00
Allan McRae
e76ec94083 build-aux/update-copyright 2019 2020
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-02-10 10:46:03 +10:00
Allan McRae
75bf8e887c Increase meson test timeout
Running the testsuite using "PACTEST_VALGRIND=1 ninja test -C build", I ran
into the following failure:

161/332 smoke001.py                             TIMEOUT 30.02 s

I figure an i7 @ 3.10GHz should be enough to run our testsuite... so boost
the meson test timeout to 120 seconds (which should be enough time for
anyone...).

Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-27 17:53:50 +10:00
Allan McRae
0965023fc5 tests: Fix typo in test description 2020-01-27 17:53:50 +10:00
Eli Schwartz
3073752bcd pactest: add environment option to run tests with valgrind
In autotools, if we wanted to run tests with valgrind, we used some Make
magic which passed arguments to pactest.py, but that doesn't work in
meson, because all arguments are encoded at configure time. Instead,
let's short-circuit the build runner logic entirely, and teach pactest
to default to running valgrind, when it detects an environment variable
set independent of the build system.

To run the tests with valgrind, we can now use:

PACTEST_VALGRIND=1 meson test -C builddir/

or

PACTEST_VALGRIND=1 make check

It is also possible, but confusing/inconsistent, to use

make check PY_LOG_FLAGS=--valgrind

We *could* add a meson option -Dvalgrind=true, but that is annoying to
reconfigure between test runs, and overall the consensus is it seems
simpler to opt in each time we want to run valgrind, as was already the
case.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-26 11:05:44 +10:00
Allan McRae
b9faf65273 pactest: set package tar format to GNU_FORMAT
python-3.8 changed the default tar format to PAX_FORMAT. This caused
issues in our testsuite with package extraction of files with UTF-8
characters as we run the tests under the C locale.

sycn600.py:
error: error while reading package /tmp/pactest-xuhri4xa/var/cache/pacman/pkg/unicodechars-2.0-1.pkg.tar.gz: Pathname can't be converted from UTF-8 to current locale.

Set format back to GNU_FORMAT.

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-12 16:14:57 +10:00
Eli Schwartz
8c7043390f scripts/library: remove human_to_size
pkgdelta was the last user, and it is gone now.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-06 15:52:21 +10:00
Ethan Sommer
1bfae7d14a libmakepkg: fix empty arguments in parseopts
Previously parseopts checked if there was an argument by checking
that the string was non-empty, resulting in empty arguments being
incorrectly considered non-existent. This change makes parseopts check
if arguments exist at all, rather than checking that they are non-empty

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-05 14:47:15 +10:00
Ethan Sommer
7be7552329 libmakepkg: add optional argument support to parseopts
Adds a "?" suffix that can be used to indicate that an option's argument is
optional.

This allows options to have a default behaviour when the user doesn't
specify one, e.g.: --color=[when] being able to behave like --color=auto
when only --color is passed

Options with optional arguments given on the command line will be returned
in the form "--opt=optarg" and "-o=optarg". Despite that not being the
syntax for passing an argument with a shortopt (trying to pass -o=foo
would make -o's argument "=foo"), this is done to allow the caller to split
the option and its optarg easily

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Reviewed-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-11-04 10:55:23 +10:00
Allan McRae
f37a3752b3 Update copyright years
make update-copyright OLD=2018 NEW=2019

Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-23 22:06:54 +10:00
Andrew Gregory
808a4f15ce run XferCommand via exec
system() runs the provided command via a shell, which is subject to
command injection.  Even though pacman already provides a mechanism to
sign and verify the databases containing the urls, certain distributions
have yet to get their act together and start signing databases, leaving
them vulnerable to MITM attacks.  Replacing the system call with an
almost equivalent exec call removes the possibility of a shell-injection
attack for those users.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2019-10-12 07:04:20 -07:00
Eli Schwartz
bcb44891ef autotools: distribute meson files
If we use make dist to create the official, signed release tarballs,
those will not have meson build files by default since autotools doesn't
know what they are.

Also distribute all src/common/ files. We never strictly needed any of
them to be distributed with autotools, because the dist tarball
dereferences the symlinks (???), but only some of them were being
distributed, and meson needs them to be in the right location as we only
build libcommon from the primary files.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-04 11:25:48 +10:00
Dave Reisner
18a6440061 meson: remove tap-driver.py, use meson's TAP protocol
This includes a patch from Andrew to fix pactest's TAP output for
subtests. Original TAP support in meson was added in 0.50, but 0.51
contains a bugfix that ensures the test still work with the --verbose
flag passed to meson test, so let's depend on that.
2019-08-12 10:03:17 +10:00
Andrew Gregory
39c20ad4f1 hooks: rename type File to Path
Make it clearer that the targets are matched against both directories
and regular files and free up File to potentially refer specifically to
regular files in the future.  File is retained as a deprecated alias for
Path for the time being to avoid breaking existing hooks and will be
removed in a future release.

See FS#53136.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-06-06 10:38:31 +10:00
Andrew Gregory
2d403709d9 allow tests for disabled features to be skipped
Previously, pacman's test suite would fail when compiled without
signature support.

Adds a require_capability method to pmtest objects.  Currently
recognized values are 'gpg', 'curl', and 'nls'; although only gpg is
used presently.  Missing features are indicated by running pactest with
one of the --without-<feature> options.

This modifies pmenv to run each case as independent tests.  Previously,
a single pmenv could run multiple tests, combining there output into
a single TAP stream but making it impossible to properly skip an entire
test case.  This change does not affect running pactest.py with a single
test (as both autotools and meson do), but will affect anybody manually
running pactest.py with multiple tests at once.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:10:47 +10:00
Andrew Gregory
ecac357c1a tap.py: add skip_all function
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:10:37 +10:00
Andrew Gregory
d150b97190 remove unused test summary code
Unused since 12e00af531

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04 11:09:48 +10:00
Andrew Gregory
f28ddd9d93 check localdb before upgrading package
Commit 2ee7a8d89a replaced a manual check
for a local package with a check for the "oldpkg" member, which gets set
at the beginning of the transaction.  If the package was also in the
remove list, such as when a package gets replaced, it would no longer be
in the local db and pacman would try to remove it twice, resulting in
superfluous error messages.

Fixes: FS#50875, FS#55534

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-12-10 11:12:06 +10:00
Andrew Gregory
6e819c819a add missing tests to meson.build
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-11-28 10:24:28 +10:00
Dave Reisner
51db84750e Add meson.build files to build with meson
Provide both build systems in parallel for now, to ensure that we work
out all the differences between the two. Some time from now, we'll give
up on autotools.

Meson tends to be faster and probably easier to read/maintain. On my
machine, the full meson configure+build+install takes a little under
half as long as a similar autotools-based invocation.

Building with meson is a two step process. First, configure the build:

  meson build

Then, compile the project:

  ninja -C build

There's some mild differences in functionality between meson and
autotools.  specifically:

1) No singular update-po target. meson only generates individual
update-po targets for each textdomain (of which we have 3).  To make
this easier, there's a build-aux/update-po script which finds all
update-po targets and runs them.

2) No 'make dist' equivalent. Just run 'git archive' to generate a
suitable tarball for distribution.
2018-11-02 03:16:34 -04:00
Andrew Gregory
ac959bb9c6 handle EINTR while polling scripts/hooks
If poll() is interrupted by a signal, alpm was closing the socket it
uses for listening to script/hook output.  This would drop script output
at the least and kill the script at the worst.

Fixes FS#60396

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-10-21 19:19:48 +10:00
Andrew Gregory
9886566abb reset signal handlers before running scripts/hooks
Front-ends or libraries may set signals to be ignored, which gets
inherited across fork and exec.  This can cause scripts to malfunction
if they expect the signal.  To make matters worse, scripts written in
bash can't reset signals that were ignored when bash was started.

Fixes FS#56756

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-10-21 19:18:29 +10:00
Dave Reisner
afb9c0140f Port pactest to python3
Use BytesIO instead of StringIO, and ensure that we unicode-encode data
where needed.
2018-10-18 18:05:19 -07:00
Allan McRae
7d05ffceaf Remove the last traces of the pacman --force option
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10 12:38:03 +10:00