summaryrefslogtreecommitdiff
path: root/test/librechroot-test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/librechroot-test.sh')
-rw-r--r--test/librechroot-test.sh79
1 files changed, 60 insertions, 19 deletions
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
index 76afb56..c22ac58 100644
--- a/test/librechroot-test.sh
+++ b/test/librechroot-test.sh
@@ -4,55 +4,96 @@ describe librechroot
. ./test-common.sh
+_setup_chrootdir
+
before() {
_before librechroot
+
mkdir -p "$XDG_CONFIG_HOME"/libretools
- echo "CHROOTDIR='$tmpdir/chrootdir'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf
+
+ echo "CHROOTDIR='${chrootdir}'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf
echo "CHROOT='default'" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
}
-after() {
+after() (
_after_sudo
-}
+)
it_creates_repo_for_new_chroots() {
require network sudo || return 0
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
- testsudo librechroot run test -r /repo/repo.db
+ testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db
}
it_cleans_the_local_repo_correctly() {
require network sudo || return 0
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
- testsudo librechroot make
- testsudo librechroot clean-repo
- testsudo librechroot run test -r /repo/repo.db
+ testsudo librechroot -l "$roundup_test_name" make
+ testsudo librechroot -l "$roundup_test_name" clean-repo
+ testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db
# TODO: inspect /repo/* more
}
+it_respects_exit_status_if_out_isnt_a_tty() (
+ require network sudo || return 0
+ set -o pipefail
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+ r=0
+ { testsudo librechroot -l "$roundup_test_name" run exit 3 | cat; } || r=$?
+ [[ $r == 3 ]]
+)
+
+it_creates_ca_certificates() {
+ require network sudo || return 0
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+ testsudo librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt
+}
+
+it_disables_networking_when_requested() {
+ require network sudo || return 0
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+
+ testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabolagnulinux.org/ >/dev/null
+ not testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null
+}
+
+it_handles_CHROOTEXTRAPKG_correctly() {
+ requuire network sudo || return 0
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+
+ not testsudo librechroot -l "$roundup_test_name" run lsof
+ echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ testsudo librechroot -l "$roundup_test_name" install-name lsof
+ testsudo librechroot -l "$roundup_test_name" clean-pkgs
+ testsudo librechroot -l "$roundup_test_name" run lsof
+ echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ testsudo librechroot -l "$roundup_test_name" clean-pkgs
+ not testsudo librechroot -l "$roundup_test_name" run lsof
+}
+
it_displays_help_as_normal_user() {
rm -rf "$XDG_CONFIG_HOME"
- LANG=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr
+ LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr
[[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
- [[ -z "$(cat $tmpdir/stderr)" ]]
+ empty $tmpdir/stderr
}
it_otherwise_fails_as_normal_user() {
- librechroot run true >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+ librechroot -l "$roundup_test_name" run true >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]
- [[ -z "$(cat $tmpdir/stdout)" ]]
- [[ -n "$(cat $tmpdir/stderr)" ]]
+ empty $tmpdir/stdout
+ not empty $tmpdir/stderr
}
it_displays_help_and_fails_with_0_args() {
- LANG=C librechroot >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+ LC_ALL=C librechroot -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]
- [[ -z "$(cat $tmpdir/stdout)" ]]
- [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]]
+ empty $tmpdir/stdout
+ [[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]]
}
# requires sudo so we know it's not failing because it needs root
@@ -61,8 +102,8 @@ it_fails_for_unknown_commands() {
testsudo librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]
- [[ -z "$(cat $tmpdir/stdout)" ]]
- [[ -n "$(cat $tmpdir/stderr)" ]]
+ empty $tmpdir/stdout
+ not empty $tmpdir/stderr
}
# requires sudo so we know it's not failing because it needs root
@@ -71,6 +112,6 @@ it_fails_for_unknown_flags() {
testsudo librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]
- [[ -z "$(cat $tmpdir/stdout)" ]]
- [[ -n "$(cat $tmpdir/stderr)" ]]
+ empty $tmpdir/stdout
+ not empty $tmpdir/stderr
}