From b93180a4d3d95f557826fe613a9ffa16012ebb4a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 11 Mar 2020 20:00:14 +0000 Subject: [PATCH] =?UTF-8?q?tests:=20Rework=20tests/installed=20=E2=86=92?= =?UTF-8?q?=20tests/kola?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we made an effort to use the [Fedora Standard Test Interface](https://docs.fedoraproject.org/en-US/ci/standard-test-interface/). This effort was not very successful; the primary thing that it really died on is Ansible just didn't support rebooting very well. I think that's since gotten better, but even then, Ansible wasn't the best thing for a test framework for us anyways. In the meantime Fedora CoreOS happened emphasizing Ignition and not "post-hoc reconciliation" models like Ansible over ssh. And, [coreos-assembler](https://github.com/coreos/coreos-assembler) happened too. Furthermore, we really need to test OSTree's interaction with Ignition as we've invented several special things there. Then most recently, I've been working on having cosa/kola support running externally defined tests: https://github.com/coreos/coreos-assembler/pull/1215 There's a lot of things to clean up after this but at least this works for me: ``` $ cd /srv/fcos $ cosa kola run -- --parallel 4 --output-dir tmp/kola -E ~/src/github/ostreedev/ostree/ 'ext.ostree.*' ``` NOTE: This *does not* drop ostree binaries into the target. See: https://github.com/coreos/coreos-assembler/pull/1252#issuecomment-600623315 This drops our dependency on Python in the installed tests, and also fixes a few bugs that came up. I disabled the `itest-bare-user-root.sh` one because it's entangled with the shell script infrastructure for the unit tests. --- tests/installed/README.md | 15 -- tests/installed/destructive-ansible.yml | 16 -- tests/installed/destructive-unit.yml | 42 ----- tests/installed/destructive/README.md | 5 - tests/installed/destructive/var-mount.yml | 13 -- tests/installed/execute_batch.yml | 23 --- tests/installed/libinsttest.sh | 101 ------------ tests/installed/nondestructive.yml | 41 ----- .../installed/nondestructive/libtest-core.sh | 1 - tests/installed/playbook-run.sh | 41 ----- tests/installed/provision.sh | 8 - tests/installed/run.sh | 12 -- .../tasks/disable-all-rpmmd-repos.yml | 5 - tests/installed/tasks/install-git.yml | 23 --- tests/installed/tasks/overlay-git.yml | 23 --- tests/installed/tasks/query-host.yml | 6 - tests/installed/tasks/reboot.yml | 72 -------- tests/kola/README.md | 1 + tests/kola/destructive/data | 1 + .../destructive/itest-bare-root.sh | 5 +- .../destructive/itest-deploy-selinux.sh | 9 +- .../destructive/itest-label-selinux.sh | 3 +- .../destructive/staged-deploy.sh} | 91 ++++++----- tests/kola/destructive/var-mount.sh | 23 +++ tests/kola/libinsttest.sh | 91 +++++++++++ tests/kola/libtest-core.sh | 153 +++++++++++++++++ tests/kola/nondestructive/data | 1 + .../nondestructive/itest-bare-unit.sh | 5 +- .../nondestructive/itest-bare-user-root.sh | 3 +- .../itest-bareuser-nouserxattrs.sh | 3 +- .../nondestructive/itest-payload-link.sh | 3 +- .../nondestructive/itest-pull-space.sh | 10 +- .../nondestructive/itest-pull.sh | 3 +- .../nondestructive/itest-remotes.sh | 3 +- .../nondestructive}/libtest-core.sh | 0 tests/libtest-core.sh | 154 +----------------- 36 files changed, 336 insertions(+), 673 deletions(-) delete mode 100644 tests/installed/README.md delete mode 100644 tests/installed/destructive-ansible.yml delete mode 100644 tests/installed/destructive-unit.yml delete mode 100644 tests/installed/destructive/README.md delete mode 100644 tests/installed/destructive/var-mount.yml delete mode 100644 tests/installed/execute_batch.yml delete mode 100644 tests/installed/libinsttest.sh delete mode 100644 tests/installed/nondestructive.yml delete mode 120000 tests/installed/nondestructive/libtest-core.sh delete mode 100755 tests/installed/playbook-run.sh delete mode 100755 tests/installed/provision.sh delete mode 100755 tests/installed/run.sh delete mode 100644 tests/installed/tasks/disable-all-rpmmd-repos.yml delete mode 100644 tests/installed/tasks/install-git.yml delete mode 100644 tests/installed/tasks/overlay-git.yml delete mode 100644 tests/installed/tasks/query-host.yml delete mode 100644 tests/installed/tasks/reboot.yml create mode 100644 tests/kola/README.md create mode 120000 tests/kola/destructive/data rename tests/{installed => kola}/destructive/itest-bare-root.sh (95%) rename tests/{installed => kola}/destructive/itest-deploy-selinux.sh (91%) rename tests/{installed => kola}/destructive/itest-label-selinux.sh (98%) rename tests/{installed/destructive/staged-deploy.yml => kola/destructive/staged-deploy.sh} (65%) mode change 100644 => 100755 create mode 100755 tests/kola/destructive/var-mount.sh create mode 100644 tests/kola/libinsttest.sh create mode 100644 tests/kola/libtest-core.sh create mode 120000 tests/kola/nondestructive/data rename tests/{installed => kola}/nondestructive/itest-bare-unit.sh (92%) mode change 100755 => 100644 rename tests/{installed => kola}/nondestructive/itest-bare-user-root.sh (97%) rename tests/{installed => kola}/nondestructive/itest-bareuser-nouserxattrs.sh (92%) rename tests/{installed => kola}/nondestructive/itest-payload-link.sh (99%) rename tests/{installed => kola}/nondestructive/itest-pull-space.sh (92%) rename tests/{installed => kola}/nondestructive/itest-pull.sh (98%) rename tests/{installed => kola}/nondestructive/itest-remotes.sh (85%) rename tests/{installed => kola/nondestructive}/libtest-core.sh (100%) mode change 100644 => 120000 tests/libtest-core.sh diff --git a/tests/installed/README.md b/tests/installed/README.md deleted file mode 100644 index b3d14a74..00000000 --- a/tests/installed/README.md +++ /dev/null @@ -1,15 +0,0 @@ -This directory holds tests that use the -[Fedora Standard Test Interface](https://fedoraproject.org/wiki/CI/Standard_Test_Interface). - -The high level structure is that we take a qcow2 file, inject -built RPMs into it, and then use Ansible to run tests. - -See `.papr.yml` for canonical usage. - -For local development, you should cache the qcow2 somewhere -stable (outside of this git repo). Also note that `../ci/build-rpms.sh` -does *not* pick up uncommitted changes! Stated more strongly, you -currently need to run `build-rpms.sh` after every change. - -To run just a specific test, use e.g.: -`env TEST_SUBJECTS=/path/to/qcow2 ./playbook-run.sh -e tests=.*pull nondestructive.yml` diff --git a/tests/installed/destructive-ansible.yml b/tests/installed/destructive-ansible.yml deleted file mode 100644 index 50c8fd77..00000000 --- a/tests/installed/destructive-ansible.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Ansible-based tests. ---- -- hosts: localhost - tags: - - atomic - remote_user: root - vars: - use_git_build: True - tests: "." - tasks: - - import_tasks: tasks/disable-all-rpmmd-repos.yml - - import_tasks: tasks/install-git.yml - when: use_git_build - - import_tasks: tasks/query-host.yml - - import_tasks: destructive/staged-deploy.yml - - import_tasks: destructive/var-mount.yml diff --git a/tests/installed/destructive-unit.yml b/tests/installed/destructive-unit.yml deleted file mode 100644 index e70561d4..00000000 --- a/tests/installed/destructive-unit.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This entrypoint right now just runs shell-script based tests -# from destructive/. Note that we `rpm-ostree usroverlay` git -# builds. So it's not supported to reboot in these tests. -# These tests will be run serially, and can e.g. change deployments. ---- -- hosts: localhost - tags: - - atomic - remote_user: root - vars: - use_git_build: True - tests: "." - tasks: - - import_tasks: tasks/query-host.yml - - set_fact: - rpmostree_initial_deployment: "{{ rpmostree_status[\"deployments\"][0] }}" - - import_tasks: tasks/overlay-git.yml - when: use_git_build - # Next copy all of the tests/ directory - - name: Copy test data - synchronize: src=../../ dest=/root/tests/ archive=yes - - - find: - paths: /root/tests/installed/destructive - patterns: "itest-*.sh" - register: all_tests - - set_fact: - selected_tests: "{{ all_tests.files|map(attribute='path') | select('match', tests) | list }}" - - assert: - that: - - "{{ selected_tests|length }} != 0" - - file: path=/root/logs state=directory - - block: - - name: Run destructive tests - shell: "{{ item }} &> /root/logs/$(basename {{ item }}).log" - with_items: - - "{{ selected_tests }}" - always: - - synchronize: - src: /root/logs/ - dest: artifacts/installed-destructive - mode: pull diff --git a/tests/installed/destructive/README.md b/tests/installed/destructive/README.md deleted file mode 100644 index cafe605a..00000000 --- a/tests/installed/destructive/README.md +++ /dev/null @@ -1,5 +0,0 @@ -This suite of tests is run from PAPR. Everything in here is destructive; it's -recommended to only run them in disposable virtual machines. This is done -in `tests/fedora-str/sysinstalled-tests.yml`, which currently uses a single VM -and runs the tests serially. It's likely in the future this will be changed -to do one VM per test. diff --git a/tests/installed/destructive/var-mount.yml b/tests/installed/destructive/var-mount.yml deleted file mode 100644 index 3fe041af..00000000 --- a/tests/installed/destructive/var-mount.yml +++ /dev/null @@ -1,13 +0,0 @@ -# https://github.com/ostreedev/ostree/issues/1667 -- name: Set up /var as a mountpoint - shell: | - set -xeuo pipefail - cp -a /var /sysroot/myvar - touch /sysroot/myvar/somenewfile - echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab -- include_tasks: ../tasks/reboot.yml -- name: Check that /var mountpoint worked - shell: | - set -xeuo pipefail - systemctl status var.mount - test -f /var/somenewfile diff --git a/tests/installed/execute_batch.yml b/tests/installed/execute_batch.yml deleted file mode 100644 index e4a11bb5..00000000 --- a/tests/installed/execute_batch.yml +++ /dev/null @@ -1,23 +0,0 @@ -##################### -# execute_batch.yml -##################### -- name: Begin async command execution - shell: "{{ async_item }} &> {{ logdir }}/{{ async_item|basename }}.log" - # 10 minutes; the PAPR tester generally times out before that - async: 600 - poll: 0 - with_items: "{{ async_commands }}" - loop_control: - loop_var: "async_item" - register: async_results - -- name: Check async command status - async_status: - jid: "{{ async_result_item.ansible_job_id }}" - with_items: "{{ async_results.results }}" - loop_control: - loop_var: "async_result_item" - register: async_poll_results - until: async_poll_results.finished - retries: 500 - retry_pause: 5 diff --git a/tests/installed/libinsttest.sh b/tests/installed/libinsttest.sh deleted file mode 100644 index edf358f2..00000000 --- a/tests/installed/libinsttest.sh +++ /dev/null @@ -1,101 +0,0 @@ -# Common definitions for installed, privileged tests -# -# Copyright (C) 2017 Colin Walters -# -# SPDX-License-Identifier: LGPL-2.0+ -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -dn=$(dirname $0) -. ${dn}/../libtest-core.sh - -# Copy of bits from tap-test -test_tmpdir= -function _tmpdir_cleanup () { - if test -z "${TEST_SKIP_CLEANUP:-}" && - test -n "${test_tmpdir}" && test -f ${test_tmpdir}/.testtmp; then - rm "${test_tmpdir}" -rf - fi -} -prepare_tmpdir() { - local tmpdir=${1:-/tmp} - test_tmpdir=$(mktemp -p ${tmpdir} -d ostree-insttest.XXXXXXXX) - touch ${test_tmpdir}/.testtmp - cd ${test_tmpdir} -} - -if test -x /usr/bin/python3; then - export PYTHON=/usr/bin/python3 - export PYTHONHTTPSERVER=http.server -elif test -x /usr/bin/python; then - export PYTHON=/usr/bin/python - export PYTHONHTTPSERVER=SimpleHTTPServer -else - fatal "no python found" -fi - -# This is copied from flatpak/flatpak/tests/test-webserver.sh -run_tmp_webserver() { - dir=$1 - - test -n ${test_tmpdir} - - cd ${dir} - env PYTHONUNBUFFERED=1 setsid $PYTHON -m $PYTHONHTTPSERVER 0 &>${test_tmpdir}/httpd-output & - cd - - child_pid=$! - - for x in $(seq 60); do - echo "Waiting for web server ($x/60)..." >&2 - # Snapshot the output - cp ${test_tmpdir}/httpd-output{,.tmp} - # If it's non-empty, see whether it matches our regexp - if test -s ${test_tmpdir}/httpd-output.tmp; then # py3's http.server prints the http:// address also - sed -e 's,Serving HTTP on 0.0.0.0 port \([0-9]*\)\( (http://[^)]*)\)\? \.\.\.,\1,' < ${test_tmpdir}/httpd-output.tmp > ${test_tmpdir}/httpd-port - if ! cmp ${test_tmpdir}/httpd-output.tmp ${test_tmpdir}/httpd-port 1>/dev/null; then - # If so, we've successfully extracted the port - break - fi - fi - sleep 1 - done - - if [ ! -f ${test_tmpdir}/httpd-port ]; then - cat ${test_tmpdir}/httpd-output - fatal "can't start up httpd" - fi - - port=$(cat ${test_tmpdir}/httpd-port) - echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address - echo "$child_pid" > ${test_tmpdir}/httpd-pid -} - -# Determine our origin refspec - we'll use this as a test base -rpmostree=$(which rpm-ostree 2>/dev/null) -if test -z "${rpmostree}"; then - skip "no rpm-ostree, at some point point this to raw ostree too" -fi - -# We need to be root -assert_streq $(id -u) 0 - -rpmostree_query_json() { - query=$1 - rpm-ostree status --json | $PYTHON -c 'import json,sys; v=json.load(sys.stdin); print(v'${query}')' -} -host_refspec=$(rpmostree_query_json '["deployments"][0]["origin"]') -host_commit=$(rpmostree_query_json '["deployments"][0]["checksum"]') -host_osname=$(rpmostree_query_json '["deployments"][0]["osname"]') diff --git a/tests/installed/nondestructive.yml b/tests/installed/nondestructive.yml deleted file mode 100644 index dcd0d442..00000000 --- a/tests/installed/nondestructive.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Nondestructive sysinstalled tests, run in parallel. ---- -- hosts: localhost - tags: - - atomic - remote_user: root - vars: - use_git_build: True - tests: "." - # Arbitrary...we want some parallelism - batching_factor: 4 - tasks: - - import_tasks: tasks/query-host.yml - - import_tasks: tasks/overlay-git.yml - when: use_git_build - # Next copy all of the tests/ directory - - name: Copy test data - synchronize: src=../../ dest=/root/tests/ archive=yes - - find: - paths: /root/tests/installed/nondestructive - patterns: "itest-*.sh" - register: all_tests - - set_fact: - selected_tests: "{{ all_tests.files|map(attribute='path') | select('match', tests) | list }}" - - assert: - that: - - "{{ selected_tests|length }} != 0" - - file: path=/root/logs state=directory - - block: - - name: Run nondestructive tests - vars: - logdir: /root/logs - async_commands: "{{ item }}" - include_tasks: execute_batch.yml - with_items: - - "{{ selected_tests | batch('{{ batching_factor }}') | list }}" - always: - - synchronize: - src: /root/logs - dest: artifacts/installed-nondestructive - mode: pull diff --git a/tests/installed/nondestructive/libtest-core.sh b/tests/installed/nondestructive/libtest-core.sh deleted file mode 120000 index d26203e2..00000000 --- a/tests/installed/nondestructive/libtest-core.sh +++ /dev/null @@ -1 +0,0 @@ -../libtest-core.sh \ No newline at end of file diff --git a/tests/installed/playbook-run.sh b/tests/installed/playbook-run.sh deleted file mode 100755 index af906c3d..00000000 --- a/tests/installed/playbook-run.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/bash -# A thin wrapper for ansible-playbook which has a nice check for -# TEST_SUBJECTS being set. -set -xeuo pipefail - -dn=$(cd $(dirname $0) && pwd) -if ! test -d build; then - mkdir -p build - (cd build && ${dn}/../../ci/build-rpm.sh) -else - # XXX: we should invalidate based on `git describe` or something - echo "NOTE: Re-using prebuilt RPMs:" - find build -name '*.rpm' -fi - -# https://fedoraproject.org/wiki/CI/Tests -if test -z "${TEST_SUBJECTS:-}"; then - cat < - /usr/bin/rpm -Fvh /root/x86_64/*.rpm && \ - cd / && rpm2cpio /root/x86_64/ostree-tests-2*.rpm | cpio -div -- command: ostree --version - register: ostree_new_version -- set_fact: - ostree_new_version_yaml: "{{ ostree_new_version.stdout | from_yaml }}" -- name: "Fail if we didn't change the ostree version" - when: ostree_orig_version_yaml['libostree']['Git'] == ostree_new_version_yaml['libostree']['Git'] - fail: - msg: "Failed to change ostree version" diff --git a/tests/installed/tasks/query-host.yml b/tests/installed/tasks/query-host.yml deleted file mode 100644 index d572ae64..00000000 --- a/tests/installed/tasks/query-host.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Load status json - command: rpm-ostree status --json - changed_when: False - register: rpmostree_status_json -- set_fact: - rpmostree_status: "{{ rpmostree_status_json.stdout | from_json }}" diff --git a/tests/installed/tasks/reboot.yml b/tests/installed/tasks/reboot.yml deleted file mode 100644 index a5d0cbec..00000000 --- a/tests/installed/tasks/reboot.yml +++ /dev/null @@ -1,72 +0,0 @@ -# This file is copied from atomic-host-tests - -# vim: set ft=ansible: -# There is no clean way to restart hosts in ansible. The general issue is that -# the shutdown command may close sshd before ansible has time to "return" from -# the task, even with async & poll. This is due to the fact that asynchronous -# tasks still require a small synchronous bootstrapping script which takes 1 sec -# to complete, during which it is vulnerable to erroring out if sshd dies. -# To mitigate this, we prefix a sleep command before the shutdown so -# ansible has time to move on. For more info on this issue, see: -# https://github.com/ansible/ansible/issues/10616 -# -# The Ansible docs now recommend this combination of tasks to handle reboots -# https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back - -# remember the real ansible_host for following local actions -# (otherwise ansible will target the localhost) -- set_fact: - real_ansible_host: "{{ ansible_host }}" - timeout: "{{ cli_reboot_timeout | default('120') }}" - -# Have to account for both because Fedora STR uses the old version of these -# inventory values for some reason. -- when: ansible_port is defined - set_fact: - real_ansible_port: "{{ ansible_port }}" - -- when: ansible_ssh_port is defined - set_fact: - real_ansible_port: "{{ ansible_ssh_port }}" - -- name: Get original bootid - command: cat /proc/sys/kernel/random/boot_id - register: orig_bootid - -# Stop sshd (thus preventing new connections) and kill our current user's -# connection so that we can't race to get back in to the system while it's -# shutting down -- name: restart hosts - when: (not skip_shutdown is defined) or (not skip_shutdown) - shell: | - systemctl stop sshd - systemd-run --on-active=5 systemctl reboot - async: 1 - poll: 0 - ignore_errors: true - -# NB: The wait_for is executed locally and doesn't require privs, so avoid sudo -- debug: - msg: "Waiting for reboot: {{ ansible_date_time.iso8601 }}" -- wait_for_connection: - delay: 5 - timeout: 120 - search_regex: "OpenSSH" -- debug: - msg: "SSH port is up {{ ansible_date_time.iso8601 }}" - -- name: Assert that the bootid changed - command: cat /proc/sys/kernel/random/boot_id - register: new_bootid - until: new_bootid.stdout != orig_bootid.stdout -- assert: - that: - - new_bootid.stdout != orig_bootid.stdout - -# provide an empty iterator when a list is not provided -# http://docs.ansible.com/ansible/playbooks_conditionals.html#loops-and-conditionals -- name: check services have started - service: - name: "{{ item }}" - state: started - with_items: "{{ wait_for_services|default([]) }}" diff --git a/tests/kola/README.md b/tests/kola/README.md new file mode 100644 index 00000000..19cd5528 --- /dev/null +++ b/tests/kola/README.md @@ -0,0 +1 @@ +This uses https://github.com/coreos/coreos-assembler/pull/1252 diff --git a/tests/kola/destructive/data b/tests/kola/destructive/data new file mode 120000 index 00000000..a96aa0ea --- /dev/null +++ b/tests/kola/destructive/data @@ -0,0 +1 @@ +.. \ No newline at end of file diff --git a/tests/installed/destructive/itest-bare-root.sh b/tests/kola/destructive/itest-bare-root.sh similarity index 95% rename from tests/installed/destructive/itest-bare-root.sh rename to tests/kola/destructive/itest-bare-root.sh index 055d873c..2834a829 100755 --- a/tests/installed/destructive/itest-bare-root.sh +++ b/tests/kola/destructive/itest-bare-root.sh @@ -4,12 +4,13 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh echo "1..2" date +require_writable_sysroot + cd /ostree/repo/tmp rm co -rf rm co-testref -rf diff --git a/tests/installed/destructive/itest-deploy-selinux.sh b/tests/kola/destructive/itest-deploy-selinux.sh similarity index 91% rename from tests/installed/destructive/itest-deploy-selinux.sh rename to tests/kola/destructive/itest-deploy-selinux.sh index 92f6993c..099b5c27 100755 --- a/tests/installed/destructive/itest-deploy-selinux.sh +++ b/tests/kola/destructive/itest-deploy-selinux.sh @@ -4,8 +4,9 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh + +require_writable_sysroot date # Create a new deployment @@ -35,8 +36,8 @@ ostree admin undeploy 0 cd /ostree/repo/tmp ostree checkout --fsync=0 -H ${host_commit} test-label -rm test-label/usr/lib/ostree-boot/vmlinuz* -rm test-label/usr/lib/ostree-boot/initramfs* +rm -vf test-label/usr/lib/ostree-boot/vmlinuz* +rm -vf test-label/usr/lib/ostree-boot/initramfs* cd test-label/usr/lib/modules/* rm initramfs.img echo new initramfs > initramfs.img diff --git a/tests/installed/destructive/itest-label-selinux.sh b/tests/kola/destructive/itest-label-selinux.sh similarity index 98% rename from tests/installed/destructive/itest-label-selinux.sh rename to tests/kola/destructive/itest-label-selinux.sh index 2a492858..87fb26f0 100755 --- a/tests/installed/destructive/itest-label-selinux.sh +++ b/tests/kola/destructive/itest-label-selinux.sh @@ -4,8 +4,7 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh date cd /ostree/repo/tmp diff --git a/tests/installed/destructive/staged-deploy.yml b/tests/kola/destructive/staged-deploy.sh old mode 100644 new mode 100755 similarity index 65% rename from tests/installed/destructive/staged-deploy.yml rename to tests/kola/destructive/staged-deploy.sh index cfd9165b..47d7c9af --- a/tests/installed/destructive/staged-deploy.yml +++ b/tests/kola/destructive/staged-deploy.sh @@ -1,14 +1,21 @@ -# Test the deploy --stage functionality; first, we stage a deployment -# reboot, and validate that it worked. +#!/bin/bash +set -xeuo pipefail -# for now, until the preset propagates down -- name: Start up path unit - shell: | - set -xeuo pipefail +. ${KOLA_EXT_DATA}/libinsttest.sh + +require_writable_sysroot +prepare_tmpdir + +n=$(nth_boot) +case "${n}" in + 1) + commit=${host_commit} + # Test the deploy --stage functionality; first, we stage a deployment + # reboot, and validate that it worked. + # for now, until the preset propagates down + # Start up path unit systemctl enable --now ostree-finalize-staged.path -- name: Write staged-deploy commit - shell: | - set -xeuo pipefail + # Write staged-deploy commit export OSTREE_SYSROOT_DEBUG="test-staged-path" cd /ostree/repo/tmp # https://github.com/ostreedev/ostree/issues/1569 @@ -20,10 +27,7 @@ systemctl show -p ActiveState ostree-finalize-staged.service | grep -q inactive systemctl show -p TriggeredBy ostree-finalize-staged.service | grep -q path ostree admin deploy --stage staged-deploy | tee out.txt - if ! grep -q 'test-staged-path: Not running' out.txt; then - cat out.txt - exit 1 - fi + assert_file_has_content out.txt 'test-staged-path: Not running' systemctl show -p SubState ostree-finalize-staged.path | grep running systemctl show -p ActiveState ostree-finalize-staged.service | grep active new_mtime=$(stat -c '%.Y' /sysroot/ostree/deploy) @@ -37,24 +41,22 @@ test -f deployment-ref-found rm deployment-ref-found if ostree admin pin 0 2>err.txt; then - echo "Pinned staged deployment"; exit 1 + fatal "Pinned staged deployment" fi - grep -qFe 'Cannot pin staged deployment' err.txt - environment: - commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}" -- include_tasks: ../tasks/reboot.yml -- name: Check that deploy-staged service worked - shell: | - set -xeuo pipefail + assert_file_has_content err.txt 'Cannot pin staged deployment' + kola_reboot + ;; + 2) + # Check that deploy-staged service worked rpm-ostree status # Assert that the previous boot had a journal entry for it - journalctl -b "-1" -u ostree-finalize-staged.service | grep -q -e 'Transaction complete' + journalctl -b "-1" -u ostree-finalize-staged.service > svc.txt + assert_file_has_content svc.txt 'Bootloader updated; bootconfig swap: yes; deployment count change: 1' + rm -f svc.txt # And there should not be a staged deployment test '!' -f /run/ostree/staged-deployment -- name: Upgrade with staging - shell: | - set -xeuo pipefail + # Upgrade with staging test '!' -f /run/ostree/staged-deployment ostree admin deploy --stage staged-deploy test -f /run/ostree/staged-deployment @@ -67,27 +69,25 @@ test -f /run/ostree/staged-deployment # Debating bouncing back out to Ansible for this firstdeploycommit=$(rpm-ostree status |grep 'Commit:' |head -1|sed -e 's,^ *Commit: *,,') - test "${firstdeploycommit}" = "${newcommit}" + assert_streq "${firstdeploycommit}" "${newcommit}" # Cleanup rpm-ostree cleanup -rp -- import_tasks: ../tasks/query-host.yml + echo "ok upgrade with staging" -# Ensure we can unstage -- name: Write staged-deploy commit, then unstage - shell: | - set -xeuo pipefail + # Ensure we can unstage + # Write staged-deploy commit, then unstage ostree admin deploy --stage staged-deploy ostree admin status > status.txt - grep -qFe '(staged)' status.txt + assert_file_has_content_literal status.txt '(staged)' test -f /run/ostree/staged-deployment ostree admin undeploy 0 ostree admin status > status.txt grep -vqFe '(staged)' status.txt test '!' -f /run/ostree/staged-deployment + echo "ok unstage" -- name: Staged should be overwritten by non-staged as first - shell: | - set -xeuo pipefail + # Staged should be overwritten by non-staged as first + commit=$(rpmostree_query_json '.deployments[0].checksum') ostree admin deploy --stage staged-deploy test -f /run/ostree/staged-deployment ostree --repo=/ostree/repo refs --create nonstaged-deploy "${commit}" @@ -96,22 +96,23 @@ grep -vqFe '(staged)' status.txt test '!' -f /run/ostree/staged-deployment ostree admin undeploy 0 - environment: - commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}" + echo "ok staged overwritten by non-staged" -- name: Staged is retained when pushing rollback - shell: | - set -xeuo pipefail + # Staged is retained when pushing rollback + commit=$(rpmostree_query_json '.deployments[0].checksum') ostree admin deploy --stage staged-deploy test -f /run/ostree/staged-deployment ostree admin deploy --retain-pending --not-as-default nonstaged-deploy test -f /run/ostree/staged-deployment ostree admin status > status.txt - grep -qFe '(staged)' status.txt + assert_file_has_content_literal status.txt '(staged)' ostree admin undeploy 0 ostree admin undeploy 1 - environment: - commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}" + echo "ok staged retained" -- name: Cleanup refs - shell: ostree refs --delete staged-deploy nonstaged-deploy + # Cleanup refs + ostree refs --delete staged-deploy nonstaged-deploy + echo "ok cleanup refs" + ;; + *) fatal "Unexpected boot count" ;; +esac diff --git a/tests/kola/destructive/var-mount.sh b/tests/kola/destructive/var-mount.sh new file mode 100755 index 00000000..b3fe3d98 --- /dev/null +++ b/tests/kola/destructive/var-mount.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# https://github.com/ostreedev/ostree/issues/1667 +set -xeuo pipefail + +. ${KOLA_EXT_DATA}/libinsttest.sh + +n=$(nth_boot) +case "${n}" in + 1) + require_writable_sysroot + # Hack this off for now + chattr -i /sysroot + cp -a /var /sysroot/myvar + touch /sysroot/myvar/somenewfile + echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab + kola_reboot + ;; + 2) + systemctl status var.mount + test -f /var/somenewfile + ;; + *) fatal "Unexpected boot count $n" +esac diff --git a/tests/kola/libinsttest.sh b/tests/kola/libinsttest.sh new file mode 100644 index 00000000..2552cf78 --- /dev/null +++ b/tests/kola/libinsttest.sh @@ -0,0 +1,91 @@ +# Common definitions for installed, privileged tests +# +# Copyright (C) 2017 Colin Walters +# +# SPDX-License-Identifier: LGPL-2.0+ +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +. ${KOLA_EXT_DATA}/libtest-core.sh + +# Copy of bits from tap-test +test_tmpdir= +function _tmpdir_cleanup () { + if test -z "${TEST_SKIP_CLEANUP:-}" && + test -n "${test_tmpdir}" && test -f ${test_tmpdir}/.testtmp; then + rm "${test_tmpdir}" -rf + fi +} +prepare_tmpdir() { + local tmpdir=${1:-/var/tmp} + test_tmpdir=$(mktemp -p ${tmpdir} -d ostree-insttest.XXXXXXXX) + touch ${test_tmpdir}/.testtmp + cd ${test_tmpdir} +} + +# This is copied from flatpak/flatpak/tests/test-webserver.sh +run_tmp_webserver() { + dir=$1 + + port=8000 + podman create --name ostree-httpd --privileged -ti --net=host -v "${dir}":/srv --workdir /srv \ + registry.svc.ci.openshift.org/coreos/fedora:31 python3 -m http.server "${port}" + podman generate systemd ostree-httpd > /etc/systemd/system/ostree-httpd.service + systemctl daemon-reload + systemctl start ostree-httpd.service + + address="http://127.0.0.1:${port}" + while ! curl --head "${address}" &>/dev/null; do sleep 1; done + echo "${address}" > ${test_tmpdir}/httpd-address +} + +# Yeah this is a hack. Doing this better requires more first class support +# for creating derived commits in ostree potentially. Or barring that, +# just recommend to people to use `unshare -m` or equivalent and +# mount -o remount,rw /sysroot in their code. +require_writable_sysroot() { + if ! test -w /sysroot; then + mount -o remount,rw /sysroot + fi +} + +nth_boot() { + journalctl --list-boots | wc -l +} + +kola_reboot() { + kill -TERM $$ + sleep 2m + echo "failed to reboot?" 1>&2 + exit 1 +} + +# Determine our origin refspec - we'll use this as a test base +rpmostree=$(which rpm-ostree 2>/dev/null) +if test -z "${rpmostree}"; then + skip "no rpm-ostree, at some point point this to raw ostree too" +fi + +# We need to be root +assert_streq $(id -u) 0 + +rpmostree_query_json() { + query=$1 + rpm-ostree status --json | jq -r "${query}" +} +host_refspec=$(rpmostree_query_json '.deployments[0].origin') +host_commit=$(rpmostree_query_json '.deployments[0].checksum') +host_osname=$(rpmostree_query_json '.deployments[0].osname') diff --git a/tests/kola/libtest-core.sh b/tests/kola/libtest-core.sh new file mode 100644 index 00000000..945d2857 --- /dev/null +++ b/tests/kola/libtest-core.sh @@ -0,0 +1,153 @@ +# Core source library for shell script tests; the +# canonical version lives in: +# +# https://github.com/ostreedev/ostree +# +# Known copies are in the following repos: +# +# - https://github.com/projectatomic/rpm-ostree +# +# Copyright (C) 2017 Colin Walters +# +# SPDX-License-Identifier: LGPL-2.0+ +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +fatal() { + echo $@ 1>&2; exit 1 +} +# fatal() is shorter to type, but retain this alias +assert_not_reached () { + fatal "$@" +} + +# Some tests look for specific English strings. Use a UTF-8 version +# of the C (POSIX) locale if we have one, or fall back to en_US.UTF-8 +# (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8) +# +# If we can't find the locale command assume we have support for C.UTF-8 +# (e.g. musl based systems) +if type -p locale >/dev/null; then + export LC_ALL=$(locale -a | grep -iEe '^(C|en_US)\.(UTF-8|utf8)$' | head -n1 || true) + if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi +else + export LC_ALL=C.UTF-8 +fi +# A GNU extension, used whenever LC_ALL is not C +unset LANGUAGE + +# This should really be the default IMO +export G_DEBUG=fatal-warnings + +assert_streq () { + test "$1" = "$2" || fatal "$1 != $2" +} + +assert_str_match () { + if ! echo "$1" | grep -E -q "$2"; then + fatal "$1 does not match regexp $2" + fi +} + +assert_not_streq () { + (! test "$1" = "$2") || fatal "$1 == $2" +} + +assert_has_file () { + test -f "$1" || fatal "Couldn't find '$1'" +} + +assert_has_dir () { + test -d "$1" || fatal "Couldn't find '$1'" +} + +# Dump ls -al + file contents to stderr, then fatal() +_fatal_print_file() { + file="$1" + shift + ls -al "$file" >&2 + sed -e 's/^/# /' < "$file" >&2 + fatal "$@" +} + +assert_not_has_file () { + if test -f "$1"; then + _fatal_print_file "$1" "File '$1' exists" + fi +} + +assert_not_file_has_content () { + fpath=$1 + shift + for re in "$@"; do + if grep -q -e "$re" "$fpath"; then + _fatal_print_file "$fpath" "File '$fpath' matches regexp '$re'" + fi + done +} + +assert_not_has_dir () { + if test -d "$1"; then + fatal "Directory '$1' exists" + fi +} + +assert_file_has_content () { + fpath=$1 + shift + for re in "$@"; do + if ! grep -q -e "$re" "$fpath"; then + _fatal_print_file "$fpath" "File '$fpath' doesn't match regexp '$re'" + fi + done +} + +assert_file_has_content_literal () { + fpath=$1; shift + for s in "$@"; do + if ! grep -q -F -e "$s" "$fpath"; then + _fatal_print_file "$fpath" "File '$fpath' doesn't match fixed string list '$s'" + fi + done +} + +assert_file_has_mode () { + mode=$(stat -c '%a' $1) + if [ "$mode" != "$2" ]; then + fatal "File '$1' has wrong mode: expected $2, but got $mode" + fi +} + +assert_symlink_has_content () { + if ! test -L "$1"; then + fatal "File '$1' is not a symbolic link" + fi + if ! readlink "$1" | grep -q -e "$2"; then + _fatal_print_file "$1" "Symbolic link '$1' doesn't match regexp '$2'" + fi +} + +assert_file_empty() { + if test -s "$1"; then + _fatal_print_file "$1" "File '$1' is not empty" + fi +} + +# Use to skip all of these tests +skip() { + echo "1..0 # SKIP" "$@" + exit 0 +} diff --git a/tests/kola/nondestructive/data b/tests/kola/nondestructive/data new file mode 120000 index 00000000..a96aa0ea --- /dev/null +++ b/tests/kola/nondestructive/data @@ -0,0 +1 @@ +.. \ No newline at end of file diff --git a/tests/installed/nondestructive/itest-bare-unit.sh b/tests/kola/nondestructive/itest-bare-unit.sh old mode 100755 new mode 100644 similarity index 92% rename from tests/installed/nondestructive/itest-bare-unit.sh rename to tests/kola/nondestructive/itest-bare-unit.sh index c973ee7c..d399d78d --- a/tests/installed/nondestructive/itest-bare-unit.sh +++ b/tests/kola/nondestructive/itest-bare-unit.sh @@ -5,8 +5,9 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh + +fatal "FIXME - need to also sync over the installed tests" date # These tests sort of bypass the installed-tests spec; diff --git a/tests/installed/nondestructive/itest-bare-user-root.sh b/tests/kola/nondestructive/itest-bare-user-root.sh similarity index 97% rename from tests/installed/nondestructive/itest-bare-user-root.sh rename to tests/kola/nondestructive/itest-bare-user-root.sh index 9e04f7bc..ad3d2dac 100755 --- a/tests/installed/nondestructive/itest-bare-user-root.sh +++ b/tests/kola/nondestructive/itest-bare-user-root.sh @@ -4,8 +4,7 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh echo "1..1" date diff --git a/tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh b/tests/kola/nondestructive/itest-bareuser-nouserxattrs.sh similarity index 92% rename from tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh rename to tests/kola/nondestructive/itest-bareuser-nouserxattrs.sh index 7063286b..7908d31b 100755 --- a/tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh +++ b/tests/kola/nondestructive/itest-bareuser-nouserxattrs.sh @@ -7,8 +7,7 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh prepare_tmpdir trap _tmpdir_cleanup EXIT diff --git a/tests/installed/nondestructive/itest-payload-link.sh b/tests/kola/nondestructive/itest-payload-link.sh similarity index 99% rename from tests/installed/nondestructive/itest-payload-link.sh rename to tests/kola/nondestructive/itest-payload-link.sh index 6a6a01d3..6cfe291a 100755 --- a/tests/installed/nondestructive/itest-payload-link.sh +++ b/tests/kola/nondestructive/itest-payload-link.sh @@ -21,8 +21,7 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh echo "1..1" date diff --git a/tests/installed/nondestructive/itest-pull-space.sh b/tests/kola/nondestructive/itest-pull-space.sh similarity index 92% rename from tests/installed/nondestructive/itest-pull-space.sh rename to tests/kola/nondestructive/itest-pull-space.sh index e365b86d..97524f67 100755 --- a/tests/installed/nondestructive/itest-pull-space.sh +++ b/tests/kola/nondestructive/itest-pull-space.sh @@ -3,14 +3,10 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh date prepare_tmpdir -trap _tmpdir_cleanup EXIT - -cd ${test_tmpdir} truncate -s 20MB testblk.img blkdev=$(losetup --find --show $(pwd)/testblk.img) mkfs.xfs ${blkdev} @@ -51,9 +47,7 @@ rm -rf mnt/repo ostree --repo=mnt/repo init --mode=bare-user echo 'fsync=false' >> mnt/repo/config echo 'min-free-space-size=10MB' >> mnt/repo/config -if ostree --repo=mnt/repo pull-local --commit-metadata-only /ostree/repo ${host_commit} 2>err.txt; then - fatal "could not write metadata objects even when min-free-space value should allow it" -fi +ostree --repo=mnt/repo pull-local --commit-metadata-only /ostree/repo ${host_commit} echo "ok metadata write even when free space is lower than min-free-space value" rm -rf mnt/repo diff --git a/tests/installed/nondestructive/itest-pull.sh b/tests/kola/nondestructive/itest-pull.sh similarity index 98% rename from tests/installed/nondestructive/itest-pull.sh rename to tests/kola/nondestructive/itest-pull.sh index 07056ea1..770f2444 100755 --- a/tests/installed/nondestructive/itest-pull.sh +++ b/tests/kola/nondestructive/itest-pull.sh @@ -7,8 +7,7 @@ set -xeuo pipefail # FIXME: https://github.com/ostreedev/ostree/pull/1548 exit 0 -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh date prepare_tmpdir /var/tmp diff --git a/tests/installed/nondestructive/itest-remotes.sh b/tests/kola/nondestructive/itest-remotes.sh similarity index 85% rename from tests/installed/nondestructive/itest-remotes.sh rename to tests/kola/nondestructive/itest-remotes.sh index 836e35ad..d1fb455b 100755 --- a/tests/installed/nondestructive/itest-remotes.sh +++ b/tests/kola/nondestructive/itest-remotes.sh @@ -4,8 +4,7 @@ set -xeuo pipefail -dn=$(dirname $0) -. ${dn}/../libinsttest.sh +. ${KOLA_EXT_DATA}/libinsttest.sh date prepare_tmpdir diff --git a/tests/installed/libtest-core.sh b/tests/kola/nondestructive/libtest-core.sh similarity index 100% rename from tests/installed/libtest-core.sh rename to tests/kola/nondestructive/libtest-core.sh diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh deleted file mode 100644 index 945d2857..00000000 --- a/tests/libtest-core.sh +++ /dev/null @@ -1,153 +0,0 @@ -# Core source library for shell script tests; the -# canonical version lives in: -# -# https://github.com/ostreedev/ostree -# -# Known copies are in the following repos: -# -# - https://github.com/projectatomic/rpm-ostree -# -# Copyright (C) 2017 Colin Walters -# -# SPDX-License-Identifier: LGPL-2.0+ -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -fatal() { - echo $@ 1>&2; exit 1 -} -# fatal() is shorter to type, but retain this alias -assert_not_reached () { - fatal "$@" -} - -# Some tests look for specific English strings. Use a UTF-8 version -# of the C (POSIX) locale if we have one, or fall back to en_US.UTF-8 -# (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8) -# -# If we can't find the locale command assume we have support for C.UTF-8 -# (e.g. musl based systems) -if type -p locale >/dev/null; then - export LC_ALL=$(locale -a | grep -iEe '^(C|en_US)\.(UTF-8|utf8)$' | head -n1 || true) - if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi -else - export LC_ALL=C.UTF-8 -fi -# A GNU extension, used whenever LC_ALL is not C -unset LANGUAGE - -# This should really be the default IMO -export G_DEBUG=fatal-warnings - -assert_streq () { - test "$1" = "$2" || fatal "$1 != $2" -} - -assert_str_match () { - if ! echo "$1" | grep -E -q "$2"; then - fatal "$1 does not match regexp $2" - fi -} - -assert_not_streq () { - (! test "$1" = "$2") || fatal "$1 == $2" -} - -assert_has_file () { - test -f "$1" || fatal "Couldn't find '$1'" -} - -assert_has_dir () { - test -d "$1" || fatal "Couldn't find '$1'" -} - -# Dump ls -al + file contents to stderr, then fatal() -_fatal_print_file() { - file="$1" - shift - ls -al "$file" >&2 - sed -e 's/^/# /' < "$file" >&2 - fatal "$@" -} - -assert_not_has_file () { - if test -f "$1"; then - _fatal_print_file "$1" "File '$1' exists" - fi -} - -assert_not_file_has_content () { - fpath=$1 - shift - for re in "$@"; do - if grep -q -e "$re" "$fpath"; then - _fatal_print_file "$fpath" "File '$fpath' matches regexp '$re'" - fi - done -} - -assert_not_has_dir () { - if test -d "$1"; then - fatal "Directory '$1' exists" - fi -} - -assert_file_has_content () { - fpath=$1 - shift - for re in "$@"; do - if ! grep -q -e "$re" "$fpath"; then - _fatal_print_file "$fpath" "File '$fpath' doesn't match regexp '$re'" - fi - done -} - -assert_file_has_content_literal () { - fpath=$1; shift - for s in "$@"; do - if ! grep -q -F -e "$s" "$fpath"; then - _fatal_print_file "$fpath" "File '$fpath' doesn't match fixed string list '$s'" - fi - done -} - -assert_file_has_mode () { - mode=$(stat -c '%a' $1) - if [ "$mode" != "$2" ]; then - fatal "File '$1' has wrong mode: expected $2, but got $mode" - fi -} - -assert_symlink_has_content () { - if ! test -L "$1"; then - fatal "File '$1' is not a symbolic link" - fi - if ! readlink "$1" | grep -q -e "$2"; then - _fatal_print_file "$1" "Symbolic link '$1' doesn't match regexp '$2'" - fi -} - -assert_file_empty() { - if test -s "$1"; then - _fatal_print_file "$1" "File '$1' is not empty" - fi -} - -# Use to skip all of these tests -skip() { - echo "1..0 # SKIP" "$@" - exit 0 -} diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh new file mode 120000 index 00000000..11131fca --- /dev/null +++ b/tests/libtest-core.sh @@ -0,0 +1 @@ +kola/libtest-core.sh \ No newline at end of file