1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 21:45:24 +01:00
Files
atomic/tests/integration/setup-scripts/system_containers_setup.sh
Yu Qi Zhang c9921db260 Refactor system container tests
The old tests (test_system_containers.sh) were disorganized
and lacked coverage for many commands. This refactor attempts
to improve the tests with a focus on clarity and coverage.

Improvements:
  - split into 4 separate tests for clarity and independence
  - section each test to better know where failures happen
  - make use of shared setup functions
  - use ${WORK_DIR} for test files
  - better setup/teardown usage
  - improved coverage for update/rollback, image commands,
    environment variables and expected failures

Drawback:
  - Slower

Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com>

Closes: #983
Approved by: giuseppe
2017-05-03 15:59:16 +00:00

46 lines
936 B
Bash
Executable File

assert_not_reached() {
echo $@ 1>&2
exit 1
}
assert_not_matches() {
if grep -q -e $@; then
sed -e s',^,| ,' < $2
assert_not_reached "Matched: " $@
fi
}
assert_matches() {
if ! grep -q -e $@; then
sed -e s',^,| ,' < $2
assert_not_reached "Failed to match: " $@
fi
}
assert_equal() {
if ! test $1 = $2; then
assert_not_reached "Failed: not equal " $1 $2
fi
}
# Skip the test if:
# 1. OSTree or runc are not installed
# 2. the version of runc is too low
# 3. atomic has not --install --system
ostree --version &>/dev/null || exit 77
runc --version &>/dev/null || exit 77
if runc --version | grep -q "version 0"; then
exit 77
fi
${ATOMIC} install --help 2>&1 > help.out
grep -q -- --system help.out || exit 77
export PYTHON=${PYTHON:-/usr/bin/python}
export ATOMIC_OSTREE_REPO=${WORK_DIR}/repo
export ATOMIC_OSTREE_CHECKOUT_PATH=${WORK_DIR}/checkout
export NAME="test-system-container-$$"