2020-04-09 20:42:52 +03:00
#!/bin/bash
2021-02-12 21:47:36 +03:00
set -xeuo pipefail
2020-04-09 20:42:52 +03:00
2020-05-05 17:28:38 +03:00
. ${ KOLA_EXT_DATA } /libtest.sh
2020-04-09 20:42:52 +03:00
cd $( mktemp -d)
2020-05-05 17:28:38 +03:00
# make sure that package-related entries are always present,
2021-02-19 02:13:04 +03:00
# even when they're empty.
# Validate there's no live state by default.
2020-05-05 17:28:38 +03:00
rpm-ostree status --json > status.json
assert_jq status.json \
'.deployments[0]["packages"]' \
'.deployments[0]["requested-packages"]' \
'.deployments[0]["requested-local-packages"]' \
'.deployments[0]["base-removals"]' \
'.deployments[0]["requested-base-removals"]' \
2021-02-19 02:13:04 +03:00
'.deployments[0]["live-inprogress"]|not' \
'.deployments[0]["live-replaced"]|not' \
2020-05-05 17:28:38 +03:00
'.deployments[0]["layered-commit-meta"]|not'
rm status.json
2021-02-12 21:47:36 +03:00
rpm-ostree testutils validate-parse-status
2020-05-05 17:28:38 +03:00
echo "ok empty pkg arrays, and commit meta correct in status json"
# Ensure we return an error when passing a wrong option.
rpm-ostree --help | awk '/^$/ {in_commands=0} {if(in_commands==1){print $0}} /^Builtin Commands:/ {in_commands=1}' > commands.txt
while read cmd; do
if rpm-ostree ${ cmd } --n0t-3xisting-0ption & >/dev/null; then
assert_not_reached " command ${ cmd } --n0t-3xisting-0ption was successful "
fi
done < commands.txt
echo "ok error on unknown command options"
2020-04-29 20:44:03 +03:00
rpm-ostree status --jsonpath '$.deployments[0].booted' > jsonpath.txt
assert_file_has_content_literal jsonpath.txt 'true'
echo "ok jsonpath"
2020-04-09 20:42:52 +03:00
# Verify operations as non-root
runuser -u core rpm-ostree status
echo "ok status doesn't require root"
# StateRoot is only in --verbose
rpm-ostree status > status.txt
assert_not_file_has_content status.txt StateRoot:
rpm-ostree status -v > status.txt
assert_file_has_content status.txt StateRoot:
echo "ok status text"
# Also check that we can do status as non-root non-active
runuser -u bin rpm-ostree status
echo "ok status doesn't require active PAM session"
rpm-ostree status -b > status.txt
assert_streq $( grep -F -e 'ostree://' status.txt | wc -l) "1"
assert_file_has_content status.txt BootedDeployment:
echo "ok status -b"
2020-04-29 20:44:03 +03:00
if rpm-ostree nosuchcommand --nosuchoption 2>err.txt; then
assert_not_reached "Expected an error for nosuchcommand"
fi
assert_file_has_content err.txt 'Unknown.*command'
echo "ok error on unknown command"
2020-05-05 17:28:38 +03:00
# related: https://github.com/coreos/fedora-coreos-config/issues/194
2021-02-27 22:50:12 +03:00
rpm-ostree testutils moo
2020-05-05 17:28:38 +03:00
echo "ok moo"
2020-04-29 20:44:03 +03:00
# Reload as root https://github.com/projectatomic/rpm-ostree/issues/976
rpm-ostree reload
echo "ok reload"
2020-06-17 19:21:02 +03:00
# See rpmostree-scripts.c
grep ^DEFAULT /etc/crypto-policies/config
echo "ok crypto-policies DEFAULT backend"
2021-01-27 21:57:44 +03:00
ldd /usr/lib64/librpmostree-1.so.1 > rpmostree-lib-deps.txt
assert_not_file_has_content rpmostree-lib-deps.txt libdnf
echo "ok lib deps"