From fa6e7ccf3914081504681679645fd7cfd803cfdd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 18:39:47 -0500 Subject: test/: re-jigger the chroot tests to be fast on btrfs --- test/librechroot-test.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 5ca1b37..442abed 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -4,30 +4,34 @@ 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 } @@ -36,7 +40,7 @@ it_respects_exit_status_if_out_isnt_a_tty() ( set -o pipefail libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty r=0 - { testsudo librechroot run exit 3 | cat; } || r=$? + { testsudo librechroot -l "$roundup_test_name" run exit 3 | cat; } || r=$? [[ $r == 3 ]] ) @@ -49,7 +53,7 @@ it_displays_help_as_normal_user() { } 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 ]] empty $tmpdir/stdout @@ -57,7 +61,7 @@ it_otherwise_fails_as_normal_user() { } it_displays_help_and_fails_with_0_args() { - LC_ALL=C librechroot >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + LC_ALL=C librechroot -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout -- cgit v1.2.3-54-g00ecf From c54c481b5b7a1cb7d4a201fad9450d3abb198742 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 01:11:33 -0500 Subject: fix librechroot test --- test/librechroot-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 442abed..d458cd9 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -65,7 +65,7 @@ it_displays_help_and_fails_with_0_args() { [[ $stat != 0 ]] empty $tmpdir/stdout - [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]] + [[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]] } # requires sudo so we know it's not failing because it needs root -- cgit v1.2.3-54-g00ecf From e0b9e3ab07f64b9cbf575f560a25e5712208b8d7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 12:41:52 -0500 Subject: test/librechroot: test the -N flag --- test/librechroot-test.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index d458cd9..ae5dd4b 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -44,6 +44,14 @@ it_respects_exit_status_if_out_isnt_a_tty() ( [[ $r == 3 ]] ) +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 + ! testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null +} + it_displays_help_as_normal_user() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr -- cgit v1.2.3-54-g00ecf From 1a7621e6e3ca4ad7c132d1b9d4f7d5dc67fc1a32 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 12:46:01 -0500 Subject: test/librechroot: test CHROOTEXTRAPKG --- test/librechroot-test.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index ae5dd4b..f8dd2ba 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -52,6 +52,20 @@ it_disables_networking_when_requested() { ! 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 + + ! 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 + ! testsudo librechroot -l "$roundup_test_name" run lsof +} + it_displays_help_as_normal_user() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr -- cgit v1.2.3-54-g00ecf From e4ccc15cccf46e6265347f4fdee598b0561c4c74 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 20:20:20 -0500 Subject: librechroot-test: check for the existance of ca-certificates.crt --- test/librechroot-test.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index f8dd2ba..3896005 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -44,6 +44,12 @@ it_respects_exit_status_if_out_isnt_a_tty() ( [[ $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 -- cgit v1.2.3-54-g00ecf From 6fb2295a25ee4a24b38f4fce1b652a60cedd1b64 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 22:24:28 -0500 Subject: test: `! true` doesn't trip `set -e`, do subshell magic --- test/aur-test.sh | 2 +- test/is_built-test.sh | 2 +- test/lib-blacklist-test.sh | 10 +++++----- test/lib-messages-test.sh | 4 ++-- test/librechroot-test.sh | 14 +++++++------- test/librelib-test.sh | 4 ++-- test/libremakepkg-test.sh | 12 ++++++------ test/librestage-test.sh | 4 ++-- test/pkgbuild-check-nonfree-test.sh | 10 +++++----- test/test-common.sh | 6 ++++++ 10 files changed, 37 insertions(+), 31 deletions(-) (limited to 'test/librechroot-test.sh') diff --git a/test/aur-test.sh b/test/aur-test.sh index 8bcb5ef..5de590b 100644 --- a/test/aur-test.sh +++ b/test/aur-test.sh @@ -24,7 +24,7 @@ it_fails_with_0_args() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } # TODO: Actually test diff --git a/test/is_built-test.sh b/test/is_built-test.sh index af754dc..f7f6c65 100644 --- a/test/is_built-test.sh +++ b/test/is_built-test.sh @@ -24,7 +24,7 @@ it_fails_with_0_args() { [[ $stat -gt 1 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_succeeds_with_1_arg() { diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh index 640ed77..9dfd5da 100644 --- a/test/lib-blacklist-test.sh +++ b/test/lib-blacklist-test.sh @@ -53,7 +53,7 @@ it_fails_update_with_no_blacklist_or_network() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_cat_with_no_blacklist_or_network() { @@ -64,7 +64,7 @@ it_fails_cat_with_no_blacklist_or_network() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_update_when_BLACKLIST_is_unset() { @@ -75,7 +75,7 @@ it_fails_update_when_BLACKLIST_is_unset() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_cat_when_syntax_error_in_conf() { @@ -87,7 +87,7 @@ it_fails_cat_when_syntax_error_in_conf() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_downloads_the_blacklist_as_needed() { @@ -97,7 +97,7 @@ it_downloads_the_blacklist_as_needed() { libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr - ! empty $tmpdir/stdout + not empty $tmpdir/stdout } it_downloads_the_blacklist_repeatedly() { diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh index fffff36..3fcac63 100644 --- a/test/lib-messages-test.sh +++ b/test/lib-messages-test.sh @@ -31,14 +31,14 @@ it_works_with_no_color_and_set_euE() ( ) >$tmpdir/stdout 2>$tmpdir/stderr empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr ) it_can_be_called_without_including() { libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_with_msg_and_no_args() { diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 3896005..c22ac58 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -54,22 +54,22 @@ 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 - ! testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null + 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 - ! testsudo librechroot -l "$roundup_test_name" run lsof + 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 - ! testsudo librechroot -l "$roundup_test_name" run lsof + not testsudo librechroot -l "$roundup_test_name" run lsof } it_displays_help_as_normal_user() { @@ -85,7 +85,7 @@ it_otherwise_fails_as_normal_user() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_displays_help_and_fails_with_0_args() { @@ -103,7 +103,7 @@ it_fails_for_unknown_commands() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } # requires sudo so we know it's not failing because it needs root @@ -113,5 +113,5 @@ it_fails_for_unknown_flags() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } diff --git a/test/librelib-test.sh b/test/librelib-test.sh index 23c38dc..a74ce0a 100644 --- a/test/librelib-test.sh +++ b/test/librelib-test.sh @@ -26,7 +26,7 @@ it_fails_with_2_args() { librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $ret != 0 ]] } @@ -68,6 +68,6 @@ it_fails_to_find_phony() { librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $ret != 0 ]] } diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 06cf695..811c8ed 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -40,8 +40,8 @@ it_disables_networking_during_build() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - ! testsudo libremakepkg -l "$roundup_test_name" - ! [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] + not testsudo libremakepkg -l "$roundup_test_name" + not [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] testsudo libremakepkg -l "$roundup_test_name" -N [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] } @@ -52,8 +52,8 @@ it_disables_networking_during_package() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - ! testsudo libremakepkg -l "$roundup_test_name" - ! [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] + not testsudo libremakepkg -l "$roundup_test_name" + not [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] testsudo libremakepkg -l "$roundup_test_name" -N [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] } @@ -83,7 +83,7 @@ it_cleans_the_chroot_before_building() { testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'first time, pass' cd "$tmpdir/3" testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } - ! testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' + not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' } it_handles_PKGDEST_not_existing() { @@ -114,5 +114,5 @@ it_otherwise_fails_as_normal_user() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } diff --git a/test/librestage-test.sh b/test/librestage-test.sh index 6728143..460eb58 100644 --- a/test/librestage-test.sh +++ b/test/librestage-test.sh @@ -34,7 +34,7 @@ it_fails_with_0_args() { [[ $stat != 0 ]] empty "$tmpdir/stdout" - ! empty "$tmpdir/stderr" + not empty "$tmpdir/stderr" } it_fails_with_invalid_args() { @@ -42,7 +42,7 @@ it_fails_with_invalid_args() { [[ $stat != 0 ]] empty "$tmpdir/stdout" - ! empty "$tmpdir/stderr" + not empty "$tmpdir/stderr" } # This was an actual bug I hit with md/emacs-mdmua a long time ago; solution was diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh index 6463d64..2af2669 100644 --- a/test/pkgbuild-check-nonfree-test.sh +++ b/test/pkgbuild-check-nonfree-test.sh @@ -39,7 +39,7 @@ it_succeeds_for_free_depends() { $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat == 0 ]] } @@ -47,7 +47,7 @@ it_succeeds_for_nonfree_depend_with_replacement() { $pcn $pcn.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat == 0 ]] } @@ -55,14 +55,14 @@ it_fails_for_nonfree_depend() { $pcn $pcn.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr local pcn_stat=$stat $psn $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_when_there_is_no_blacklist() { @@ -73,6 +73,6 @@ it_fails_when_there_is_no_blacklist() { $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat != 0 ]] && [[ $stat != 15 ]] } diff --git a/test/test-common.sh b/test/test-common.sh index 3df7107..c525dd8 100644 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -70,3 +70,9 @@ empty() ( set +x [[ $(stat -c %s "$1") -eq 0 ]] ) + +# Just using '!' doesn't trip `set -e` +not() ( + set +x + ! eval "$@" +) -- cgit v1.2.3-54-g00ecf From b810795b6689ab9e1635af21a48660305b2a7820 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 10 May 2014 22:48:36 -0400 Subject: test/librechroot: 'exit' isn't an executable program. This test worked before because of work-arounds for systemd bugs, it had invoked bash inside of the chroot. --- test/librechroot-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/librechroot-test.sh') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index c22ac58..43f3143 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -40,7 +40,7 @@ it_respects_exit_status_if_out_isnt_a_tty() ( 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=$? + { testsudo librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || r=$? [[ $r == 3 ]] ) -- cgit v1.2.3-54-g00ecf