diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/arch_is_concerned.sh | 93 | ||||
-rw-r--r-- | tests/common.sh | 15 | ||||
-rw-r--r-- | tests/local.mk | 51 | ||||
-rwxr-xr-x | tests/match_arch.sh | 33 | ||||
-rwxr-xr-x | tests/match_plat.sh | 25 | ||||
-rwxr-xr-x | tests/parse_control.basic.sh | 2 | ||||
-rw-r--r-- | tests/parse_control.common.sh | 20 | ||||
-rwxr-xr-x | tests/plat_is_concerned.sh | 85 | ||||
-rwxr-xr-x | tests/reduce_deps.sh | 66 | ||||
-rwxr-xr-x | tests/resolve_deps.basic.sh | 23 |
10 files changed, 205 insertions, 208 deletions
diff --git a/tests/arch_is_concerned.sh b/tests/arch_is_concerned.sh index 5358b73..c6c1d17 100755 --- a/tests/arch_is_concerned.sh +++ b/tests/arch_is_concerned.sh @@ -20,10 +20,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use archplat - do_test() { local host_arch="${1}" @@ -47,50 +43,45 @@ do_test() fi } -# Architecture: all - -do_test 'amd64-linux-glibc' 'all' false - -do_test 'i686-linux-glibc' 'all' false - -do_test 'all' 'all' true - -# Architecture: any - -do_test 'amd64-linux-glibc' 'any' true - -do_test 'i686-linux-glibc' 'any' true - -do_test 'all' 'any' false - -# Architecture: amd64-linux-glibc - -do_test 'amd64-linux-glibc' 'amd64-linux-glibc' true - -do_test 'i686-linux-glibc' 'amd64-linux-glibc' false - -do_test 'all' 'amd64-linux-glibc' false - -# Architecture: !amd64-linux-glibc - -do_test 'amd64-linux-glibc' '!amd64-linux-glibc' false - -do_test 'i686-linux-glibc' '!amd64-linux-glibc' true - -do_test 'all' '!amd64-linux-glibc' false - -# Architecture: amd64-linux-glibc cortexa8-linux-glibc - -do_test 'amd64-linux-glibc' 'amd64-linux-glibc cortexa8-linux-glibc' true - -do_test 'i686-linux-glibc' 'amd64-linux-glibc cortexa8-linux-glibc' false - -do_test 'all' 'amd64-linux-glibc cortexa8-linux-glibc' false - -# Architecture: amd64-linux-glibc all - -do_test 'amd64-linux-glibc' 'amd64-linux-glibc all' true - -do_test 'i686-linux-glibc' 'amd64-linux-glibc all' false - -do_test 'all' 'amd64-linux-glibc all' true +main() +{ + local arches= + + # Architecture: all + arches='all' + do_test 'amd64-linux-glibc' "${arches}" false + do_test 'i686-linux-glibc' "${arches}" false + do_test 'all' "${arches}" true + + # Architecture: any + arches='any' + do_test 'amd64-linux-glibc' "${arches}" true + do_test 'i686-linux-glibc' "${arches}" true + do_test 'all' "${arches}" false + + # Architecture: amd64-linux-glibc + arches='amd64-linux-glibc' + do_test 'amd64-linux-glibc' "${arches}" true + do_test 'i686-linux-glibc' "${arches}" false + do_test 'all' "${arches}" false + + # Architecture: !amd64-linux-glibc + arches='!amd64-linux-glibc' + do_test 'amd64-linux-glibc' "${arches}" false + do_test 'i686-linux-glibc' "${arches}" true + do_test 'all' "${arches}" false + + # Architecture: amd64-linux-glibc cortexa8-linux-glibc + arches='amd64-linux-glibc cortexa8-linux-glibc' + do_test 'amd64-linux-glibc' "${arches}" true + do_test 'i686-linux-glibc' "${arches}" false + do_test 'all' "${arches}" false + + # Architecture: amd64-linux-glibc all + arches='amd64-linux-glibc all' + do_test 'amd64-linux-glibc' "${arches}" true + do_test 'i686-linux-glibc' "${arches}" false + do_test 'all' "${arches}" true + + return 0 +} diff --git a/tests/common.sh b/tests/common.sh index b883a51..293dc7d 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -33,21 +33,6 @@ trap atexit EXIT in_place=true builddir='.' -use() -{ - local module="${1}" - local dir= - - dir='lib' - - if [ -f "${dir}/${module}.sm" ]; then - . "${dir}/${module}.sm" - else - printf '%s: Error: Failed to load module "%s": %s\n' \ - "${0##*/}" "${module}" 'no such file or directory' >&2 - exit 2 - fi -} assert() { diff --git a/tests/local.mk b/tests/local.mk index 023eae1..4c54bc8 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -1,8 +1,55 @@ -TESTS = \ +check_PROGRAMS = \ + tests/parse_control.basic \ + tests/resolve_deps.basic \ + tests/match_arch \ + tests/match_plat \ + tests/arch_is_concerned \ + tests/plat_is_concerned \ + tests/reduce_deps + +TESTS = $(check_PROGRAMS) + +tests_parse_control_basic_SOURCES = \ tests/parse_control.basic.sh \ + tests/parse_control.common.sh \ + tests/common.sh \ + src/output.sh \ + src/control.sh +tests_parse_control_basic_LDADD = $(tests_parse_control_basic_SOURCES:.sh=.sho) + +tests_resolve_deps_basic_SOURCES = \ tests/resolve_deps.basic.sh \ + tests/common.sh \ + src/pkg.sh +tests_resolve_deps_basic_LDADD = $(tests_resolve_deps_basic_SOURCES:.sh=.sho) + +tests_match_arch_SOURCES = \ tests/match_arch.sh \ + tests/common.sh \ + src/archplat.sh +tests_match_arch_LDADD = $(tests_match_arch_SOURCES:.sh=.sho) + +tests_match_plat_SOURCES = \ tests/match_plat.sh \ + tests/common.sh \ + src/archplat.sh +tests_match_plat_LDADD = $(tests_match_plat_SOURCES:.sh=.sho) + +tests_arch_is_concerned_SOURCES = \ tests/arch_is_concerned.sh \ + tests/common.sh \ + src/archplat.sh +tests_arch_is_concerned_LDADD = $(tests_arch_is_concerned_SOURCES:.sh=.sho) + +tests_plat_is_concerned_SOURCES = \ tests/plat_is_concerned.sh \ - tests/reduce_deps.sh + tests/common.sh \ + src/archplat.sh +tests_plat_is_concerned_LDADD = $(tests_plat_is_concerned_SOURCES:.sh=.sho) + +tests_reduce_deps_SOURCES = \ + tests/reduce_deps.sh \ + tests/common.sh \ + src/deps.sh \ + src/archplat.sh +tests_reduce_deps_LDADD = $(tests_reduce_deps_SOURCES:.sh=.sho) diff --git a/tests/match_arch.sh b/tests/match_arch.sh index f9b8a22..35f943b 100755 --- a/tests/match_arch.sh +++ b/tests/match_arch.sh @@ -20,10 +20,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use archplat - do_test() { local arch="${1}" @@ -47,26 +43,31 @@ do_test() fi } -do_test all 'all' true +main() +{ + do_test all 'all' true -do_test foo-bar-baz 'any' true + do_test foo-bar-baz 'any' true -do_test foo-bar-baz 'any all' true + do_test foo-bar-baz 'any all' true -do_test all 'any all' true + do_test all 'any all' true -do_test foo-bar-baz 'foo-bar-baz' true + do_test foo-bar-baz 'foo-bar-baz' true -do_test foo-bar-baz 'foo-any-any' true + do_test foo-bar-baz 'foo-any-any' true -do_test foo-bar-baz 'foo-bar-qux' false + do_test foo-bar-baz 'foo-bar-qux' false -do_test foo-bar-baz 'any-qux-any any-bar-any' true + do_test foo-bar-baz 'any-qux-any any-bar-any' true -do_test foo-bar-baz 'any-qux-any any-quux-any' false + do_test foo-bar-baz 'any-qux-any any-quux-any' false -do_test all 'any' false + do_test all 'any' false -do_test any 'all' false + do_test any 'all' false -do_test all 'foo-any-any' false + do_test all 'foo-any-any' false + + return 0 +} diff --git a/tests/match_plat.sh b/tests/match_plat.sh index 775e203..9074362 100755 --- a/tests/match_plat.sh +++ b/tests/match_plat.sh @@ -20,10 +20,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use archplat - do_test() { local plat="${1}" @@ -47,18 +43,23 @@ do_test() fi } -do_test all 'all' true +main() +{ + do_test all 'all' true -do_test dev 'any' true + do_test dev 'any' true -do_test dev 'any all' true + do_test dev 'any all' true -do_test all 'any all' true + do_test all 'any all' true -do_test dev 'dev' true + do_test dev 'dev' true -do_test dev 'ao751h' false + do_test dev 'ao751h' false -do_test all 'any' false + do_test all 'any' false -do_test any 'all' false + do_test any 'all' false + + return 0 +} diff --git a/tests/parse_control.basic.sh b/tests/parse_control.basic.sh index f8df181..98d3c83 100755 --- a/tests/parse_control.basic.sh +++ b/tests/parse_control.basic.sh @@ -39,5 +39,3 @@ Package bar Version 2.0 ¶ " - -. "${srcdir}/tests/parse_control.common.sh" diff --git a/tests/parse_control.common.sh b/tests/parse_control.common.sh index 1549ae0..9eee27b 100644 --- a/tests/parse_control.common.sh +++ b/tests/parse_control.common.sh @@ -18,11 +18,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use output -use control - load_locale HT=' ' @@ -41,10 +36,15 @@ para() test_results="${test_results}¶${LF}" } -parse_control - field para "${req_fields}" <<-EOF - ${packages} - EOF +main() +{ + parse_control - field para "${req_fields}" <<-EOF + ${packages} + EOF -printf 'Required fields: %s\n\n' "${req_fields}" + printf 'Required fields: %s\n\n' "${req_fields}" -test_diff "${results}" "${test_results}" + test_diff "${results}" "${test_results}" + + return 0 +} diff --git a/tests/plat_is_concerned.sh b/tests/plat_is_concerned.sh index 2bc808b..126e36a 100755 --- a/tests/plat_is_concerned.sh +++ b/tests/plat_is_concerned.sh @@ -20,10 +20,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use archplat - do_test() { local host_plat="${1}" @@ -47,50 +43,37 @@ do_test() fi } -# Platform: all - -do_test dev 'all' false - -do_test ao751h 'all' false - -do_test all 'all' true - -# Platform: any - -do_test dev 'any' true - -do_test ao751h 'any' true - -do_test all 'any' false - -# Platform: dev - -do_test dev 'dev' true - -do_test ao751h 'dev' false - -do_test all 'dev' false - -# Platform: !dev - -do_test dev '!dev' false - -do_test ao751h '!dev' true - -do_test all '!dev' false - -# Platform: dev dimension2400 - -do_test 'dev' 'dev dimension2400' true - -do_test 'ao751h' 'dev dimension2400' false - -do_test 'all' 'dev dimension2400' false - -# Platform: dev all - -do_test 'dev' 'dev all' true - -do_test 'ao751h' 'dev all' false - -do_test 'all' 'dev all' true +main() +{ + # Platform: all + do_test dev 'all' false + do_test ao751h 'all' false + do_test all 'all' true + + # Platform: any + do_test dev 'any' true + do_test ao751h 'any' true + do_test all 'any' false + + # Platform: dev + do_test dev 'dev' true + do_test ao751h 'dev' false + do_test all 'dev' false + + # Platform: !dev + do_test dev '!dev' false + do_test ao751h '!dev' true + do_test all '!dev' false + + # Platform: dev dimension2400 + do_test 'dev' 'dev dimension2400' true + do_test 'ao751h' 'dev dimension2400' false + do_test 'all' 'dev dimension2400' false + + # Platform: dev all + do_test 'dev' 'dev all' true + do_test 'ao751h' 'dev all' false + do_test 'all' 'dev all' true + + return 0 +} diff --git a/tests/reduce_deps.sh b/tests/reduce_deps.sh index 569a16c..0e5f7da 100755 --- a/tests/reduce_deps.sh +++ b/tests/reduce_deps.sh @@ -20,10 +20,6 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use deps - do_test() { local deps="${1}" @@ -45,38 +41,30 @@ do_test() fi } -# Normal and union AND-lists. - -do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - -do_test 'foo,bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - -do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - -do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' - -do_test 'foo,bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' - -do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' - -# Normal and union OR-lists. - -do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' - -do_test 'foo|bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' - -do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' - -# Normal and union AND-lists with arch specs. - -do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' false \ - 'amd64-linux-glibc' 'dev' 'foo' - -do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' true \ - 'amd64-linux-glibc' 'dev' 'foo' - -# Normal and union AND-lists with plat specs. - -do_test 'foo <dev>, bar <!dev>' false 'amd64-linux-glibc' 'dev' 'foo' - -do_test 'foo <dev>, bar <!dev>' true 'amd64-linux-glibc' 'dev' 'foo' +main() +{ + # Normal and union AND-lists. + do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' + do_test 'foo,bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' + do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' + do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' + do_test 'foo,bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' + do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' + + # Normal and union OR-lists. + do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' + do_test 'foo|bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' + do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' + + # Normal and union AND-lists with arch specs. + do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' false \ + 'amd64-linux-glibc' 'dev' 'foo' + do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' true \ + 'amd64-linux-glibc' 'dev' 'foo' + + # Normal and union AND-lists with plat specs. + do_test 'foo <dev>, bar <!dev>' false 'amd64-linux-glibc' 'dev' 'foo' + do_test 'foo <dev>, bar <!dev>' true 'amd64-linux-glibc' 'dev' 'foo' + + return 0 +} diff --git a/tests/resolve_deps.basic.sh b/tests/resolve_deps.basic.sh index b0c506c..b0b938e 100755 --- a/tests/resolve_deps.basic.sh +++ b/tests/resolve_deps.basic.sh @@ -20,23 +20,26 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. -. "${srcdir}/tests/common.sh" - -use pkg - pkgs='foo bar' deps="\ foo: baz bar: qux baz: quux " -results='foo bar baz qux quux' -test_results="$(resolve_deps "${pkgs}" "${deps}")" +main() +{ + local results= + local test_results= -test_diff "${results}" "${test_results}" + results='foo bar baz qux quux' + test_results="$(resolve_deps "${pkgs}" "${deps}")" + test_diff "${results}" "${test_results}" -results="$(printf '%s\n' ${results} | sort)" -test_results="$(printf '%s\n' $(resolve_deps "${pkgs}" "${deps}") | sort)" + results="$(printf '%s\n' ${results} | sort)" + test_results="$(printf '%s\n' $(resolve_deps "${pkgs}" "${deps}") | \ + sort)" + test_diff "${results}" "${test_results}" -test_diff "${results}" "${test_results}" + return 0 +} |