summaryrefslogtreecommitdiff
path: root/tests/libtest.sh
Commit message (Collapse)AuthorAgeFilesLines
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* libtest: tweak selinux/relabel messageLuca BRUNO2021-09-061-1/+1
|
* tests: Unset SOURCE_DATE_EPOCHSimon McVittie2021-07-261-0/+4
| | | | | | | | | | | | | Some distributions set this during build in order to have reproducible builds from the same source code: for example, Debian uses the date from debian/changelog. However, some of our tests assume that `ostree commit` will result in a commit with the current date/time, and SOURCE_DATE_EPOCH breaks that assumption. Unset it for our build-time tests. Resolves: https://github.com/ostreedev/ostree/issues/2405 Signed-off-by: Simon McVittie <smcv@collabora.com>
* libtest.sh: Remove duplicate ERR trap and report_err()Simon McVittie2021-06-221-8/+0
| | | | | | | Since #2377 was merged, this is in libtest-core.sh, which is sourced by libtest.sh. Signed-off-by: Simon McVittie <smcv@collabora.com>
* *: rename master to main in tests & examplesTimothée Ravier2021-05-071-4/+4
|
* tests: Test without a cache directory by defaultDan Nicholson2021-04-191-0/+5
| | | | | | | | | | | | | | | | | | | Several tests generate summaries and then expect to use the generated summary immediately. However, this can cause intermittent test failures when they inadvertantly get a cached summary file. This typically happens when the test is run on a filesystem that doesn't support user extended attributes. In that case, the caching code can only use the last modified time, which only has 1 second granularity. If tests don't carefully manage the summary modification times or the repo cache then they are likely subject to races in some test environments. This introduces an environment variable `OSTREE_SKIP_CACHE` that prevents the repo from using a cache directory. This is enabled by default in tests and disabled for tests that are a explicitly trying to test the caching behavior. Fixes: #2313 Fixes: #2351
* libtest: On failure, make it clearer what has happenedSimon McVittie2021-04-181-0/+8
| | | | | | | | If we fail as a result of `set -x`, It's often not completely obvious which command failed or how. Use a trap on ERR to show the command that failed, and its exit status. Signed-off-by: Simon McVittie <smcv@collabora.com>
* build-sys: Remove --enable-experimental-apiColin Walters2021-04-071-6/+0
| | | | | | | | | It was added for the collections bits, but we made that stable. It's now just cruft and we're very unlikely to reuse the infrastructure again. Motivated by a unit test failure when running from a tarball: https://github.com/ostreedev/ostree/issues/2313
* Add an API+CLI to inject metadata for bootable OSTree commitsColin Walters2021-03-121-3/+6
| | | | | | | | | | | | | | | | | | | | | I was doing some rpm-ostree work and I wanted to compare two OSTree commits to see if the kernel has changed. I think this should be a lot more natural. Add `ostree commit --bootable` which calls into a new generic library API `ostree_commit_metadata_for_bootable()` that discovers the kernel version and injects it as an `ostree.linux` metadata key. And for extra clarity, add an `ostree.bootable` key. It's interesting because the "core" OSTree layer is all about generic files, but this is adding special APIs around bootable OSTree commits (as opposed to e.g. flatpak as well as things like rpm-ostree's pkgcache refs). Eventually, I'd like to ensure everyone is using this and hard require this metadata key for the `ostree admin deploy` flow - mainly to prevent accidents.
* Add --enable-sanitizers, fix `make check` with itColin Walters2021-02-031-0/+3
| | | | | | | | It's cleaner if this is an build option rather than being kludged into the CI layer. Notably we can't use `LD_PRELOAD` anymore with ASAN, so update our tests to check for `ASAN_OPTIONS`.
* tests/libtest.sh: Add skip_without_sign_ed25519() functionFrédéric Danis2020-09-141-0/+6
| | | | Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
* ci: Test for clock skewColin Walters2020-05-181-0/+12
| | | | | | | | I saw `tests/test-admin-deploy.none.sh` fail in one CI run, and I want to check if it was because of clock skew, so fail fast if we detect that. xref https://github.com/ostreedev/ostree/pull/2099#issuecomment-629805375
* Use `sign-ed25519` for the feature nameColin Walters2020-04-161-2/+2
| | | | | | | | `libsodium` is an implementation detail. In particular, I'd like to consider using OpenSSL for ed25519 (if libsodium isn't configured and openssl is). So switch the name of the exposed feature and adjust the tests.
* tests/libtest: add functions for ed25519 testsDenis Pynkin2020-03-251-4/+31
| | | | | | | | | | Add functions for keys generation to be used in signing-related tests: - gen_ed25519_keys initializing variables ED25519PUBLIC, ED25519SEED and ED25519SECRET with appropriate base64-encoded keys - gen_ed25519_random_public print a random base64 public key (used in tests with wrong keys) Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
* tests: add test for commits sign/verificationDenis Pynkin2020-03-251-0/+10
| | | | | | | | | | | | Add tests checking: - sign mechanism is in working state - module 'dummy' is able to sign/verify commit - module 'ed25519' is able to sign/verify commit - both modules could be used for the same commit - 'ostree sign' builtin works with commits - 'ostree commit' builtin able to sign commits Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
* tests/libtest: Make temporary gpghome privateDan Nicholson2020-01-241-1/+2
| | | | | | gpg prints a warning about unsafe permissions if the homedir is group or world readable. This is just noise in the test logs, so appease it by making the homedir 700.
* tests/libtest: Record long GPG key IDs and fingerprintsDan Nicholson2020-01-241-3/+6
| | | | | | Use long GPG key IDs as it's safer and matches the format used by gpg and gpgme. Add the associated fingerprints since these are needed by gpg when manipulating keys.
* tests: Skip /var test if running with systemd and libmountAlex Kiernan2019-12-291-0/+12
| | | | | | | If running with systemd and libmount then /var mounting is deferred for systemd. Skip the relevant tests in this case as it will always fail. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
* tests: Avoid musl failure with `cp -a`Alex Kiernan2019-11-011-1/+3
| | | | | | | | | | | When copying the tree, using musl and GNU coreutils, something gets confused when setting the ownership of symlinks and the copy fails with: cp: failed to preserve ownership for osdata-devel/bin: Not supported Rework using tar to avoid the problem. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
* lib/deploy: Also install HMAC file into /bootJonathan Lebon2019-10-291-0/+3
| | | | | | | | | | | | To allow for FIPS mode, we need to also install the HMAC file from `/usr/lib/modules` to `/boot` alongside the kernel image where the `fips` dracut module will find it. For details, see: https://github.com/coreos/fedora-coreos-tracker/issues/302 Note I didn't include the file in the boot checksum since it's itself a checksum of the kernel, so we don't really gain much here other than potentially causing an unnecessary bootcsum bump.
* tests/gpg: fix the check of GPG supportDenis Pynkin2019-08-011-2/+10
| | | | | | | | | | | | | Shell function `has_gpgme` shouldn't exit if GPG support is not detected since it stop any test with error. Added function `skip_without_gpgme` to skip the whole test if it is useless without GPG support Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com> Closes: #1889 Approved by: cgwalters
* tests: Always cleanup gpg-agent when exitingDan Nicholson2019-06-191-0/+1
| | | | | | | | | | | | | | | | Add `libtest_cleanup_gpg()` to the array of commands to run when exiting. This provides 2 improvements: 1. You don't need to worry about whether the test will spawn a gpg-agent and therefore require adding a call to `libtest_cleanup_gpg()`. 2. All the existing users were calling `libtest_cleanup_gpg()` at the end of the script. If there was a failure and the script exited early, then it wouldn't cleanup and there may be a stray gpg-agent hanging around. Closes: #1799 Approved by: cgwalters
* tests/libtest: Allow appending actions to be run on EXITDan Nicholson2019-06-191-2/+13
| | | | | | | | | | Currently if a test script adds a trap on `EXIT` to run some cleanup, it will stomp on the existing trap to run `save_core()`. Allow for scripts to append actions that will run on exit by introducing an array that will be iterated over by a single exit runner. Closes: #1799 Approved by: cgwalters
* tests/test-gpg-signed-commit: Test more key statesDan Nicholson2019-06-191-0/+33
| | | | | | | | | | | | | Extend test-gpg-signed-commit.sh to test various key states. If gpg is found that supports the required options, keys will be generated on the fly and changed in various ways to exercise the output from `ostree_gpg_verify_result_describe_variant` used in `ostree show`. I tested this using gnupg 2.2.12, so I hope it works well enough on various gpgs found in the wild. Closes: #1872 Approved by: cgwalters
* tests/libtest: Allow specifying GPG homedir to cleanupDan Nicholson2019-06-191-1/+2
| | | | | | | | In case the tests want to use a custom GPG homedir, allow passing in the homedir to use when cleaning up a running gpg-agent. Closes: #1872 Approved by: cgwalters
* lib/deploy: Don't include version twice in bootmenu titleJonathan Lebon2019-03-091-2/+1
| | | | | | | | | | | | | | | In Silverblue right now, the boot menu title looks like this: Fedora 29.20190301.0 (Workstation Edition) 29.20190301.0 (ostree) This is because RPM-OSTree's `mutate-os-release` feature is enabled, which injects the OSTree version string directly into `VERSION` and `PRETTY_NAME`. So appending the version string again is a bit redundant. Let's just do a simple substring check here before adding the version to the title. Closes: #1829 Approved by: cgwalters
* Add sysroot.bootloader repo config keyRobert Fairley2019-03-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The sysroot.bootloader key configures the bootloader that OSTree uses when deploying a sysroot. Having this key allows specifying behavior not to use the default bootloader backend code, which is preferable when creating a first deployment from the sysroot (#1774). As of now, the key can take the values "auto" or "none". If the key is not given, the value defaults to "auto". "auto" causes _ostree_sysroot_query_bootloader() to be used when writing a new deployment, which is the original behavior that dynamically detects which bootloader to use. "none" avoids querying the bootloader dynamically. The BLS config fragments are still written to sysroot/boot/loader/entries for use by higher-level software. More values can be supported in future to specify a single bootloader, different behavior for the bootloader code, or a list of bootloaders to try. Resolves: #1774 Closes: #1814 Approved by: jlebon
* tests: Move assert_fail function to tests/libtest.shRobert Fairley2018-07-051-0/+9
| | | | | | | | | This moves the assert_fail function definition which was defined and called in tests/test-remote-headers.sh. Done in preparation for use of the assert_fail function in other test files. Closes: #1669 Approved by: jlebon
* tests: Save corefiles back to tests/ directory if one existsWilliam Manley2018-06-281-0/+8
| | | | | | | Makes it easier to debug failures from the tests. Closes: #1657 Approved by: cgwalters
* lib/deploy: Also compare deployment csum versionsJonathan Lebon2018-04-241-1/+1
| | | | | | | | | | | | | When comparing deployments to determine whether we need a new bootversion, we should also check whether the commit "version" metadata is the same. Otherwise, we may end up with the a bootconfig whose `title` includes a version that doesn't match the one from the deployment checksum. Closes: https://github.com/projectatomic/rpm-ostree/issues/1343 Closes: #1556 Approved by: cgwalters
* lib/fetcher: Allow clients to append to User-AgentJonathan Lebon2018-03-161-5/+4
| | | | | | | | | We do already have `http-headers`, which potentially could be used to allow clients to completely override the field, but it seems like the more common use case is simply to append. Closes: #1496 Approved by: cgwalters
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* tests: Add a "pull-test2" that uses slightly more realistic contentColin Walters2017-11-011-0/+46
| | | | | | | | | | | | | | This one actually exercises the delta paths more; I pulled the data from some local F26AH builds. One thing I noticed while doing that is that we try bsdiff on xz'd data, but that won't be useful. https://github.com/projectatomic/rpm-ostree/issues/470 https://bugzilla.redhat.com/show_bug.cgi?id=1367496 Anyways I verified this test fails without the fixup for `pread()` in https://github.com/ostreedev/ostree/pull/1312 Closes: #1314 Approved by: jlebon
* lib/pull: Delete unused "exampleos" codeColin Walters2017-11-011-100/+0
| | | | | | | | We never ended up using this, and I'm going to revisit this in another patch with a different approach that has useful *content* and not just a lot of files. Closes: #1314 Approved by: jlebon
* tests: check for relabeling rather than overlayJonathan Lebon2017-09-301-29/+49
| | | | | | | | | | | | | | | | | Instead of checking for overlayfs, let's explicitly check for our ability to relabel files since we now have a `libtest` function to do this. Also port that logic to `libostreetest`. Note that overlayfs *does* allow manipulating user xattrs. So ideally, we should break down `OSTREE_NO_XATTRS` further to distinguish between tests that use bare repos from other modes. We check the current directory instead of `/` so that developers can just point `TEST_TMPDIR` to a non-overlayfs mount point when hacking from a container. Closes: #1170 Approved by: cgwalters
* tests/libtest.sh: always nuke repo and filesJonathan Lebon2017-09-301-0/+2
| | | | | | | This allows users to easily re-initialize the test repo. Closes: #1170 Approved by: cgwalters
* create-usb: Add a create-usb command to complement OstreeRepoFinderMountPhilip Withnall2017-09-271-0/+6
| | | | | | | | | | This can be used to put OSTree repositories on USB sticks in a format recognised by OstreeRepoFinderMount. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1182 Approved by: cgwalters
* tests,ci: Move "test-basic" (bare mode) to installed testColin Walters2017-09-271-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Our CI uses default Docker, which has SELinux labeling but is rather evil in returning `EOPNOTSUPP` to any attempts to set `security.selinux`, even if to the same value. The previous fire 🔥 for this was: https://github.com/ostreedev/ostree/pull/759 The `bare` repo mode really only makes sense as uid 0, so our installed test framework is a good match for this. However, the unit tests *do* work in a privileged container even as non-root, and *also* should work on SELinux-disabled systems. So let's teach the test framework how to skip in those situations. I tested this both in a priv container (my default builder) and an unpriv container (like our CI). At the same time, start executing the `test-basic.sh` from an installed test, so we get better coverage than before. This is just the start - all of the sysroot tests really need the same treatment. Closes: #1217 Approved by: jlebon
* tests/libtest: check that we have setfattrJonathan Lebon2017-09-211-0/+3
| | | | | | | | | | We use `setfattr` to determine whether the filesystem we're on supports xattrs, but we need to check that `setfattr` itself is available. We just make it a hard requirement but only if trying to run tests that ask about xattr support. Closes: #1207 Approved by: cgwalters
* lib/repo: Don't syncfs or fsync() dirs if fsync opt is disabledColin Walters2017-09-211-0/+23
| | | | | | | | | | | | | | There are use cases for not syncing at all; think build cache repos, etc. Let's be consistent here and make sure if fsync is disabled we do no sync at all. I chose this opportunity to add tests using the shiny new strace fault injection. I can forsee using this for a lot more things, so I made the support for detecting things generic. Related: https://github.com/ostreedev/ostree/issues/1184 Closes: #1186 Approved by: jlebon
* tests/libtest: Factor out user xattr detectionColin Walters2017-09-211-4/+16
| | | | | | | | | | Make the equivalent of a `GOnce` or Rust `lazy_static!` detecting this and share it between the two callers. Prep for a future similar patch for strace fault injection. Closes: #1186 Approved by: jlebon
* tests: Reset umask to 022 while creating test repositorySimon McVittie2017-09-191-0/+3
| | | | | | | | | | | | | | | | | | | | | In test-basic-root.sh we make assertions about the permissions of files like baz/cow, which were created without an explicit chmod. We can't do that unless we control the permissions. For some reason the "debomatic" autobuilder used to do some Debian archive rebuilds does the entire build including build-time tests as uid 0 with umask 002, which broke those assertions. This seems a weird thing to do, and I've opened a bug, but it also seems reasonable to fix this test. This also lets us remove a couple of existing workarounds for the same issue. Bug-Debian: https://bugs.debian.org/876138 Signed-off-by: Simon McVittie <smcv@collabora.com> Closes: #1192 Approved by: cgwalters
* libtest: Allow skipping single checks without user xattrsSimon McVittie2017-08-291-0/+11
| | | | | | | Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #1120 Approved by: cgwalters
* lib/pull: Add support for timestamp-check option, use in upgraderColin Walters2017-08-211-1/+9
| | | | | | | | | | | | For both flatpak and ostree-as-host, we really want to verify up front during pulls that we're not being downgraded. Currently both flatpak and `OstreeSysrootUpgrader` do this before deployments, but at that point we've already downloaded all the data, which is annoying. Closes: https://github.com/ostreedev/ostree/issues/687 Closes: #1055 Approved by: jlebon
* lib/deploy: Add .img to end of initramfs in /usr/lib/modulesColin Walters2017-08-211-9/+11
| | | | | | | | | | | | | | | Follow up to <https://github.com/ostreedev/ostree/pull/1079>; I was working on the rpm-ostree updates for this, and I think it's more consistent if we have `.img` here, since that's a closer match to the "remove $kver" that results in `vmlinuz`. Also just best practice to have file suffix types where they make sense. The astute reader might notice this sneaks in a change where we'd crash if the legacy bootdir didn't have an initramfs...yeah, should probably have test coverage of that. Closes: #1095 Approved by: jlebon
* lib/sysroot: Support /usr/lib/modules/$kver for kernel/initramfsColin Walters2017-08-181-19/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the new Fedora kernel standard layout; it has the advantage of being in `/usr` like `/usr/lib/ostree-boot`, but it's not OSTree specific. Further, I think in practice forcing tree builders to compute the checksum is an annoying stumbling block; since we already switched to e.g. computing checksums always when doing pulls, the cost of doing another checksum for the kernel/initramfs is tiny. The "bootcsum" becomes more of an internal implementation detail. Now, there is a transition; my current thought for this is that rpm-ostree will change to default to injecting into both `/usr/lib/ostree-boot` and `/usr/lib/modules`, and stop doing `/boot`, then maybe next year say we drop the `/usr/lib/ostree-boot` by default. A twist here is that the default Fedora kernel RPM layout (and what's in rpm-ostree today) includes a kernel but *not* an initramfs in `/usr/lib/modules`. If we looked only there, we'd just find the kernel. So we need to look in both, and then special case this - pick the legacy layout if we have `/usr/lib/modules` but not an initramfs. While here, rework the code to have an `OstreeKernelLayout` struct which makes dealing with all of the variables nicer. Closes: #1079 Approved by: jlebon
* lib/sysroot-deploy: Refactor kernel layout parsingColin Walters2017-08-091-14/+25
| | | | | | | | | | | | | I'd like to move the new canonical kernel directory to `/usr/lib/modules/$kver`, as Fedora has done. The `get_kernel_from_tree()` function now abstracts over parsing the data (src vs destination filenames, as well as checksum) in preparation for adding the new case. In preparation for this, let's change the current test suite to use the *current* directory of `/usr/lib/ostree-boot`, and also add coverage of `/boot`. Closes: #1053 Approved by: jlebon
* tests: Fix assert_files_hardlinkedColin Walters2017-06-291-6/+5
| | | | | | | | | | | | | | | It was always succeeding because we were trying to stat the inode number, and failing, and thus getting the empty string for both, which compared as true. Regression from: <https://github.com/ostreedev/ostree/commit/74e3581e> Noticed this while working on <https://github.com/ostreedev/ostree/pull/974> and looking at the test results. Closes: #976 Approved by: jlebon
* tests: Add integration tests for collectionsPhilip Withnall2017-06-261-0/+12
| | | | | | | | | | | Test various pieces of core and command line utility functionality relating to the newly-introduced concept of collections. Mostly focussed around the find-remotes utility, and around handling of collection–refs. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
* lib/repo: Support hardlink conversions from bare-user to bu-onlyColin Walters2017-06-131-7/+23
| | | | | | | | | | | | | | | Thinking about the problem of flatpak converting from `bare-user` to `bare-user-only` "in place" by creating a new repo and doing a `pull-local`, I realized that we can optimize this process by doing hardlinks for both metadata and regular files. The repo formats are *almost* compatible, the exception being symlinks. An earlier patch caused us to do hardlinks for metadata, this patch takes things to the next step and special cases this specific conversion. In this case we need to parse the source object to determine whether or not it's a symlink. Closes: #922 Approved by: alexlarsson