diff options
author | 2015-08-08 13:49:04 -0700 | |
---|---|---|
committer | 2015-08-08 17:38:18 -0700 | |
commit | 56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch) | |
tree | 3f91093cdb475e565ae857f1c5a7fd339e2d781e /eclass/tests | |
download | gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2 gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip |
proj/gentoo: Initial commit
This commit represents a new era for Gentoo:
Storing the gentoo-x86 tree in Git, as converted from CVS.
This commit is the start of the NEW history.
Any historical data is intended to be grafted onto this point.
Creation process:
1. Take final CVS checkout snapshot
2. Remove ALL ChangeLog* files
3. Transform all Manifests to thin
4. Remove empty Manifests
5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$
5.1. Do not touch files with -kb/-ko keyword flags.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests
X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project
X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration
X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn
X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts
X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration
X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging
X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'eclass/tests')
-rwxr-xr-x | eclass/tests/autotools_eaclocal_amflags.sh | 32 | ||||
-rwxr-xr-x | eclass/tests/distutils-r1.sh | 33 | ||||
-rwxr-xr-x | eclass/tests/eutils_eshopts.sh | 44 | ||||
-rwxr-xr-x | eclass/tests/eutils_estack.sh | 53 | ||||
-rwxr-xr-x | eclass/tests/eutils_evar.sh | 100 | ||||
-rwxr-xr-x | eclass/tests/eutils_path_exists.sh | 36 | ||||
-rwxr-xr-x | eclass/tests/flag-o-matic.sh | 149 | ||||
-rwxr-xr-x | eclass/tests/git-r3.sh | 204 | ||||
-rwxr-xr-x | eclass/tests/git-r3_GIT_DIR.sh | 61 | ||||
-rwxr-xr-x | eclass/tests/git-r3_subrepos.sh | 38 | ||||
-rwxr-xr-x | eclass/tests/linux-info_get_running_version.sh | 39 | ||||
-rwxr-xr-x | eclass/tests/multiprocessing.sh | 43 | ||||
-rwxr-xr-x | eclass/tests/multiprocessing_makeopts_jobs.sh | 39 | ||||
-rwxr-xr-x | eclass/tests/python-utils-r1.sh | 170 | ||||
-rwxr-xr-x | eclass/tests/savedconfig.sh | 79 | ||||
-rwxr-xr-x | eclass/tests/scons-utils.sh | 64 | ||||
-rw-r--r-- | eclass/tests/tests-common.sh | 147 | ||||
-rwxr-xr-x | eclass/tests/toolchain-funcs.sh | 115 | ||||
-rwxr-xr-x | eclass/tests/toolchain.sh | 83 | ||||
-rwxr-xr-x | eclass/tests/versionator_version_compare.sh | 200 |
20 files changed, 1729 insertions, 0 deletions
diff --git a/eclass/tests/autotools_eaclocal_amflags.sh b/eclass/tests/autotools_eaclocal_amflags.sh new file mode 100755 index 000000000000..e164796f0916 --- /dev/null +++ b/eclass/tests/autotools_eaclocal_amflags.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit autotools + +test-it() { + tbegin "eaclocal_amflags $1: $2" + printf "ACLOCAL_AMFLAGS = %b\n" "$2" > Makefile.am + local flags=$(eaclocal_amflags) exp=${3:-$2} + [[ "${flags}" == "${exp}" ]] + if ! tend $? ; then + printf '### INPUT:\n%s\n' "$2" + printf '### FILE:\n%s\n' "$(<Makefile.am)" + printf '### EXPECTED:\n%s\n' "${exp}" + printf '### ACTUAL:\n%s\n' "${flags}" + fi + rm Makefile.am +} + +test-it simple "-Im4" +test-it simple "-I m4 -I lakdjfladsfj /////" + +test-it shell-exec '`echo hi`' "hi" +test-it shell-exec '`echo {0..3}`' "0 1 2 3" + +test-it multiline '-I oneline \\\n\t-I twoline' "-I oneline -I twoline" + +texit diff --git a/eclass/tests/distutils-r1.sh b/eclass/tests/distutils-r1.sh new file mode 100755 index 000000000000..c5501bdcde74 --- /dev/null +++ b/eclass/tests/distutils-r1.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 +PYTHON_COMPAT=( python2_7 ) +source tests-common.sh + +test-phase_name_free() { + local ph=${1} + + if declare -f "${ph}"; then + die "${ph} function declared while name reserved for phase!" + fi + if declare -f "${ph}_all"; then + die "${ph}_all function declared while name reserved for phase!" + fi +} + +inherit distutils-r1 + +tbegin "sane function names" + +test-phase_name_free python_prepare +test-phase_name_free python_configure +test-phase_name_free python_compile +test-phase_name_free python_test +test-phase_name_free python_install + +tend ${failed} + +texit diff --git a/eclass/tests/eutils_eshopts.sh b/eclass/tests/eutils_eshopts.sh new file mode 100755 index 000000000000..65dc89c9f258 --- /dev/null +++ b/eclass/tests/eutils_eshopts.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +source tests-common.sh + +inherit eutils + +test-it() { + local s0 s1 s2 + + tbegin "push/pop '$*'" + s0=$(shopt -p) + t eshopts_push $* + s1=$(shopt -p) + t eshopts_pop + s2=$(shopt -p) + [[ ${s0} == "${s2}" ]] && \ + [[ ${s1} == *"shopt $*"* ]] + tend $? +} + +# should handle bug #395025 +for arg in nullglob dotglob extglob ; do + for flag in s u ; do + test-it -${flag} ${arg} + done +done + +tbegin "multi push/pop" +s0=$(shopt -p) +t eshopts_push -s dotglob +t eshopts_push -u dotglob +t eshopts_push -s extglob +t eshopts_push -u dotglob +t eshopts_push -s dotglob +t eshopts_pop +t eshopts_pop +t eshopts_pop +t eshopts_pop +t eshopts_pop +s1=$(shopt -p) +[[ ${s0} == "${s1}" ]] +tend $? + +texit diff --git a/eclass/tests/eutils_estack.sh b/eclass/tests/eutils_estack.sh new file mode 100755 index 000000000000..c029c9b1dae3 --- /dev/null +++ b/eclass/tests/eutils_estack.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit eutils + +tbegin "initial stack state" +estack_pop teststack +# Should be empty and thus return 1 +[[ $? -eq 1 ]] +tend $? + +tbegin "simple push/pop" +estack_push ttt 1 +pu=$? +estack_pop ttt +po=$? +[[ ${pu}${po} == "00" ]] +tend $? + +tbegin "simple push/pop var" +estack_push xxx "boo ga boo" +pu=$? +estack_pop xxx i +po=$? +[[ ${pu}${po} == "00" ]] && [[ ${i} == "boo ga boo" ]] +tend $? + +tbegin "multi push/pop" +estack_push yyy {1..10} +pu=$? +i=0 +while estack_pop yyy ; do + : $(( i++ )) +done +[[ ${pu} -eq 0 && ${i} -eq 10 ]] +tend $? + +tbegin "umask push/pop" +u0=$(umask) +eumask_push 0000 +pu=$? +u1=$(umask) +eumask_pop +po=$? +u2=$(umask) +[[ ${pu}${po}:${u0}:${u1}:${u2} == "00:${u0}:0000:${u0}" ]] +tend $? + +texit diff --git a/eclass/tests/eutils_evar.sh b/eclass/tests/eutils_evar.sh new file mode 100755 index 000000000000..1e53a873e901 --- /dev/null +++ b/eclass/tests/eutils_evar.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit eutils + +tbegin "simple push/pop" +VAR=1 +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR} == "001" ]] +tend $? + +tbegin "unset push/pop" +unset VAR +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set} == "00" ]] +tend $? + +tbegin "empty push/pop" +VAR= +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set}${VAR} == "00set" ]] +tend $? + +tbegin "export push/pop" +export VAR=exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR}') +[[ ${pu}${po}${var} == "00exported" ]] +tend $? + +tbegin "unexport push/pop" +unset VAR +VAR=not-exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po}${VAR}${var} == "00not-exported" ]] +tend $? + +tbegin "multi push/pop" +A=a B=b C=c +evar_push A B C +pu=$? +A=A B=B C=C +evar_pop 1 +po1=$? +[[ ${A}${B}${C} == "ABc" ]] +po2=$? +evar_pop 2 +po3=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po1}${po2}${po3}${A}${B}${C} == "0000abc" ]] +tend $? + +tbegin "simple push_set/pop" +VAR=1 +evar_push_set VAR 2 +pu=$? +[[ ${VAR} == "2" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +tbegin "unset push_set/pop" +VAR=1 +evar_push_set VAR +pu=$? +[[ ${VAR+set} != "set" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +texit diff --git a/eclass/tests/eutils_path_exists.sh b/eclass/tests/eutils_path_exists.sh new file mode 100755 index 000000000000..a3d1f993f7d1 --- /dev/null +++ b/eclass/tests/eutils_path_exists.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit eutils + +test-path_exists() { + local exp=$1; shift + tbegin "path_exists($*) == ${exp}" + path_exists "$@" + [[ ${exp} -eq $? ]] + tend $? +} + +test-path_exists 1 +test-path_exists 1 -a +test-path_exists 1 -o + +good="/ . tests-common.sh /bin/bash" +test-path_exists 0 ${good} +test-path_exists 0 -a ${good} +test-path_exists 0 -o ${good} + +bad="/asjdkfljasdlfkja jlakjdsflkasjdflkasdjflkasdjflaskdjf" +test-path_exists 1 ${bad} +test-path_exists 1 -a ${bad} +test-path_exists 1 -o ${bad} + +test-path_exists 1 ${good} ${bad} +test-path_exists 1 -a ${good} ${bad} +test-path_exists 0 -o ${good} ${bad} + +texit diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh new file mode 100755 index 000000000000..762a5f74d94d --- /dev/null +++ b/eclass/tests/flag-o-matic.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit flag-o-matic + +CFLAGS="-a -b -c=1" +CXXFLAGS="-x -y -z=2" +LDFLAGS="-l -m -n=3" +ftend() { + local ret=$? + local msg="Failed; flags are:" + local flag + for flag in $(all-flag-vars) ; do + msg+=$'\n\t'"${flag}=${!flag}" + done + tend ${ret} "${msg}" +} + +tbegin "is-flag" +! (is-flag 1 2 3) 2>/dev/null +ftend + +tbegin "is-ldflag" +! (is-ldflag 1 2 3) 2>/dev/null +ftend + +while read exp flag ; do + [[ -z ${exp}${flag} ]] && continue + + tbegin "is-flagq ${flag}" + is-flagq ${flag} + [[ ${exp} -eq $? ]] + ftend +done <<<" + 1 -L + 0 -a + 0 -x +" + +while read exp flag ; do + [[ -z ${exp}${flag} ]] && continue + + tbegin "is-ldflagq ${flag}" + is-ldflagq "${flag}" + [[ ${exp} -eq $? ]] + ftend +done <<<" + 1 -a + 0 -n=* + 1 -n +" + +tbegin "strip-unsupported-flags" +strip-unsupported-flags +[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] +ftend + +for var in $(all-flag-vars) ; do + eval ${var}=\"-filter -filter-glob -foo-${var%FLAGS}\" +done + +tbegin "filter-flags basic" +filter-flags -filter +( +for var in $(all-flag-vars) ; do + val=${!var} + [[ ${val} == "-filter-glob -foo-${var%FLAGS}" ]] || exit 1 +done +) +ftend + +tbegin "filter-flags glob" +filter-flags '-filter-*' +( +for var in $(all-flag-vars) ; do + val=${!var} + [[ ${val} == "-foo-${var%FLAGS}" ]] || exit 1 +done +) +ftend + +tbegin "strip-flags basic" +CXXFLAGS+=" -O999 " +strip-flags +[[ -z ${CFLAGS}${LDFLAGS}${CPPFLAGS} && ${CXXFLAGS} == "-O2" ]] +ftend + +tbegin "replace-flags basic" +CFLAGS="-O0 -foo" +replace-flags -O0 -O1 +[[ ${CFLAGS} == "-O1 -foo" ]] +ftend + +tbegin "replace-flags glob" +CXXFLAGS="-O0 -mcpu=bad -cow" +replace-flags '-mcpu=*' -mcpu=good +[[ ${CXXFLAGS} == "-O0 -mcpu=good -cow" ]] +ftend + +tbegin "append-cflags basic" +CFLAGS= +append-cflags -O0 +[[ ${CFLAGS} == " -O0" ]] +ftend + +tbegin "append-cflags -DFOO='a b c'" +CFLAGS= +append-cflags '-DFOO="a b c"' +[[ ${CFLAGS} == ' -DFOO="a b c"' ]] +ftend + +tbegin "raw-ldflags" +LDFLAGS='-Wl,-O1 -Wl,--as-needed -Wl,-z,now -flto' +LDFLAGS=$(raw-ldflags) +[[ ${LDFLAGS} == '-O1 --as-needed -z now' ]] +ftend + +tbegin "test-flags-CC (valid flags)" +out=$(test-flags-CC -O3) +[[ $? -eq 0 && ${out} == "-O3" ]] +ftend + +tbegin "test-flags-CC (invalid flags)" +out=$(test-flags-CC -finvalid-flag) +[[ $? -ne 0 && -z ${out} ]] +ftend + +if type -P clang >/dev/null ; then +tbegin "test-flags-CC (valid flags w/clang)" +out=$(CC=clang test-flags-CC -O3) +[[ $? -eq 0 && ${out} == "-O3" ]] +ftend + +tbegin "test-flags-CC (invalid flags w/clang)" +out=$(CC=clang test-flags-CC -finvalid-flag) +[[ $? -ne 0 && -z ${out} ]] +ftend + +tbegin "test-flags-CC (gcc-valid but clang-invalid flags)" +out=$(CC=clang test-flags-CC -finline-limit=1200) +[[ $? -ne 0 && -z ${out} ]] +ftend +fi + +texit diff --git a/eclass/tests/git-r3.sh b/eclass/tests/git-r3.sh new file mode 100755 index 000000000000..3de6f059752f --- /dev/null +++ b/eclass/tests/git-r3.sh @@ -0,0 +1,204 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit git-r3 + +testdir=${pkg_root}/git +mkdir "${testdir}" || die "unable to mkdir testdir" +cd "${testdir}" || die "unable to cd to testdir" + +EGIT3_STORE_DIR=store +mkdir "${EGIT3_STORE_DIR}" || die "unable to mkdir store" + +test_file() { + local fn=${1} + local expect=${2} + + if [[ ! -f ${fn} ]]; then + eerror "${fn} does not exist (not checked out?)" + else + local got=$(<"${fn}") + + if [[ ${got} != ${expect} ]]; then + eerror "${fn}, expected: ${expect}, got: ${got}" + else + return 0 + fi + fi + return 1 +} + +test_no_file() { + local fn=${1} + + if [[ -f ${fn} ]]; then + eerror "${fn} exists (wtf?!)" + else + return 0 + fi + return 1 +} + +test_repo_clean() { + local P=${P}_${FUNCNAME#test_} + + ( + mkdir repo + cd repo + git init -q + echo test > file + git add file + git commit -m 1 -q + echo other-text > file2 + git add file2 + git commit -m 2 -q + ) || die "unable to prepare repo" + + # we need to use an array to preserve whitespace + local EGIT_REPO_URI=( + "ext::git daemon --export-all --base-path=. --inetd %G/repo" + ) + + tbegin "fetching from a simple repo" + ( + git-r3_src_unpack + test_file "${WORKDIR}/${P}/file" test && \ + test_file "${WORKDIR}/${P}/file2" other-text + ) &>fetch.log + + eend ${?} || cat fetch.log +} + +test_repo_revert() { + local P=${P}_${FUNCNAME#test_} + + ( + cd repo + git revert -n HEAD^ + git commit -m r1 -q + ) || die "unable to prepare repo" + + # we need to use an array to preserve whitespace + local EGIT_REPO_URI=( + "ext::git daemon --export-all --base-path=. --inetd %G/repo" + ) + + tbegin "fetching revert" + ( + git-r3_src_unpack + test_no_file "${WORKDIR}/${P}/file" && \ + test_file "${WORKDIR}/${P}/file2" other-text + ) &>fetch.log + + eend ${?} || cat fetch.log +} + +test_repo_branch() { + local P=${P}_${FUNCNAME#test_} + + ( + cd repo + git branch -q other-branch HEAD^ + git checkout -q other-branch + echo one-more > file3 + git add file3 + git commit -m 3 -q + git checkout -q master + ) || die "unable to prepare repo" + + # we need to use an array to preserve whitespace + local EGIT_REPO_URI=( + "ext::git daemon --export-all --base-path=. --inetd %G/repo" + ) + local EGIT_BRANCH=other-branch + + tbegin "switching branches" + ( + git-r3_src_unpack + test_file "${WORKDIR}/${P}/file" test && \ + test_file "${WORKDIR}/${P}/file2" other-text && \ + test_file "${WORKDIR}/${P}/file3" one-more + ) &>fetch.log + + eend ${?} || cat fetch.log +} + +test_repo_merge() { + local P=${P}_${FUNCNAME#test_} + + ( + cd repo + git branch -q one-more-branch HEAD^ + git checkout -q one-more-branch + echo foobarbaz > file3 + git add file3 + git commit -m 3b -q + git checkout -q master + git merge -m 4 -q one-more-branch + ) || die "unable to prepare repo" + + # we need to use an array to preserve whitespace + local EGIT_REPO_URI=( + "ext::git daemon --export-all --base-path=. --inetd %G/repo" + ) + + tbegin "fetching a merge commit" + ( + git-r3_src_unpack + test_no_file "${WORKDIR}/${P}/file" && \ + test_file "${WORKDIR}/${P}/file2" other-text && \ + test_file "${WORKDIR}/${P}/file3" foobarbaz + ) &>fetch.log + + eend ${?} || cat fetch.log +} + +test_repo_revert_merge() { + local P=${P}_${FUNCNAME#test_} + + ( + cd repo + git branch -q to-be-reverted + git checkout -q to-be-reverted + echo trrm > file3 + git add file3 + git commit -m 5b -q + git checkout -q master + echo trrm > file2 + git add file2 + git commit -m 5 -q + git merge -m 6 -q to-be-reverted + echo trrm > file + git add file + git commit -m 7 -q + git revert -m 1 -n HEAD^ + git commit -m 7r -q + ) || die "unable to prepare repo" + + # we need to use an array to preserve whitespace + local EGIT_REPO_URI=( + "ext::git daemon --export-all --base-path=. --inetd %G/repo" + ) + + tbegin "fetching a revert of a merge commit" + ( + git-r3_src_unpack + test_file "${WORKDIR}/${P}/file" trrm && \ + test_file "${WORKDIR}/${P}/file2" trrm && \ + test_file "${WORKDIR}/${P}/file3" foobarbaz + ) &>fetch.log + + eend ${?} || cat fetch.log +} + +test_repo_clean +test_repo_revert +test_repo_branch +test_repo_merge +test_repo_revert_merge + +texit diff --git a/eclass/tests/git-r3_GIT_DIR.sh b/eclass/tests/git-r3_GIT_DIR.sh new file mode 100755 index 000000000000..38ed723c8a83 --- /dev/null +++ b/eclass/tests/git-r3_GIT_DIR.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit git-r3 + +testdir=${pkg_root}/git +mkdir "${testdir}" || die "unable to mkdir testdir" +cd "${testdir}" || die "unable to cd to testdir" + +EGIT3_STORE_DIR=store +mkdir "${EGIT3_STORE_DIR}" || die "unable to mkdir store" + +# Test cleaning up canonical repo URI +test_repouri() { + local uri=${1} + local expect=${2} + local -x GIT_DIR + + tbegin "GIT_DIR for ${uri}" + + _git-r3_set_gitdir "${uri}" &>/dev/null + local got=${GIT_DIR#${EGIT3_STORE_DIR}/} + + [[ ${expect} == ${got} ]] + tend ${?} || eerror "Expected: ${expect}, got: ${got}" +} + +test_repouri git://git.overlays.gentoo.org/proj/portage.git proj_portage.git +test_repouri https://git.overlays.gentoo.org/gitroot/proj/portage.git proj_portage.git +test_repouri git+ssh://git@git.overlays.gentoo.org/proj/portage.git proj_portage.git + +test_repouri git://anongit.freedesktop.org/mesa/mesa mesa_mesa.git +test_repouri ssh://git.freedesktop.org/git/mesa/mesa mesa_mesa.git +test_repouri http://anongit.freedesktop.org/git/mesa/mesa.git mesa_mesa.git +test_repouri http://cgit.freedesktop.org/mesa/mesa/ mesa_mesa.git + +test_repouri https://code.google.com/p/snakeoil/ snakeoil.git + +test_repouri git://git.code.sf.net/p/xournal/code xournal_code.git +test_repouri http://git.code.sf.net/p/xournal/code xournal_code.git + +test_repouri git://git.gnome.org/glibmm glibmm.git +test_repouri https://git.gnome.org/browse/glibmm glibmm.git +test_repouri ssh://USERNAME@git.gnome.org/git/glibmm glibmm.git + +test_repouri git://git.kernel.org/pub/scm/git/git.git git_git.git +test_repouri http://git.kernel.org/pub/scm/git/git.git git_git.git +test_repouri https://git.kernel.org/pub/scm/git/git.git git_git.git +test_repouri https://git.kernel.org/cgit/git/git.git/ git_git.git + +#test_repouri git@github.com:gentoo/identity.gentoo.org.git gentoo_identity.gentoo.org.git +test_repouri https://github.com/gentoo/identity.gentoo.org.git gentoo_identity.gentoo.org.git + +#test_repouri git@bitbucket.org:mgorny/python-exec.git mgorny_python-exec.git +test_repouri https://mgorny@bitbucket.org/mgorny/python-exec.git mgorny_python-exec.git + +texit diff --git a/eclass/tests/git-r3_subrepos.sh b/eclass/tests/git-r3_subrepos.sh new file mode 100755 index 000000000000..4a66a1c3707b --- /dev/null +++ b/eclass/tests/git-r3_subrepos.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit git-r3 + +# Test getting submodule URIs +test_subrepos() { + local suburi=${1} + local expect=( "${@:2}" ) + + tbegin "subrepos for ${suburi} -> ${expect[0]}${expect[1]+...}" + + local subrepos + _git-r3_set_subrepos "${suburi}" "${repos[@]}" + + [[ ${expect[@]} == ${subrepos[@]} ]] + tend ${?} || eerror "Expected: ${expect[@]}, got: ${subrepos[@]}" +} + +# parent repos +repos=( http://foohub/fooman/foo.git git://foohub/fooman/foo.git ) + +# absolute URI +test_subrepos http://foo/bar http://foo/bar +test_subrepos /foo/bar /foo/bar + +# plain relative URI +test_subrepos ./baz http://foohub/fooman/foo.git/baz git://foohub/fooman/foo.git/baz + +# backward relative URIs +test_subrepos ../baz.git http://foohub/fooman/baz.git git://foohub/fooman/baz.git +test_subrepos ../../bazman/baz.git http://foohub/bazman/baz.git git://foohub/bazman/baz.git + +texit diff --git a/eclass/tests/linux-info_get_running_version.sh b/eclass/tests/linux-info_get_running_version.sh new file mode 100755 index 000000000000..d5b36a5d8902 --- /dev/null +++ b/eclass/tests/linux-info_get_running_version.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit linux-info + +test_get_running_version() { + local test_kv=$1 major=$2 minor=$3 patch=$4 extra=$5 + tbegin "get_running_version ${test_kv}" + uname() { echo "${test_kv}" ; } + ROOT=/:/:/:/: get_running_version + local r=$? + [[ ${r} -eq 0 && + ${major} == "${KV_MAJOR}" && + ${minor} == "${KV_MINOR}" && + ${patch} == "${KV_PATCH}" && + ${extra} == "${KV_EXTRA}" ]] + tend $? "FAIL: {ret: ${r}==0} {major: ${major}==${KV_MAJOR}} {minor: ${minor}==${KV_MINOR}} {patch: ${patch}==${KV_PATCH}} {extra: ${extra}==${KV_EXTRA}}" +} + +tests=( + # KV_FULL MAJOR MINOR PATCH EXTRA + 1.2.3 1 2 3 '' + 1.2.3.4 1 2 3 .4 + 1.2.3-ver+1.4 1 2 3 -ver+1.4 + 1.2-kern.3 1 2 0 -kern.3 + 1.2+kern.5 1 2 0 +kern.5 + 1.2.3_blah 1 2 3 _blah + 3.2.1-zen-vs2.3.2.5+ 3 2 1 -zen-vs2.3.2.5+ +) + +for (( i = 0; i < ${#tests[@]}; i += 5 )) ; do + test_get_running_version "${tests[@]:i:5}" +done + +texit diff --git a/eclass/tests/multiprocessing.sh b/eclass/tests/multiprocessing.sh new file mode 100755 index 000000000000..d20cb6ea08d1 --- /dev/null +++ b/eclass/tests/multiprocessing.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit multiprocessing + +tbegin "simple" +MAKEOPTS="-j1" multijob_init +multijob_child_init ls -d / >/dev/null || die "fail!" +multijob_finish +tend $? + +tbegin "less simple" +multijob_init -j3 +multijob_child_init true || die "fail!" +multijob_child_init false || die "fail!" +multijob_child_init true || die "fail!" +multijob_finish +tend $(( $? == 1 ? 0 : 1 )) + +tbegin "less less simple" +multijob_init -j1 +multijob_child_init true || die "fail!" +multijob_child_init false || die "fail!" +multijob_child_init true && die "fail!" +multijob_finish +tend $? + +tbegin "less less less simple" +multijob_init -j10 +multijob_child_init true || die "fail!" +multijob_finish_one || die "fail!" +multijob_child_init false || die "fail!" +multijob_finish_one && die "fail!" +multijob_child_init true || die "fail!" +multijob_finish_one || die "fail!" +multijob_finish +tend $? + +texit diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh new file mode 100755 index 000000000000..017d491156a0 --- /dev/null +++ b/eclass/tests/multiprocessing_makeopts_jobs.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit multiprocessing + +test-makeopts_jobs() { + local exp=$1; shift + tbegin "makeopts_jobs($*) == ${exp}" + local act=$(makeopts_jobs "$@") + [[ ${act} == "${exp}" ]] + tend $? "Got back: ${act}" +} + +tests=( + 999 "-j" + 999 "--jobs" + 1 "" + 1 "-l9 -w" + 1 "-l9 -w-j4" + 1 "-l9--jobs=3" + 1 "-l9--jobs=8" + 2 "-j2" + 3 "-j 3" + 4 "-l3 -j 4 -w" + 5 "--jobs=5" + 6 "--jobs 6" + 7 "-l3 --jobs 7 -w" + 4 "-j1 -j 2 --jobs 3 --jobs=4" + 8 " -j 8 " +) +for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do + test-makeopts_jobs "${tests[i]}" "${tests[i+1]}" +done + +texit diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh new file mode 100755 index 000000000000..e49636a6111a --- /dev/null +++ b/eclass/tests/python-utils-r1.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 +source tests-common.sh + +test_var() { + local var=${1} + local impl=${2} + local expect=${3} + + tbegin "${var} for ${impl}" + + local ${var} + python_export ${impl} ${var} + [[ ${!var} == ${expect} ]] || eerror "(${impl}: ${var}: ${!var} != ${expect}" + + tend ${?} +} + +test_is() { + local func=${1} + local expect=${2} + + tbegin "${func} (expecting: ${expect})" + + ${func} + [[ ${?} == ${expect} ]] + + tend ${?} +} + +test_fix_shebang() { + local from=${1} + local to=${2} + local expect=${3} + local args=( "${@:4}" ) + + tbegin "python_fix_shebang${args[@]+ ${args[*]}} from ${from} to ${to} (exp: ${expect})" + + echo "${from}" > "${tmpfile}" + output=$( EPYTHON=${to} python_fix_shebang "${args[@]}" -q "${tmpfile}" 2>&1 ) + + if [[ ${?} != 0 ]]; then + if [[ ${expect} != FAIL ]]; then + echo "${output}" + tend 1 + else + tend 0 + fi + else + [[ $(<"${tmpfile}") == ${expect} ]] \ + || eerror "${from} -> ${to}: $(<"${tmpfile}") != ${expect}" + tend ${?} + fi +} + +tmpfile=$(mktemp) + +inherit python-utils-r1 + +test_var EPYTHON python2_7 python2.7 +test_var PYTHON python2_7 /usr/bin/python2.7 +test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages +test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7 +test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname) +test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' +test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 + +test_var EPYTHON python3_3 python3.3 +test_var PYTHON python3_3 /usr/bin/python3.3 +test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages +test_var PYTHON_INCLUDEDIR python3_3 /usr/include/python3.3 +test_var PYTHON_LIBPATH python3_3 /usr/lib/libpython3.3$(get_libname) +test_var PYTHON_PKG_DEP python3_3 '*dev-lang/python*:3.3' +test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3 + +test_var EPYTHON jython2_7 jython2.7 +test_var PYTHON jython2_7 /usr/bin/jython2.7 +test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages +test_var PYTHON_PKG_DEP jython2_7 '*dev-java/jython*:2.7' +test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7 + +test_var EPYTHON pypy pypy +test_var PYTHON pypy /usr/bin/pypy +test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages +test_var PYTHON_INCLUDEDIR pypy /usr/lib/pypy/include +test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0=' +test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy + +test_var EPYTHON pypy3 pypy3 +test_var PYTHON pypy3 /usr/bin/pypy3 +test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages +test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include +test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0=' +test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3 + +test_is "python_is_python3 python2.7" 1 +test_is "python_is_python3 python3.2" 0 +test_is "python_is_python3 jython2.7" 1 +test_is "python_is_python3 pypy" 1 +test_is "python_is_python3 pypy3" 0 + +# generic shebangs +test_fix_shebang '#!/usr/bin/python' python2.7 '#!/usr/bin/python2.7' +test_fix_shebang '#!/usr/bin/python' python3.4 '#!/usr/bin/python3.4' +test_fix_shebang '#!/usr/bin/python' pypy '#!/usr/bin/pypy' +test_fix_shebang '#!/usr/bin/python' pypy3 '#!/usr/bin/pypy3' +test_fix_shebang '#!/usr/bin/python' jython2.7 '#!/usr/bin/jython2.7' + +# python2/python3 matching +test_fix_shebang '#!/usr/bin/python2' python2.7 '#!/usr/bin/python2.7' +test_fix_shebang '#!/usr/bin/python3' python2.7 FAIL +test_fix_shebang '#!/usr/bin/python3' python2.7 '#!/usr/bin/python2.7' --force +test_fix_shebang '#!/usr/bin/python3' python3.4 '#!/usr/bin/python3.4' +test_fix_shebang '#!/usr/bin/python2' python3.4 FAIL +test_fix_shebang '#!/usr/bin/python2' python3.4 '#!/usr/bin/python3.4' --force + +# pythonX.Y matching (those mostly test the patterns) +test_fix_shebang '#!/usr/bin/python2.7' python2.7 '#!/usr/bin/python2.7' +test_fix_shebang '#!/usr/bin/python2.7' python3.2 FAIL +test_fix_shebang '#!/usr/bin/python2.7' python3.2 '#!/usr/bin/python3.2' --force +test_fix_shebang '#!/usr/bin/python3.2' python3.2 '#!/usr/bin/python3.2' +test_fix_shebang '#!/usr/bin/python3.2' python2.7 FAIL +test_fix_shebang '#!/usr/bin/python3.2' python2.7 '#!/usr/bin/python2.7' --force +test_fix_shebang '#!/usr/bin/pypy' pypy '#!/usr/bin/pypy' +test_fix_shebang '#!/usr/bin/pypy' python2.7 FAIL +test_fix_shebang '#!/usr/bin/pypy' python2.7 '#!/usr/bin/python2.7' --force +test_fix_shebang '#!/usr/bin/jython2.7' jython2.7 '#!/usr/bin/jython2.7' +test_fix_shebang '#!/usr/bin/jython2.7' jython3.2 FAIL +test_fix_shebang '#!/usr/bin/jython2.7' jython3.2 '#!/usr/bin/jython3.2' --force + +# fancy path handling +test_fix_shebang '#!/mnt/python2/usr/bin/python' python3.4 \ + '#!/mnt/python2/usr/bin/python3.4' +test_fix_shebang '#!/mnt/python2/usr/bin/python2' python2.7 \ + '#!/mnt/python2/usr/bin/python2.7' +test_fix_shebang '#!/mnt/python2/usr/bin/env python' python2.7 \ + '#!/mnt/python2/usr/bin/env python2.7' +test_fix_shebang '#!/mnt/python2/usr/bin/python2 python2' python2.7 \ + '#!/mnt/python2/usr/bin/python2.7 python2' +test_fix_shebang '#!/mnt/python2/usr/bin/python3 python2' python2.7 FAIL +test_fix_shebang '#!/mnt/python2/usr/bin/python3 python2' python2.7 \ + '#!/mnt/python2/usr/bin/python2.7 python2' --force +test_fix_shebang '#!/usr/bin/foo' python2.7 FAIL + +# regression test for bug #522080 +test_fix_shebang '#!/usr/bin/python ' python2.7 '#!/usr/bin/python2.7 ' + +# make sure we don't break pattern matching +test_is "_python_impl_supported python2_5" 1 +test_is "_python_impl_supported python2_6" 1 +test_is "_python_impl_supported python2_7" 0 +test_is "_python_impl_supported python3_1" 1 +test_is "_python_impl_supported python3_2" 1 +test_is "_python_impl_supported python3_3" 0 +test_is "_python_impl_supported python3_4" 0 +test_is "_python_impl_supported pypy1_8" 1 +test_is "_python_impl_supported pypy1_9" 1 +test_is "_python_impl_supported pypy2_0" 1 +test_is "_python_impl_supported pypy" 0 +test_is "_python_impl_supported pypy3" 0 +test_is "_python_impl_supported jython2_5" 0 +test_is "_python_impl_supported jython2_7" 0 + +rm "${tmpfile}" + +texit diff --git a/eclass/tests/savedconfig.sh b/eclass/tests/savedconfig.sh new file mode 100755 index 000000000000..c4a3ce824fdc --- /dev/null +++ b/eclass/tests/savedconfig.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit savedconfig + +quiet() { + local out ret + out=$("$@" 2>&1) + ret=$? + [[ ${ret} -eq 0 ]] || echo "${out}" + return ${ret} +} +sc() { EBUILD_PHASE=install quiet save_config "$@" ; } +rc() { EBUILD_PHASE=prepare quiet restore_config "$@" ; } + +cleanup() { rm -rf "${ED}"/* "${T}"/* "${WORKDIR}"/* ; } +test-it() { + local ret=0 + tbegin "$@" + mkdir -p "${ED}"/etc/portage/savedconfig + : $(( ret |= $? )) + pushd "${WORKDIR}" >/dev/null + : $(( ret |= $? )) + test + : $(( ret |= $? )) + popd >/dev/null + : $(( ret |= $? )) + tend ${ret} + cleanup +} + +test() { + touch f || return 1 + sc f || return 1 + [[ -f ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "simple save_config" + +test() { + touch a b c || return 1 + sc a b c || return 1 + [[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "multi save_config" + +test() { + mkdir dir || return 1 + touch dir/{a,b,c} || return 1 + sc dir || return 1 + [[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "dir save_config" + +PORTAGE_CONFIGROOT=${D} + +test() { + echo "ggg" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] +} +test-it "simple restore_config" + +test() { + echo "ggg" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] || return 1 + sc f || return 1 + + echo "hhh" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] +} +test-it "simple restore+save config" + +texit diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh new file mode 100755 index 000000000000..5a65fbe63ffc --- /dev/null +++ b/eclass/tests/scons-utils.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit scons-utils + +test-scons_clean_makeopts() { + local sconsopts=$(scons_clean_makeopts ${1}) + + if [[ ${sconsopts} != ${2-${1}} ]]; then + eerror "Self-test failed:" + eindent + eerror "MAKEOPTS: ${1}" + eerror "Expected: ${2-${1}}" + eerror "Actual: ${sconsopts}" + eoutdent + (( ++failed )) + return 1 + fi + + return 0 +} + +# jobcount expected for non-specified state +jc=5 +# failed test counter +failed=0 + +tbegin "scons_clean_makeopts()" + +# sane MAKEOPTS +test-scons_clean_makeopts '--jobs=14 -k' +test-scons_clean_makeopts '--jobs=14 -k' +test-scons_clean_makeopts '--jobs 15 -k' +test-scons_clean_makeopts '--jobs=16 --keep-going' +test-scons_clean_makeopts '-j17 --keep-going' +test-scons_clean_makeopts '-j 18 --keep-going' + +# needing cleaning +test-scons_clean_makeopts '--jobs -k' "--jobs=${jc} -k" +test-scons_clean_makeopts '--jobs --keep-going' "--jobs=${jc} --keep-going" +test-scons_clean_makeopts '-kj' "-kj ${jc}" + +# broken by definition (but passed as it breaks make as well) +test-scons_clean_makeopts '-jk' +test-scons_clean_makeopts '--jobs=randum' +test-scons_clean_makeopts '-kjrandum' + +# needing stripping +test-scons_clean_makeopts '--load-average=25 -kj16' '-kj16' +test-scons_clean_makeopts '--load-average 25 -k -j17' '-k -j17' +test-scons_clean_makeopts '-j2 HOME=/tmp' '-j2' +test-scons_clean_makeopts '--jobs funnystuff -k' "--jobs=${jc} -k" + +# bug #388961 +test-scons_clean_makeopts '--jobs -l3' "--jobs=${jc}" +test-scons_clean_makeopts '-j -l3' "-j ${jc}" + +tend ${failed} + +texit diff --git a/eclass/tests/tests-common.sh b/eclass/tests/tests-common.sh new file mode 100644 index 000000000000..d3095e5fc350 --- /dev/null +++ b/eclass/tests/tests-common.sh @@ -0,0 +1,147 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +if ! source /lib/gentoo/functions.sh ; then + echo "Missing functions.sh. Please install sys-apps/gentoo-functions!" 1>&2 + exit 1 +fi + +# Let overlays override this so they can add their own testsuites. +TESTS_ECLASS_SEARCH_PATHS=( .. ) + +inherit() { + local e path + for e in "$@" ; do + for path in "${TESTS_ECLASS_SEARCH_PATHS[@]}" ; do + local eclass=${path}/${e}.eclass + if [[ -e "${eclass}" ]] ; then + source "${eclass}" + return 0 + fi + done + done + die "could not find ${eclass}" +} +EXPORT_FUNCTIONS() { :; } + +debug-print() { + [[ ${#} -eq 0 ]] && return + + if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then + printf 'debug: %s\n' "${@}" >&2 + elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then + printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}" + fi +} + +debug-print-function() { + debug-print "${1}, parameters: ${*:2}" +} + +debug-print-section() { + debug-print "now in section ${*}" +} + +has() { + local needle=$1 + shift + + local x + for x in "$@"; do + [ "${x}" = "${needle}" ] && return 0 + done + return 1 +} +use() { has "$1" ${IUSE} ; } + +die() { + echo "die: $*" 1>&2 + exit 1 +} + +has_version() { + portageq has_version / "$@" +} + +KV_major() { + [[ -z $1 ]] && return 1 + + local KV=$@ + echo "${KV%%.*}" +} + +KV_minor() { + [[ -z $1 ]] && return 1 + + local KV=$@ + KV=${KV#*.} + echo "${KV%%.*}" +} + +KV_micro() { + [[ -z $1 ]] && return 1 + + local KV=$@ + KV=${KV#*.*.} + echo "${KV%%[^[:digit:]]*}" +} + +KV_to_int() { + [[ -z $1 ]] && return 1 + + local KV_MAJOR=$(KV_major "$1") + local KV_MINOR=$(KV_minor "$1") + local KV_MICRO=$(KV_micro "$1") + local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + if [[ ${KV_int} -ge 131584 ]] ; then + echo "${KV_int}" + return 0 + fi + + return 1 +} + +tret=0 +tbegin() { + ebegin "Testing $*" +} +texit() { + rm -rf "${tmpdir}" + exit ${tret} +} +tend() { + t eend "$@" +} +t() { + "$@" + local ret=$? + : $(( tret |= ${ret} )) + return ${ret} +} + +tmpdir="${PWD}/tmp" +pkg_root="${tmpdir}/$0/${RANDOM}" +T="${pkg_root}/temp" +D="${pkg_root}/image" +WORKDIR="${pkg_root}/work" +ED=${D} +mkdir -p "${D}" "${T}" "${WORKDIR}" + +dodir() { + mkdir -p "${@/#/${ED}/}" +} + +elog() { einfo "$@" ; } + +IUSE="" +CATEGORY="dev-eclass" +PN="tests" +PV="0" +P="${PN}-${PV}" +PF=${P} +SLOT=0 diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh new file mode 100755 index 000000000000..41c1ae59306b --- /dev/null +++ b/eclass/tests/toolchain-funcs.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit toolchain-funcs + +# +# TEST: tc-arch-kernel +# +test-tc-arch-kernel() { + local ret=0 + KV=$1 ; shift + for CHOST in "$@" ; do + exp=${CHOST##*:} + CHOST=${CHOST%%:*} + actual=$(tc-arch-kernel) + + if [[ ${actual} != ${exp:-${CHOST}} ]] ; then + eerror "Failure for CHOST: ${CHOST} Expected: ${exp} != Actual: ${actual}" + ((++ret)) + fi + done + return ${ret} +} +tbegin "tc-arch-kernel() (KV=2.6.0)" +test-tc-arch-kernel 2.6.0 \ + alpha arm{,eb}:arm avr32 bfin:blackfin cris hppa:parisc \ + i{3..6}86:i386 ia64 m68k mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 \ + s390{,x}:s390 sh{1..4}{,eb}:sh sparc{,64} vax x86_64 \ + i{3..6}86-gentoo-freebsd:i386 +tend $? +tbegin "tc-arch-kernel() (KV=2.6.30)" +test-tc-arch-kernel 2.6.30 \ + i{3..6}86:x86 x86_64:x86 \ + powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386 +tend $? + +# +# TEST: tc-arch +# +tbegin "tc-arch" +ret=0 +for CHOST in \ + alpha arm{,eb}:arm avr32:avr bfin cris hppa i{3..6}86:x86 ia64 m68k \ + mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 s390{,x}:s390 \ + sh{1..4}{,eb}:sh sparc{,64}:sparc vax x86_64:amd64 +do + exp=${CHOST##*:} + CHOST=${CHOST%%:*} + actual=$(tc-arch) + + if [[ ${actual} != ${exp:-${CHOST}} ]] ; then + eerror "Failure for CHOST: ${CHOST} Expected: ${exp} != Actual: ${actual}" + : $((++ret)) + fi +done +tend ${ret} + +# +# TEST: tc-ld-is-gold +# +tbegin "tc-ld-is-gold (bfd selected)" +LD=ld.bfd tc-ld-is-gold && ret=1 || ret=0 +tend ${ret} + +tbegin "tc-ld-is-gold (gold selected)" +LD=ld.gold tc-ld-is-gold +ret=$? +tend ${ret} + +tbegin "tc-ld-is-gold (bfd selected via flags)" +LD=ld.gold LDFLAGS=-fuse-ld=bfd tc-ld-is-gold +ret=$? +tend ${ret} + +tbegin "tc-ld-is-gold (gold selected via flags)" +LD=ld.bfd LDFLAGS=-fuse-ld=gold tc-ld-is-gold +ret=$? +tend ${ret} + +# +# TEST: tc-ld-disable-gold +# +tbegin "tc-ld-disable-gold (bfd selected)" +( +export LD=ld.bfd LDFLAGS= +ewarn() { :; } +tc-ld-disable-gold +[[ ${LD} == "ld.bfd" && -z ${LDFLAGS} ]] +) +tend $? + +tbegin "tc-ld-disable-gold (gold selected)" +( +export LD=ld.gold LDFLAGS= +ewarn() { :; } +tc-ld-disable-gold +[[ ${LD} == "ld.bfd" || ${LDFLAGS} == *"-fuse-ld=bfd"* ]] +) +tend $? + +tbegin "tc-ld-disable-gold (gold selected via flags)" +( +export LD= LDFLAGS="-fuse-ld=gold" +ewarn() { :; } +tc-ld-disable-gold +[[ ${LD} == *"/ld.bfd" || ${LDFLAGS} == "-fuse-ld=gold -fuse-ld=bfd" ]] +) +tend $? + + +texit diff --git a/eclass/tests/toolchain.sh b/eclass/tests/toolchain.sh new file mode 100755 index 000000000000..7dc5e7330c3c --- /dev/null +++ b/eclass/tests/toolchain.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit toolchain + +test_downgrade_arch_flags() { + local exp msg ret=0 ver + + ver=${1} + exp=${2} + shift 2 + CFLAGS=${@} + + tbegin "${ver} ${CFLAGS} => ${exp}" + + CHOST=x86_64 # needed for tc-arch + downgrade_arch_flags ${ver} + + if [[ ${CFLAGS} != ${exp} ]]; then + msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\"" + ret=1 + fi + tend ${ret} ${msg} +} + +# ver expected given +test_downgrade_arch_flags 4.9 "-march=haswell" "-march=haswell" +test_downgrade_arch_flags 4.8 "-march=core-avx2" "-march=haswell" +test_downgrade_arch_flags 4.7 "-march=core-avx2" "-march=haswell" +test_downgrade_arch_flags 4.6 "-march=core-avx-i" "-march=haswell" +test_downgrade_arch_flags 4.5 "-march=core2" "-march=haswell" +test_downgrade_arch_flags 4.4 "-march=core2" "-march=haswell" +test_downgrade_arch_flags 4.3 "-march=core2" "-march=haswell" +test_downgrade_arch_flags 4.2 "-march=nocona" "-march=haswell" +test_downgrade_arch_flags 4.1 "-march=nocona" "-march=haswell" +test_downgrade_arch_flags 4.0 "-march=nocona" "-march=haswell" +test_downgrade_arch_flags 3.4 "-march=nocona" "-march=haswell" +test_downgrade_arch_flags 3.3 "-march=nocona" "-march=haswell" + +test_downgrade_arch_flags 4.9 "-march=bdver4" "-march=bdver4" +test_downgrade_arch_flags 4.8 "-march=bdver3" "-march=bdver4" +test_downgrade_arch_flags 4.7 "-march=bdver2" "-march=bdver4" +test_downgrade_arch_flags 4.6 "-march=bdver1" "-march=bdver4" +test_downgrade_arch_flags 4.5 "-march=amdfam10" "-march=bdver4" +test_downgrade_arch_flags 4.4 "-march=amdfam10" "-march=bdver4" +test_downgrade_arch_flags 4.3 "-march=amdfam10" "-march=bdver4" +test_downgrade_arch_flags 4.2 "-march=k8" "-march=bdver4" +test_downgrade_arch_flags 4.1 "-march=k8" "-march=bdver4" +test_downgrade_arch_flags 4.0 "-march=k8" "-march=bdver4" +test_downgrade_arch_flags 3.4 "-march=k8" "-march=bdver4" +test_downgrade_arch_flags 3.3 "-march=x86-64" "-march=bdver4" + +test_downgrade_arch_flags 3.4 "-march=c3-2" "-march=c3-2" +test_downgrade_arch_flags 3.3 "-march=c3" "-march=c3-2" + +test_downgrade_arch_flags 4.5 "-march=garbage" "-march=garbage" + +test_downgrade_arch_flags 4.9 "-mtune=intel" "-mtune=intel" +test_downgrade_arch_flags 4.8 "-mtune=generic" "-mtune=intel" +test_downgrade_arch_flags 3.4 "" "-mtune=generic" +test_downgrade_arch_flags 3.4 "" "-mtune=x86-64" +test_downgrade_arch_flags 3.3 "" "-mtune=anything" + +test_downgrade_arch_flags 4.5 "-march=amdfam10 -mtune=generic" "-march=btver2 -mtune=generic" +test_downgrade_arch_flags 3.3 "-march=k6-2" "-march=geode -mtune=barcelona" +test_downgrade_arch_flags 3.4 "-march=k8" "-march=btver2 -mtune=generic" + +test_downgrade_arch_flags 4.2 "-march=native" "-march=native" +test_downgrade_arch_flags 4.1 "-march=nocona" "-march=native" + +test_downgrade_arch_flags 4.9 "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" +test_downgrade_arch_flags 4.8 "-march=foo -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" +test_downgrade_arch_flags 4.7 "-march=foo -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" +test_downgrade_arch_flags 4.6 "-march=foo -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" +test_downgrade_arch_flags 4.3 "-march=foo -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" +test_downgrade_arch_flags 4.2 "-march=foo" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" + +test_downgrade_arch_flags 4.4 "-O2 -march=core2 -ffoo -fblah" "-O2 -march=atom -mno-sha -ffoo -mno-rtm -fblah" +texit diff --git a/eclass/tests/versionator_version_compare.sh b/eclass/tests/versionator_version_compare.sh new file mode 100755 index 000000000000..633ba26dc2e6 --- /dev/null +++ b/eclass/tests/versionator_version_compare.sh @@ -0,0 +1,200 @@ +#!/bin/bash +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +source tests-common.sh + +inherit versionator + +eshopts_push -s extglob +ver=( "" "lt" "eq" "gt" ) +lt=1 eq=2 gt=3 + +test_version_compare() { + tbegin "version_compare ${1} -${ver[${2}]} ${3}" + version_compare "${1}" "${3}" + local r=$? + [[ ${r} -eq ${2} ]] + tend $? "FAIL: ${@} (got ${r} exp ${2})" +} + +echo " + 0 $lt 1 + 1 $lt 2 + 2 $gt 1 + 2 $eq 2 + 0 $eq 0 + 10 $lt 20 + 68 $eq 068 + 068 $gt 67 + 068 $lt 69 + + 1.0 $lt 2.0 + 2.0 $eq 2.0 + 2.0 $gt 1.0 + + 1.0 $gt 0.0 + 0.0 $eq 0.0 + 0.0 $lt 1.0 + + 0.1 $lt 0.2 + 0.2 $eq 0.2 + 0.3 $gt 0.2 + + 1.2 $lt 2.1 + 2.1 $gt 1.2 + + 1.2.3 $lt 1.2.4 + 1.2.4 $gt 1.2.3 + + 1.2.0 $gt 1.2 + 1.2.1 $gt 1.2 + 1.2 $lt 1.2.1 + + 1.2b $eq 1.2b + 1.2b $lt 1.2c + 1.2b $gt 1.2a + 1.2b $gt 1.2 + 1.2 $lt 1.2a + + 1.3 $gt 1.2a + 1.3 $lt 1.3a + + 1.0_alpha7 $lt 1.0_beta7 + 1.0_beta $lt 1.0_pre + 1.0_pre5 $lt 1.0_rc2 + 1.0_rc2 $lt 1.0 + + 1.0_p1 $gt 1.0 + 1.0_p1-r1 $gt 1.0_p1 + + 1.0_alpha6-r1 $gt 1.0_alpha6 + 1.0_beta6-r1 $gt 1.0_alpha6-r2 + + 1.0_pre1 $lt 1.0_p1 + + 1.0p $gt 1.0_p1 + 1.0r $gt 1.0-r1 + 1.6.15 $gt 1.6.10-r2 + 1.6.10-r2 $lt 1.6.15 + +" | while read a b c ; do + [[ -z "${a}${b}${c}" ]] && continue + test_version_compare "${a}" "${b}" "${c}" +done + + +for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}" ; do + for p in ${q%%=*} ; do + c=${q##*=} + alt=${c%%;*} agt=${c##*;} + test_version_compare "1.0" $agt "1.0_${p}" + test_version_compare "1.0" $agt "1.0_${p}1" + test_version_compare "1.0" $agt "1.0_${p}068" + + test_version_compare "2.0_${p}" $alt "2.0" + test_version_compare "2.0_${p}1" $alt "2.0" + test_version_compare "2.0_${p}068" $alt "2.0" + + test_version_compare "1.0_${p}" $eq "1.0_${p}" + test_version_compare "0.0_${p}" $lt "0.0_${p}1" + test_version_compare "666_${p}3" $gt "666_${p}" + + test_version_compare "1_${p}7" $lt "1_${p}8" + test_version_compare "1_${p}7" $eq "1_${p}7" + test_version_compare "1_${p}7" $gt "1_${p}6" + test_version_compare "1_${p}09" $eq "1_${p}9" + + test_version_compare "1_${p}7-r0" $eq "1_${p}7" + test_version_compare "1_${p}7-r0" $lt "1_${p}7-r1" + test_version_compare "1_${p}7-r0" $lt "1_${p}7-r01" + test_version_compare "1_${p}7-r01" $eq "1_${p}7-r1" + test_version_compare "1_${p}8-r1" $gt "1_${p}7-r100" + + test_version_compare "1_${p}_alpha" $lt "1_${p}_beta" + done +done + +for p in "-r" "_p" ; do + test_version_compare "7.2${p}1" $lt "7.2${p}2" + test_version_compare "7.2${p}2" $gt "7.2${p}1" + test_version_compare "7.2${p}3" $gt "7.2${p}2" + test_version_compare "7.2${p}2" $lt "7.2${p}3" +done + +# The following tests all come from portage's test cases: +test_version_compare "6.0" $gt "5.0" +test_version_compare "5.0" $gt "5" +test_version_compare "1.0-r1" $gt "1.0-r0" +test_version_compare "1.0-r1" $gt "1.0" +test_version_compare "999999999999999999999999999999" $gt "999999999999999999999999999998" +test_version_compare "1.0.0" $gt "1.0" +test_version_compare "1.0.0" $gt "1.0b" +test_version_compare "1b" $gt "1" +test_version_compare "1b_p1" $gt "1_p1" +test_version_compare "1.1b" $gt "1.1" +test_version_compare "12.2.5" $gt "12.2b" + +test_version_compare "4.0" $lt "5.0" +test_version_compare "5" $lt "5.0" +test_version_compare "1.0_pre2" $lt "1.0_p2" +test_version_compare "1.0_alpha2" $lt "1.0_p2" +test_version_compare "1.0_alpha1" $lt "1.0_beta1" +test_version_compare "1.0_beta3" $lt "1.0_rc3" +test_version_compare "1.001000000000000000001" $lt "1.001000000000000000002" +test_version_compare "1.00100000000" $lt "1.0010000000000000001" +test_version_compare "999999999999999999999999999998" $lt "999999999999999999999999999999" +test_version_compare "1.01" $lt "1.1" +test_version_compare "1.0-r0" $lt "1.0-r1" +test_version_compare "1.0" $lt "1.0-r1" +test_version_compare "1.0" $lt "1.0.0" +test_version_compare "1.0b" $lt "1.0.0" +test_version_compare "1_p1" $lt "1b_p1" +test_version_compare "1" $lt "1b" +test_version_compare "1.1" $lt "1.1b" +test_version_compare "12.2b" $lt "12.2.5" + +test_version_compare "4.0" $eq "4.0" +test_version_compare "1.0" $eq "1.0" +test_version_compare "1.0-r0" $eq "1.0" +test_version_compare "1.0" $eq "1.0-r0" +test_version_compare "1.0-r0" $eq "1.0-r0" +test_version_compare "1.0-r1" $eq "1.0-r1" + +# The following were just tests for != in portage, we need something a bit +# more precise +test_version_compare "1" $lt "2" +test_version_compare "1.0_alpha" $lt "1.0_pre" +test_version_compare "1.0_beta" $gt "1.0_alpha" +test_version_compare "0" $lt "0.0" +test_version_compare "1.0-r0" $lt "1.0-r1" +test_version_compare "1.0-r1" $gt "1.0-r0" +test_version_compare "1.0" $lt "1.0-r1" +test_version_compare "1.0-r1" $gt "1.0" +test_version_compare "1_p1" $lt "1b_p1" +test_version_compare "1b" $gt "1" +test_version_compare "1.1b" $gt "1.1" +test_version_compare "12.2b" $gt "12.2" + +# The following tests all come from paludis's test cases: +test_version_compare "1.0" $gt "1" +test_version_compare "1" $lt "1.0" +test_version_compare "1.0_alpha" $gt "1_alpha" +test_version_compare "1.0_alpha" $gt "1" +test_version_compare "1.0_alpha" $lt "1.0" +test_version_compare "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4" + +test_version_compare "0001" $eq "1" +test_version_compare "01" $eq "001" +test_version_compare "0001.1" $eq "1.1" +test_version_compare "01.01" $eq "1.01" +test_version_compare "1.010" $eq "1.01" +test_version_compare "1.00" $eq "1.0" +test_version_compare "1.0100" $eq "1.010" +test_version_compare "1" $eq "1-r0" +test_version_compare "1-r00" $eq "1-r0" + +eshopts_pop + +texit |