From bce7eb253a5e2344c5a3a37f53cf971c8df8ce1d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 20:02:26 +0200 Subject: add some sample PKGBUILDs --- test/packages/pkg-any-a/PKGBUILD | 11 +++++++++++ test/packages/pkg-any-b/PKGBUILD | 11 +++++++++++ test/packages/pkg-simple-a/PKGBUILD | 11 +++++++++++ test/packages/pkg-simple-b/PKGBUILD | 11 +++++++++++ test/packages/pkg-split-a/PKGBUILD | 16 ++++++++++++++++ test/packages/pkg-split-b/PKGBUILD | 16 ++++++++++++++++ 6 files changed, 76 insertions(+) create mode 100644 test/packages/pkg-any-a/PKGBUILD create mode 100644 test/packages/pkg-any-b/PKGBUILD create mode 100644 test/packages/pkg-simple-a/PKGBUILD create mode 100644 test/packages/pkg-simple-b/PKGBUILD create mode 100644 test/packages/pkg-split-a/PKGBUILD create mode 100644 test/packages/pkg-split-b/PKGBUILD (limited to 'test') diff --git a/test/packages/pkg-any-a/PKGBUILD b/test/packages/pkg-any-a/PKGBUILD new file mode 100644 index 0000000..348bc4b --- /dev/null +++ b/test/packages/pkg-any-a/PKGBUILD @@ -0,0 +1,11 @@ +pkgname=pkg-any-a +pkgver=1 +pkgrel=1 +pkgdesc="A package called ${pkgname}" +arch=('any') +url='http://www.archlinux.org/' +license=('GPL') + +package() { + true +} diff --git a/test/packages/pkg-any-b/PKGBUILD b/test/packages/pkg-any-b/PKGBUILD new file mode 100644 index 0000000..fd42748 --- /dev/null +++ b/test/packages/pkg-any-b/PKGBUILD @@ -0,0 +1,11 @@ +pkgname=pkg-any-b +pkgver=1 +pkgrel=1 +pkgdesc="A package called ${pkgname}" +arch=('any') +url='http://www.archlinux.org/' +license=('GPL') + +package() { + true +} diff --git a/test/packages/pkg-simple-a/PKGBUILD b/test/packages/pkg-simple-a/PKGBUILD new file mode 100644 index 0000000..78f3c8e --- /dev/null +++ b/test/packages/pkg-simple-a/PKGBUILD @@ -0,0 +1,11 @@ +pkgname=pkg-simple-a +pkgver=1 +pkgrel=1 +pkgdesc="A package called ${pkgname}" +arch=('i686' 'x86_64') +url='http://www.archlinux.org/' +license=('GPL') + +package() { + true +} diff --git a/test/packages/pkg-simple-b/PKGBUILD b/test/packages/pkg-simple-b/PKGBUILD new file mode 100644 index 0000000..1ef298e --- /dev/null +++ b/test/packages/pkg-simple-b/PKGBUILD @@ -0,0 +1,11 @@ +pkgname=pkg-simple-b +pkgver=1 +pkgrel=1 +pkgdesc="A package called ${pkgname}" +arch=('i686' 'x86_64') +url='http://www.archlinux.org/' +license=('GPL') + +package() { + true +} diff --git a/test/packages/pkg-split-a/PKGBUILD b/test/packages/pkg-split-a/PKGBUILD new file mode 100644 index 0000000..6ac77ea --- /dev/null +++ b/test/packages/pkg-split-a/PKGBUILD @@ -0,0 +1,16 @@ +pkgbase=pkg-split-a +pkgname=('pkg-split-a1' 'pkg-split-a2') +pkgver=1 +pkgrel=1 +pkgdesc="A split package called ${pkgbase}" +arch=('i686' 'x86_64') +url='http://www.archlinux.org/' +license=('GPL') + +package_pkg-split-a1() { + true +} + +package_pkg-split-a2() { + true +} diff --git a/test/packages/pkg-split-b/PKGBUILD b/test/packages/pkg-split-b/PKGBUILD new file mode 100644 index 0000000..e1817b7 --- /dev/null +++ b/test/packages/pkg-split-b/PKGBUILD @@ -0,0 +1,16 @@ +pkgbase=pkg-split-b +pkgname=('pkg-split-b1' 'pkg-split-b2') +pkgver=1 +pkgrel=1 +pkgdesc="A split package called ${pkgbase}" +arch=('i686' 'x86_64') +url='http://www.archlinux.org/' +license=('GPL') + +package_pkg-split-b1() { + true +} + +package_pkg-split-b2() { + true +} -- cgit v1.2.3 From bf064423e1f5d60c76940c3b8b4130921dbaa0d7 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 20:02:42 +0200 Subject: add a local copy of shunit2 This is a local copy of shUnit 2.1.5 from http://shunit2.googlecode.com/ License: LGPL --- test/lib/shunit2 | 1116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1116 insertions(+) create mode 100644 test/lib/shunit2 (limited to 'test') diff --git a/test/lib/shunit2 b/test/lib/shunit2 new file mode 100644 index 0000000..d900a70 --- /dev/null +++ b/test/lib/shunit2 @@ -0,0 +1,1116 @@ +# $Id: shunit2 277 2008-10-29 21:20:22Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# vim:foldmethod=marker:foldmarker=/**,*/ +# +#/** +# +# +# +# shUnit 2.1.5 +# Shell Unit Test Framework +# +# http://shunit2.googlecode.com/ +# +# written by Kate Ward <kate.ward@forestent.com> +# released under the LGPL +# +# This module implements a xUnit based unit test framework similar to JUnit. +# +#*/ + +SHUNIT_VERSION='2.1.5' + +SHUNIT_TRUE=0 +SHUNIT_FALSE=1 +SHUNIT_ERROR=2 + +_shunit_warn() { echo "shunit2:WARN $@" >&2; } +_shunit_error() { echo "shunit2:ERROR $@" >&2; } +_shunit_fatal() { echo "shunit2:FATAL $@" >&2; } + +# specific shell checks +if [ -n "${ZSH_VERSION:-}" ]; then + setopt |grep "^shwordsplit$" >/dev/null + if [ $? -ne ${SHUNIT_TRUE} ]; then + _shunit_fatal 'zsh shwordsplit option is required for proper operation' + exit ${SHUNIT_ERROR} + fi + if [ -z "${SHUNIT_PARENT:-}" ]; then + _shunit_fatal "zsh does not pass \$0 through properly. please declare \ +\"SHUNIT_PARENT=\$0\" before calling shUnit2" + exit ${SHUNIT_ERROR} + fi +fi + +# +# constants +# + +__SHUNIT_ASSERT_MSG_PREFIX='ASSERT:' +__SHUNIT_PARENT=${SHUNIT_PARENT:-$0} + +# set the constants readonly +shunit_constants_=`set |grep '^__SHUNIT_' |cut -d= -f1` +echo "${shunit_constants_}" |grep '^Binary file' >/dev/null \ + && shunit_constants_=`set |grep -a '^__SHUNIT_' |cut -d= -f1` +for shunit_constant_ in ${shunit_constants_}; do + shunit_ro_opts_='' + case ${ZSH_VERSION:-} in + '') ;; # this isn't zsh + [123].*) ;; # early versions (1.x, 2.x, 3.x) + *) shunit_ro_opts_='-g' ;; # all later versions. declare readonly globally + esac + readonly ${shunit_ro_opts_} ${shunit_constant_} +done +unset shunit_constant_ shunit_constants_ shunit_ro_opts_ + +# variables +__shunit_skip=${SHUNIT_FALSE} +__shunit_suite='' + +# counts of tests +__shunit_testSuccess=${SHUNIT_TRUE} +__shunit_testsTotal=0 +__shunit_testsPassed=0 +__shunit_testsFailed=0 + +# counts of asserts +__shunit_assertsTotal=0 +__shunit_assertsPassed=0 +__shunit_assertsFailed=0 +__shunit_assertsSkipped=0 + +__shunit_lineno='' +__shunit_reportGenerated=${SHUNIT_FALSE} + +# macros +_SHUNIT_LINENO_='eval __shunit_lineno=""; if [ "${1:-}" = "--lineno" ]; then [ -n "$2" ] && __shunit_lineno="[$2] "; shift 2; fi' + +#----------------------------------------------------------------------------- +# assert functions +# + +#/** +# +# +# void +# +# +# +# +# assertEquals +# string [message] +# string expected +# string actual +# +# +# Asserts that expected and +# actual are equal to one another. The message is +# optional. +# +# +#*/ +assertEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertEquals() requires two or three arguments; $# given" + _shunit_error "1: ${1:+$1} 2: ${2:+$2} 3: ${3:+$3}" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_expected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_expected_}" = "${shunit_actual_}" ]; then + _shunit_assertPass + else + failNotEquals "${shunit_message_}" "${shunit_expected_}" "${shunit_actual_}" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_expected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_EQUALS_='eval assertEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotEquals +# string [message] +# string unexpected +# string actual +# +# +# Asserts that unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +assertNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotEquals() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_unexpected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_unexpected_}" != "${shunit_actual_}" ]; then + _shunit_assertPass + else + failSame "${shunit_message_}" "$@" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_unexpected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_NOT_EQUALS_='eval assertNotEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNull +# string [message] +# string value +# +# +# Asserts that value is null, +# or in shell terms a zero-length string. The message is optional. +# +# +#*/ +assertNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertTrue "${shunit_message_}" "[ -z '$1' ]" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NULL_='eval assertNull --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotNull +# string [message] +# string value +# +# +# Asserts that value is not null, or in shell terms not +# a zero-length string. The message is optional. +# +# +#*/ +assertNotNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 2 ]; then # allowing 0 arguments as $1 might actually be null + _shunit_error "assertNotNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertTrue "${shunit_message_}" "[ -n '${1:-}' ]" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_NULL_='eval assertNotNull --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertSame +# string [message] +# string expected +# string actual +# +# +# This function is functionally equivalent to +# assertEquals. +# +# +#*/ +assertSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertSame() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_SAME_='eval assertSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotSame +# string [message] +# string unexpected +# string actual +# +# +# Asserts that unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +assertNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_:-}$1" + shift + fi + assertNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_SAME_='eval assertNotSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertTrue +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is true. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertTrue "[ 34 -gt 23 ]" +# The folloing test will fail with a message: assertTrue "test failed" "[ -r '/non/existant/file' ]" +# +# +# +#*/ +assertTrue() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 2 ]; then + _shunit_error "assertTrue() takes one two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ "${shunit_condition_}" = "${shunit_match_}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -ne 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -ne 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_TRUE_='eval assertTrue --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertFalse +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is false. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertFalse "[ 'apples' = 'oranges' ]" +# The folloing test will fail with a message: assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]" +# +# +# +#*/ +assertFalse() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertFalse() quires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ "${shunit_condition_}" = "${shunit_match_}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -eq 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -eq 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_FALSE_='eval assertFalse --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# failure functions +# + +#/** +# +# +# void +# +# +# +# +# fail +# string [message] +# +# +# Fails the test immediately, with the optional message. +# +# +#*/ +fail() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 1 ]; then + _shunit_error "fail() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 1 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_}" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_='eval fail --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failNotEquals +# string [message] +# string unexpected +# string actual +# +# +# Fails the test if unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +failNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_unexpected_=$1 + shunit_actual_=$2 + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected:<${shunit_unexpected_}> but was:<${shunit_actual_}>" + + unset shunit_message_ shunit_unexpected_ shunit_actual_ + return ${SHUNIT_FALSE} +} +_FAIL_NOT_EQUALS_='eval failNotEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failSame +# string [message] +# +# +# Indicate test failure because arguments were the same. The message is +# optional. +# +# +#*/ +failSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected not same" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_SAME_='eval failSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failNotSame +# string [message] +# string expected +# string actual +# +# +# Indicate test failure because arguments were not the same. The +# message is optional. +# +# +#*/ +failNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + failNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_FAIL_NOT_SAME_='eval failNotSame --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# skipping functions +# + +#/** +# +# +# void +# +# +# +# +# startSkipping +# +# +# +# This function forces the remaining assert and fail functions to be +# "skipped", i.e. they will have no effect. Each function skipped will be +# recorded so that the total of asserts and fails will not be altered. +# +# +#*/ +startSkipping() +{ + __shunit_skip=${SHUNIT_TRUE} +} + +#/** +# +# +# void +# +# +# +# +# endSkipping +# +# +# +# This function returns calls to the assert and fail functions to their +# default behavior, i.e. they will be called. +# +# +#*/ +endSkipping() +{ + __shunit_skip=${SHUNIT_FALSE} +} + +#/** +# +# +# boolean +# +# +# +# +# isSkipping +# +# +# +# This function returns the state of skipping. +# +# +#*/ +isSkipping() +{ + return ${__shunit_skip} +} + +#----------------------------------------------------------------------------- +# suite functions +# + +#/** +# +# +# void +# +# +# +# +# suite +# +# +# +# This function can be optionally overridden by the user in their test +# suite. +# If this function exists, it will be called when +# shunit2 is sourced. If it does not exist, shUnit2 will +# search the parent script for all functions beginning with the word +# test, and they will be added dynamically to the test +# suite. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# suite() { :; } + +#/** +# +# +# void +# +# +# +# +# suite_addTest +# string function +# +# +# This function adds a function name to the list of tests scheduled for +# execution as part of this test suite. This function should only be called +# from within the suite() function. +# +# +#*/ +suite_addTest() +{ + shunit_func_=${1:-} + + __shunit_suite="${__shunit_suite:+${__shunit_suite} }${shunit_func_}" + __shunit_testsTotal=`expr ${__shunit_testsTotal} + 1` + + unset shunit_func_ +} + +#/** +# +# +# void +# +# +# +# +# oneTimeSetUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once before any tests are +# run. It is useful to prepare a common environment for all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeSetUp() { :; } + +#/** +# +# +# void +# +# +# +# +# oneTimeTearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once after all tests are +# completed. It is useful to clean up the environment after all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeTearDown() { :; } + +#/** +# +# +# void +# +# +# +# +# setUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called before each test is run. +# It is useful to reset the environment before each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# setUp() { :; } + +#/** +# +# +# void +# +# +# +# +# tearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called after each test completes. +# It is useful to clean up the environment after each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# tearDown() { :; } + +#------------------------------------------------------------------------------ +# internal shUnit2 functions +# + +# this function is a cross-platform temporary directory creation tool. not all +# OSes have the mktemp function, so one is included here. +_shunit_mktempDir() +{ + # try the standard mktemp function + ( exec mktemp -dqt shunit.XXXXXX 2>/dev/null ) && return + + # the standard mktemp didn't work. doing our own. + if [ -r '/dev/urandom' ]; then + _shunit_random_=`od -vAn -N4 -tx4 "${_shunit_file_}" +#! /bin/sh +exit ${SHUNIT_TRUE} +EOF + chmod +x "${_shunit_file_}" + done + + unset _shunit_file_ +} + +_shunit_cleanup() +{ + _shunit_name_=$1 + + case ${_shunit_name_} in + EXIT) _shunit_signal_=0 ;; + INT) _shunit_signal_=2 ;; + TERM) _shunit_signal_=15 ;; + *) + _shunit_warn "unrecognized trap value (${_shunit_name_})" + _shunit_signal_=0 + ;; + esac + + # do our work + rm -fr "${__shunit_tmpDir}" + + # exit for all non-EXIT signals + if [ ${_shunit_name_} != 'EXIT' ]; then + _shunit_warn "trapped and now handling the (${_shunit_name_}) signal" + # disable EXIT trap + trap 0 + # add 128 to signal and exit + exit `expr ${_shunit_signal_} + 128` + elif [ ${__shunit_reportGenerated} -eq ${SHUNIT_FALSE} ] ; then + _shunit_assertFail 'Unknown failure encountered running a test' + _shunit_generateReport + exit ${SHUNIT_ERROR} + fi + + unset _shunit_name_ _shunit_signal_ +} + +# The actual running of the tests happens here. +_shunit_execSuite() +{ + for _shunit_test_ in ${__shunit_suite}; do + __shunit_testSuccess=${SHUNIT_TRUE} + + # disable skipping + endSkipping + + # execute the per-test setup function + setUp + + # execute the test + echo "${_shunit_test_}" + eval ${_shunit_test_} + + # execute the per-test tear-down function + tearDown + + # update stats + if [ ${__shunit_testSuccess} -eq ${SHUNIT_TRUE} ]; then + __shunit_testsPassed=`expr ${__shunit_testsPassed} + 1` + else + __shunit_testsFailed=`expr ${__shunit_testsFailed} + 1` + fi + done + + unset _shunit_test_ +} + +# This function exits shUnit2 with the appropriate error code and OK/FAILED +# message. +_shunit_generateReport() +{ + _shunit_ok_=${SHUNIT_TRUE} + + # if no exit code was provided one, determine an appropriate one + [ ${__shunit_testsFailed} -gt 0 \ + -o ${__shunit_testSuccess} -eq ${SHUNIT_FALSE} ] \ + && _shunit_ok_=${SHUNIT_FALSE} + + echo + if [ ${__shunit_testsTotal} -eq 1 ]; then + echo "Ran ${__shunit_testsTotal} test." + else + echo "Ran ${__shunit_testsTotal} tests." + fi + + _shunit_failures_='' + _shunit_skipped_='' + [ ${__shunit_assertsFailed} -gt 0 ] \ + && _shunit_failures_="failures=${__shunit_assertsFailed}" + [ ${__shunit_assertsSkipped} -gt 0 ] \ + && _shunit_skipped_="skipped=${__shunit_assertsSkipped}" + + if [ ${_shunit_ok_} -eq ${SHUNIT_TRUE} ]; then + _shunit_msg_='OK' + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_} (${_shunit_skipped_})" + else + _shunit_msg_="FAILED (${_shunit_failures_}" + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_},${_shunit_skipped_}" + _shunit_msg_="${_shunit_msg_})" + fi + + echo + echo ${_shunit_msg_} + __shunit_reportGenerated=${SHUNIT_TRUE} + + unset _shunit_failures_ _shunit_msg_ _shunit_ok_ _shunit_skipped_ +} + +_shunit_shouldSkip() +{ + [ ${__shunit_skip} -eq ${SHUNIT_FALSE} ] && return ${SHUNIT_FALSE} + _shunit_assertSkip +} + +_shunit_assertPass() +{ + __shunit_assertsPassed=`expr ${__shunit_assertsPassed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +_shunit_assertFail() +{ + _shunit_msg_=$1 + + __shunit_testSuccess=${SHUNIT_FALSE} + __shunit_assertsFailed=`expr ${__shunit_assertsFailed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` + echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}" + + unset _shunit_msg_ +} + +_shunit_assertSkip() +{ + __shunit_assertsSkipped=`expr ${__shunit_assertsSkipped} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +#------------------------------------------------------------------------------ +# main +# + +# create a temporary storage location +__shunit_tmpDir=`_shunit_mktempDir` + +# provide a public temporary directory for unit test scripts +# TODO(kward): document this +shunit_tmpDir="${__shunit_tmpDir}/tmp" +mkdir "${shunit_tmpDir}" + +# setup traps to clean up after ourselves +trap '_shunit_cleanup EXIT' 0 +trap '_shunit_cleanup INT' 2 +trap '_shunit_cleanup TERM' 15 + +# create phantom functions to work around issues with Cygwin +_shunit_mktempFunc +PATH="${__shunit_tmpDir}:${PATH}" + +# execute the oneTimeSetUp function (if it exists) +oneTimeSetUp + +# execute the suite function defined in the parent test script +# deprecated as of 2.1.0 +suite + +# if no suite function was defined, dynamically build a list of functions +if [ -z "${__shunit_suite}" ]; then + shunit_funcs_=`grep "^[ \t]*test[A-Za-z0-9_]* *()" ${__SHUNIT_PARENT} \ + |sed 's/[^A-Za-z0-9_]//g'` + for shunit_func_ in ${shunit_funcs_}; do + suite_addTest ${shunit_func_} + done +fi +unset shunit_func_ shunit_funcs_ + +# execute the tests +_shunit_execSuite + +# execute the oneTimeTearDown function (if it exists) +oneTimeTearDown + +# generate the report +_shunit_generateReport + +# that's it folks +[ ${__shunit_testsFailed} -eq 0 ] +exit $? + +#/** +# +#*/ -- cgit v1.2.3 From 266d9d35240e84393b2ffc4ec40d96dcdac1f87f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 20:04:40 +0200 Subject: add default makepkg.conf for both arches --- test/lib/makepkg-i686.conf | 115 +++++++++++++++++++++++++++++++++++++++++++ test/lib/makepkg-x86_64.conf | 115 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 test/lib/makepkg-i686.conf create mode 100644 test/lib/makepkg-x86_64.conf (limited to 'test') diff --git a/test/lib/makepkg-i686.conf b/test/lib/makepkg-i686.conf new file mode 100644 index 0000000..553f943 --- /dev/null +++ b/test/lib/makepkg-i686.conf @@ -0,0 +1,115 @@ +# +# /etc/makepkg.conf +# + +######################################################################### +# SOURCE ACQUISITION +######################################################################### +# +#-- The download utilities that makepkg should use to acquire sources +# Format: 'protocol::agent' +DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u' + 'http::/usr/bin/wget -c -t 3 --waitretry=3 -O %o %u' + 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate -O %o %u' + 'rsync::/usr/bin/rsync -z %u %o' + 'scp::/usr/bin/scp -C %u %o') + +# Other common tools: +# /usr/bin/snarf +# /usr/bin/lftpget -c +# /usr/bin/curl + +######################################################################### +# ARCHITECTURE, COMPILE FLAGS +######################################################################### +# +CARCH="i686" +CHOST="i686-pc-linux-gnu" + +#-- Exclusive: will only run on i686 +# -march (or -mcpu) builds exclusively for an architecture +# -mtune optimizes for an architecture, but builds for whole processor family +CFLAGS="-march=i686 -mtune=generic -O2 -pipe" +CXXFLAGS="-march=i686 -mtune=generic -O2 -pipe" +LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed" +#-- Make Flags: change this for DistCC/SMP systems +#MAKEFLAGS="-j2" + +######################################################################### +# BUILD ENVIRONMENT +######################################################################### +# +# Defaults: BUILDENV=(fakeroot !distcc color !ccache) +# A negated environment option will do the opposite of the comments below. +# +#-- fakeroot: Allow building packages as a non-root user +#-- distcc: Use the Distributed C/C++/ObjC compiler +#-- color: Colorize output messages +#-- ccache: Use ccache to cache compilation +# +BUILDENV=(fakeroot !distcc color !ccache) +# +#-- If using DistCC, your MAKEFLAGS will also need modification. In addition, +#-- specify a space-delimited list of hosts running in the DistCC cluster. +#DISTCC_HOSTS="" + +######################################################################### +# GLOBAL PACKAGE OPTIONS +# These are default values for the options=() settings +######################################################################### +# +# Default: OPTIONS=(strip docs libtool emptydirs zipman purge) +# A negated option will do the opposite of the comments below. +# +#-- strip: Strip symbols from binaries/libraries in STRIP_DIRS +#-- docs: Save doc directories specified by DOC_DIRS +#-- libtool: Leave libtool (.la) files in packages +#-- emptydirs: Leave empty directories in packages +#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip +#-- purge: Remove files specified by PURGE_TARGETS +# +OPTIONS=(strip docs libtool emptydirs zipman purge) + +#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 +INTEGRITY_CHECK=(md5) +#-- Options to be used when stripping binaries. See `man strip' for details. +STRIP_BINARIES="--strip-all" +#-- Options to be used when stripping shared libraries. See `man strip' for details. +STRIP_SHARED="--strip-unneeded" +#-- Options to be used when stripping static libraries. See `man strip' for details. +STRIP_STATIC="--strip-debug" +#-- Manual (man and info) directories to compress (if zipman is specified) +MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) +#-- Doc directories to remove (if !docs is specified) +DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) +#-- Directories to be searched for the strip option (if strip is specified) +STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin}) +#-- Files to be removed from all packages (if purge is specified) +PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) + +######################################################################### +# PACKAGE OUTPUT +######################################################################### +# +# Default: put built package and cached source in build directory +# +#-- Destination: specify a fixed directory where all packages will be placed +#PKGDEST=/home/packages +#-- Source cache: specify a fixed directory where source files will be cached +#SRCDEST=/home/sources +#-- Source packages: specify a fixed directory where all src packages will be placed +#SRCPKGDEST=/home/srcpackages +#-- Packager: name/email of the person or organization building packages +#PACKAGER="John Doe " + +######################################################################### +# EXTENSION DEFAULTS +######################################################################### +# +# WARNING: Do NOT modify these variables unless you know what you are +# doing. +# +PKGEXT='.pkg.tar.xz' +SRCEXT='.src.tar.gz' + +# vim: set ft=sh ts=2 sw=2 et: diff --git a/test/lib/makepkg-x86_64.conf b/test/lib/makepkg-x86_64.conf new file mode 100644 index 0000000..e53375f --- /dev/null +++ b/test/lib/makepkg-x86_64.conf @@ -0,0 +1,115 @@ +# +# /etc/makepkg.conf +# + +######################################################################### +# SOURCE ACQUISITION +######################################################################### +# +#-- The download utilities that makepkg should use to acquire sources +# Format: 'protocol::agent' +DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u' + 'http::/usr/bin/wget -c -t 3 --waitretry=3 -O %o %u' + 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate -O %o %u' + 'rsync::/usr/bin/rsync -z %u %o' + 'scp::/usr/bin/scp -C %u %o') + +# Other common tools: +# /usr/bin/snarf +# /usr/bin/lftpget -c +# /usr/bin/curl + +######################################################################### +# ARCHITECTURE, COMPILE FLAGS +######################################################################### +# +CARCH="x86_64" +CHOST="x86_64-unknown-linux-gnu" + +#-- Exclusive: will only run on x86_64 +# -march (or -mcpu) builds exclusively for an architecture +# -mtune optimizes for an architecture, but builds for whole processor family +CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" +CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" +LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed" +#-- Make Flags: change this for DistCC/SMP systems +#MAKEFLAGS="-j2" + +######################################################################### +# BUILD ENVIRONMENT +######################################################################### +# +# Defaults: BUILDENV=(fakeroot !distcc color !ccache) +# A negated environment option will do the opposite of the comments below. +# +#-- fakeroot: Allow building packages as a non-root user +#-- distcc: Use the Distributed C/C++/ObjC compiler +#-- color: Colorize output messages +#-- ccache: Use ccache to cache compilation +# +BUILDENV=(fakeroot !distcc color !ccache) +# +#-- If using DistCC, your MAKEFLAGS will also need modification. In addition, +#-- specify a space-delimited list of hosts running in the DistCC cluster. +#DISTCC_HOSTS="" + +######################################################################### +# GLOBAL PACKAGE OPTIONS +# These are default values for the options=() settings +######################################################################### +# +# Default: OPTIONS=(strip docs libtool emptydirs zipman purge) +# A negated option will do the opposite of the comments below. +# +#-- strip: Strip symbols from binaries/libraries in STRIP_DIRS +#-- docs: Save doc directories specified by DOC_DIRS +#-- libtool: Leave libtool (.la) files in packages +#-- emptydirs: Leave empty directories in packages +#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip +#-- purge: Remove files specified by PURGE_TARGETS +# +OPTIONS=(strip docs libtool emptydirs zipman purge) + +#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 +INTEGRITY_CHECK=(md5) +#-- Options to be used when stripping binaries. See `man strip' for details. +STRIP_BINARIES="--strip-all" +#-- Options to be used when stripping shared libraries. See `man strip' for details. +STRIP_SHARED="--strip-unneeded" +#-- Options to be used when stripping static libraries. See `man strip' for details. +STRIP_STATIC="--strip-debug" +#-- Manual (man and info) directories to compress (if zipman is specified) +MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) +#-- Doc directories to remove (if !docs is specified) +DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) +#-- Directories to be searched for the strip option (if strip is specified) +STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin}) +#-- Files to be removed from all packages (if purge is specified) +PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) + +######################################################################### +# PACKAGE OUTPUT +######################################################################### +# +# Default: put built package and cached source in build directory +# +#-- Destination: specify a fixed directory where all packages will be placed +#PKGDEST=/home/packages +#-- Source cache: specify a fixed directory where source files will be cached +#SRCDEST=/home/sources +#-- Source packages: specify a fixed directory where all src packages will be placed +#SRCPKGDEST=/home/srcpackages +#-- Packager: name/email of the person or organization building packages +#PACKAGER="John Doe " + +######################################################################### +# EXTENSION DEFAULTS +######################################################################### +# +# WARNING: Do NOT modify these variables unless you know what you are +# doing. +# +PKGEXT='.pkg.tar.xz' +SRCEXT='.src.tar.gz' + +# vim: set ft=sh ts=2 sw=2 et: -- cgit v1.2.3 From 1d903977850d8e8a22f8246994e72b0ef101eb76 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 20:05:09 +0200 Subject: add some common functions for our test suite --- test/lib/common.inc | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/lib/common.inc (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc new file mode 100644 index 0000000..5abe2ed --- /dev/null +++ b/test/lib/common.inc @@ -0,0 +1,113 @@ +pkgdir="$(dirname $0)/packages" + +oneTimeSetUp() { + local p + echo -n 'Building packages...' + for p in "${pkgdir}"/*; do + pushd $p >/dev/null + linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || exit 1 + linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1 + popd >/dev/null + done + echo 'done' + echo +} + +oneTimeTearDown() { + find "${pkgdir}" -name '*.pkg.tar.*' -delete +} + +setUp() { + local p + local pkg + + [ -f "${curdir}/../config.local" ] && exit 1 + TMP="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)" + #echo "Using ${TMP}" + + mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} + mkdir -p "${TMP}/ftp/"{{core,extra,community,testing,community-testing}/os,packages/{arch,community}}/{i686,any,x86_64} + mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} + + echo -n 'Creating svn repository...' + svnadmin create "${TMP}/svn-packages-repo" + svnadmin create "${TMP}/svn-community-repo" + svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" + svn checkout -q "file://${TMP}/svn-community-repo" "${TMP}/svn-community-copy" + + for p in "${pkgdir}"/*; do + pkg=$(basename $p) + mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} + cp "${p}/PKGBUILD" "${TMP}/svn-packages-copy"/${pkg}/trunk/ + svn add -q "${TMP}/svn-packages-copy"/${pkg} + svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" + done + echo 'done' + + cat < "${curdir}/../config.local" + FTP_BASE="${TMP}/ftp" + SVNREPO="file://${TMP}/svn-packages-repo" + SVNREPOCOMMUNITY="file://${TMP}/svn-community-repo" + CLEANUP_DESTDIR="${TMP}/package-cleanup" + SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" + STAGING="${TMP}/staging" + TMPDIR="${TMP}/tmp" +eot + . "${curdir}/../config" +} + +tearDown() { + rm -rf "${TMP}" + rm -f "${curdir}/../config.local" + echo +} + +testPackages() { + local p + for p in "${pkgdir}"/*; do + pushd $p >/dev/null + namcap *.pkg.tar.* || fail 'namcap failed' + popd >/dev/null + done +} + +releasePackage() { + local repo=$1 + local pkgbase=$2 + local arch=$3 + + pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null + archrelease ${repo}-${arch} >/dev/null + popd >/dev/null + cp "${pkgdir}/${pkgbase}"/*.pkg.tar.* "${STAGING}"/${repo}/ +} + +checkAnyPackage() { + local repo=$1 + local pkg=$2 + local arch + + [ -f "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "packages/arch/any/${pkg} not found" + + for arch in any i686 x86_64; do + [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/any/${pkg}" + done + [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" +} + +checkPackage() { + local repo=$1 + local pkg=$2 + local arch=$3 + + [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "packages/arch/${arch}/${pkg} not found" + [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" + [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}" + + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" +} -- cgit v1.2.3 From 66ae94cafb62da09da77712269f411f095dd81fc Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 20:05:58 +0200 Subject: add an initial set of tests --- test/runTest | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 test/runTest (limited to 'test') diff --git a/test/runTest b/test/runTest new file mode 100755 index 0000000..1d54ea4 --- /dev/null +++ b/test/runTest @@ -0,0 +1,66 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/lib/common.inc" + + +testAddSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + done + done +} + +testAddAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz + done +} + +testAddSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done + done +} + + +. "${curdir}/lib/shunit2" -- cgit v1.2.3 From bccf84211be4abda3c96ded43f03b597081fecb1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 21:21:08 +0200 Subject: add test for db-remove --- test/lib/common.inc | 13 +++------ test/runTest | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 5abe2ed..4052aa1 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,4 +1,4 @@ -pkgdir="$(dirname $0)/packages" +pkgdir="${curdir}/packages" oneTimeSetUp() { local p @@ -57,20 +57,13 @@ eot } tearDown() { + echo -n 'Cleaning up...' rm -rf "${TMP}" rm -f "${curdir}/../config.local" + echo 'done' echo } -testPackages() { - local p - for p in "${pkgdir}"/*; do - pushd $p >/dev/null - namcap *.pkg.tar.* || fail 'namcap failed' - popd >/dev/null - done -} - releasePackage() { local repo=$1 local pkgbase=$2 diff --git a/test/runTest b/test/runTest index 1d54ea4..258a181 100755 --- a/test/runTest +++ b/test/runTest @@ -3,6 +3,23 @@ curdir=$(readlink -e $(dirname $0)) . "${curdir}/lib/common.inc" +# +# self test +# + +testPackages() { + local p + for p in "${pkgdir}"/*; do + pushd $p >/dev/null + namcap *.pkg.tar.* || fail 'namcap failed' + popd >/dev/null + done +} + + +# +# db-update +# testAddSimplePackages() { local arches=('i686' 'x86_64') @@ -63,4 +80,65 @@ testAddSplitPackages() { } +# +# db-remove +# + +testRemovePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-remove ${pkgbase} extra ${arch} + done + done + + for arch in ${arches[@]}; do + [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty" + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-${arch} should not exist" + done + done +} + +testRemoveAnyPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + ../db-remove ${pkgbase} extra any + done + + for arch in ${arches[@]}; do + [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty" + done + + for pkgbase in ${pkgs[@]}; do + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-any" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-any should not exist" + done +} + + . "${curdir}/lib/shunit2" -- cgit v1.2.3 From 76ef37d1b1e03b0c517f8513b943474ea379738e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 23:48:03 +0200 Subject: Simplify tests and add tests for db-move --- test/lib/common.inc | 38 ++++++++++++++++++++--- test/runTest | 86 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 110 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 4052aa1..3ba715e 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,12 +1,14 @@ -pkgdir="${curdir}/packages" +. "${curdir}/../db-functions" oneTimeSetUp() { local p + pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" + cp -r ${curdir}/packages/* "${pkgdir}" echo -n 'Building packages...' for p in "${pkgdir}"/*; do pushd $p >/dev/null linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || exit 1 - linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1 + [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1 popd >/dev/null done echo 'done' @@ -22,7 +24,7 @@ setUp() { local pkg [ -f "${curdir}/../config.local" ] && exit 1 - TMP="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)" + TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #echo "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} @@ -82,7 +84,7 @@ checkAnyPackage() { [ -f "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "packages/arch/any/${pkg} not found" - for arch in any i686 x86_64; do + for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/any/${pkg}" done @@ -103,4 +105,32 @@ checkPackage() { [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}" bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" + + local pkgbase=$(getpkgbase "${FTP_BASE}/packages/arch/${arch}/${pkg}") + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" +} + +checkRemovedPackage() { + local repo=$1 + local pkgbase=$2 + local arch=$3 + + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz" + + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" } + +checkRemovedAnyPackage() { + local repo=$1 + local pkgbase=$2 + local arch + + for arch in i686 x86_64; do + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz" + done + + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" +} \ No newline at end of file diff --git a/test/runTest b/test/runTest index 258a181..c53b63c 100755 --- a/test/runTest +++ b/test/runTest @@ -103,20 +103,14 @@ testRemovePackages() { done done - for arch in ${arches[@]}; do - [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty" - done - for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-${arch} should not exist" + checkRemovedPackage extra ${pkgbase} ${arch} done done } testRemoveAnyPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase @@ -130,15 +124,87 @@ testRemoveAnyPackages() { ../db-remove ${pkgbase} extra any done + for pkgbase in ${pkgs[@]}; do + checkRemovedAnyPackage extra ${pkgbase} + done +} + + +# +# db-move +# + +testMoveSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update testing + + for arch in ${arches[@]}; do + ../db-move-draft pkg-simple-a testing extra ${arch} + done + for arch in ${arches[@]}; do - [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty" + checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + + checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch} done +} + +testMoveAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase for pkgbase in ${pkgs[@]}; do - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-any" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-any should not exist" + releasePackage testing ${pkgbase} any done + + ../db-update testing + ../db-move-draft pkg-any-a testing extra any + + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz + checkRemovedAnyPackage testing pkg-any-a + checkAnyPackage testing pkg-any-b-1-1-any.pkg.tar.xz } +testMoveSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update testing + + for arch in ${arches[@]}; do + ../db-move-draft pkg-split-a testing extra ${arch} + done + + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/pkg-split-b"/*-${arch}.pkg.tar.*; do + checkPackage testing $(basename ${pkg}) ${arch} + done + done + + checkRemovedAnyPackage testing pkg-split-a +} . "${curdir}/lib/shunit2" -- cgit v1.2.3 From 0cfcc705c755eda1911a8868b2214c6a56f8e064 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 00:00:34 +0200 Subject: Fix old call --- test/runTest | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index c53b63c..6a4f3de 100755 --- a/test/runTest +++ b/test/runTest @@ -148,7 +148,7 @@ testMoveSimplePackages() { ../db-update testing for arch in ${arches[@]}; do - ../db-move-draft pkg-simple-a testing extra ${arch} + ../db-move pkg-simple-a testing extra ${arch} done for arch in ${arches[@]}; do @@ -168,7 +168,7 @@ testMoveAnyPackages() { done ../db-update testing - ../db-move-draft pkg-any-a testing extra any + ../db-move pkg-any-a testing extra any checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -190,7 +190,7 @@ testMoveSplitPackages() { ../db-update testing for arch in ${arches[@]}; do - ../db-move-draft pkg-split-a testing extra ${arch} + ../db-move pkg-split-a testing extra ${arch} done for arch in ${arches[@]}; do -- cgit v1.2.3 From 23d4669b8e330d131b2f78cd5858b30a07478c8a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 00:33:46 +0200 Subject: Use package pool instead of $repo/os/any dirs --- test/lib/common.inc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 3ba715e..4080c38 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -91,6 +91,8 @@ checkAnyPackage() { [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" + + [ -f "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } checkPackage() { -- cgit v1.2.3 From 1db7071b222207d2d924a03a48d0745387f11c7b Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 01:26:11 +0200 Subject: add test for ftpdir-cleanup --- test/lib/common.inc | 3 +- test/runTest | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 4080c38..dd3022e 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -16,7 +16,7 @@ oneTimeSetUp() { } oneTimeTearDown() { - find "${pkgdir}" -name '*.pkg.tar.*' -delete + rm -rf "${pkgdir}" } setUp() { @@ -54,6 +54,7 @@ setUp() { SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" TMPDIR="${TMP}/tmp" + CLEANUP_DRYRUN=false eot . "${curdir}/../config" } diff --git a/test/runTest b/test/runTest index 6a4f3de..7136508 100755 --- a/test/runTest +++ b/test/runTest @@ -25,6 +25,7 @@ testAddSimplePackages() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase + local arch for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -61,6 +62,7 @@ testAddSplitPackages() { local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase + local arch for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -88,6 +90,7 @@ testRemovePackages() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') local pkgbase + local arch for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -138,6 +141,7 @@ testMoveSimplePackages() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase + local arch for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -180,6 +184,7 @@ testMoveSplitPackages() { local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase + local arch for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -207,4 +212,96 @@ testMoveSplitPackages() { checkRemovedAnyPackage testing pkg-split-a } + +# +# ftpdir-cleanup +# + +testCleanupSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-a extra ${arch} + done + + ../cron-jobs/ftpdir-cleanup + + for arch in ${arches[@]}; do + local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" + [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" + + local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" + checkPackage extra ${pkg2} ${arch} + done +} + +testCleanupAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + local arch='any' + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update extra + ../db-remove pkg-any-a extra any + ../cron-jobs/ftpdir-cleanup + + local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' + [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" + + local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" + checkAnyPackage extra ${pkg2} +} + +testCleanupSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-remove pkg-split-a extra ${arch} + done + done + + ../cron-jobs/ftpdir-cleanup + + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do + [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] && fail "packages/arch/${arch}/${pkg} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" + done + + for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done +} + + . "${curdir}/lib/shunit2" -- cgit v1.2.3 From 918eaba387411a2f447f1669f255bcd2fb681e94 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 02:51:51 +0200 Subject: add transitions tests Theses tests simulate the case of packages with the old repo layout and the new package pool layout. --- test/runTest | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index 7136508..d453493 100755 --- a/test/runTest +++ b/test/runTest @@ -303,5 +303,91 @@ testCleanupSplitPackages() { done } +# +# transition tests +# + +testMovePackagesWithoutPool() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgbase + local arch + local pkg + local old + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update testing + + # transform two packages to old style layout + for arch in ${arches[@]}; do + for old in 0 2; do + for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + done + done + done + + ../cron-jobs/ftpdir-cleanup + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-move ${pkgbase} testing extra ${arch} + done + done + + ../cron-jobs/ftpdir-cleanup + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + checkRemovedPackage testing ${pkgbase} ${arch} + done + done +} + +testMoveAnyPackagesWithoutPool() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + local arch + local pkg + + for pkgbase in ${pkgs[@]}; do + releasePackage testing ${pkgbase} any + done + + ../db-update testing + + # transform a package to old style layout + for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/packages/arch/any/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + for arch in i686 x86_64; do + ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + done + done + + ../cron-jobs/ftpdir-cleanup + + for pkgbase in ${pkgs[@]}; do + ../db-move ${pkgbase} testing extra any + done + + ../cron-jobs/ftpdir-cleanup + + for pkgbase in ${pkgs[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do + checkAnyPackage extra $(basename ${pkg}) + done + checkRemovedAnyPackage testing ${pkgbase} + done +} . "${curdir}/lib/shunit2" -- cgit v1.2.3 From c117d9048ae591401a79037222da7bf7bda85705 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 03:44:17 +0200 Subject: Reduce verbosity Only inform of errors and processes that might take longer. --- test/lib/common.inc | 4 +--- test/runTest | 14 +++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index dd3022e..2d2b612 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -60,10 +60,8 @@ eot } tearDown() { - echo -n 'Cleaning up...' rm -rf "${TMP}" rm -f "${curdir}/../config.local" - echo 'done' echo } @@ -73,7 +71,7 @@ releasePackage() { local arch=$3 pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null - archrelease ${repo}-${arch} >/dev/null + archrelease ${repo}-${arch} >/dev/null 2&>1 popd >/dev/null cp "${pkgdir}/${pkgbase}"/*.pkg.tar.* "${STAGING}"/${repo}/ } diff --git a/test/runTest b/test/runTest index d453493..b24b7ea 100755 --- a/test/runTest +++ b/test/runTest @@ -235,7 +235,7 @@ testCleanupSimplePackages() { ../db-remove pkg-simple-a extra ${arch} done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" @@ -258,7 +258,7 @@ testCleanupAnyPackages() { ../db-update extra ../db-remove pkg-any-a extra any - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" @@ -289,7 +289,7 @@ testCleanupSplitPackages() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do @@ -333,7 +333,7 @@ testMovePackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -341,7 +341,7 @@ testMovePackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -374,13 +374,13 @@ testMoveAnyPackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do ../db-move ${pkgbase} testing extra any done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do -- cgit v1.2.3 From cbe9204ce41a81086c7498360769a66cfe48ce34 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 11:29:16 +0200 Subject: Fix test and add some more checks --- test/runTest | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index b24b7ea..5bbea05 100755 --- a/test/runTest +++ b/test/runTest @@ -239,6 +239,7 @@ testCleanupSimplePackages() { for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" + checkRemovedPackage extra 'pkg-simple-a' ${arch} [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" @@ -261,6 +262,7 @@ testCleanupAnyPackages() { ../cron-jobs/ftpdir-cleanup >/dev/null local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' + checkRemovedAnyPackage extra 'pkg-any-a' [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" @@ -283,16 +285,15 @@ testCleanupSplitPackages() { ../db-update extra - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-remove pkg-split-a extra ${arch} - done + for arch in ${arches[@]}; do + ../db-remove ${pkgs[0]} extra ${arch} done ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do + checkRemovedPackage extra ${pkgs[0]} ${arch} [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] && fail "packages/arch/${arch}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done -- cgit v1.2.3 From ff0745c50507f0cea48dbf97b8f55734698e3c13 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 12:47:06 +0200 Subject: Prepare for variable db file compression --- test/lib/common.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 2d2b612..d28017d 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -89,7 +89,7 @@ checkAnyPackage() { done [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" [ -f "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } @@ -105,7 +105,7 @@ checkPackage() { [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" local pkgbase=$(getpkgbase "${FTP_BASE}/packages/arch/${arch}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -117,7 +117,7 @@ checkRemovedPackage() { local pkgbase=$2 local arch=$3 - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz" + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" @@ -129,7 +129,7 @@ checkRemovedAnyPackage() { local arch for arch in i686 x86_64; do - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz" + bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done svn up -q "${TMP}/svn-packages-copy/${pkgbase}" -- cgit v1.2.3 From 9eb1cd7b9403533c4b60ecfbbbf00a08c211059a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 15:03:27 +0200 Subject: Move common function to db-functions db-functions now sets an individual $WORKDIR and implements trap functinos that remove locks on exit or error. There are new functions to lock and unlock the running script. misc-scripts/ftpdir-cleanup was renamed to ftpdir-cleanup-repo as the cron-job had the same name. Script names have to be unique when using db-functions. --- test/lib/common.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index d28017d..ba5be9f 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -7,8 +7,8 @@ oneTimeSetUp() { echo -n 'Building packages...' for p in "${pkgdir}"/*; do pushd $p >/dev/null - linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || exit 1 - [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1 + linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' + [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || die 'makepkg failed' popd >/dev/null done echo 'done' @@ -23,7 +23,7 @@ setUp() { local p local pkg - [ -f "${curdir}/../config.local" ] && exit 1 + [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #echo "Using ${TMP}" -- cgit v1.2.3 From af4f86808e8cd45cc171f55a1ec15bf30d858a0d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 10 Aug 2010 21:40:24 +0200 Subject: Use more consitent naming for package pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no longer architecture-specific subdirs and the structure was switch to this: ftp └── pool ├── community └── packages packages contains all packages from core, extra and testing; this naming is in sync with the svn repo naming: svn-packages and svn-community --- test/lib/common.inc | 13 +++++++------ test/runTest | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index ba5be9f..89155c7 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -28,7 +28,8 @@ setUp() { #echo "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} - mkdir -p "${TMP}/ftp/"{{core,extra,community,testing,community-testing}/os,packages/{arch,community}}/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing}/os/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/pool/"{packages,community} mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} echo -n 'Creating svn repository...' @@ -81,11 +82,11 @@ checkAnyPackage() { local pkg=$2 local arch - [ -f "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "packages/arch/any/${pkg} not found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/any/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" done [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" @@ -99,15 +100,15 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "packages/arch/${arch}/${pkg} not found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - local pkgbase=$(getpkgbase "${FTP_BASE}/packages/arch/${arch}/${pkg}") + local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } diff --git a/test/runTest b/test/runTest index 5bbea05..75c7a05 100755 --- a/test/runTest +++ b/test/runTest @@ -240,7 +240,7 @@ testCleanupSimplePackages() { for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' ${arch} - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" @@ -263,7 +263,7 @@ testCleanupAnyPackages() { local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' checkRemovedAnyPackage extra 'pkg-any-a' - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" @@ -294,7 +294,7 @@ testCleanupSplitPackages() { for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do checkRemovedPackage extra ${pkgs[0]} ${arch} - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] && fail "packages/arch/${arch}/${pkg} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] && fail "$(get_pkgpool_for_host)/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done @@ -329,7 +329,7 @@ testMovePackagesWithoutPool() { for old in 0 2; do for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done done done @@ -369,7 +369,7 @@ testMoveAnyPackagesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/packages/arch/any/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done -- cgit v1.2.3 From e2c005b490df6762e23da3223944151c17d1de80 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 08:20:27 +0200 Subject: Check permission before any action Added a function to check if user has permission to alter the repos and db files. --- test/lib/common.inc | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 89155c7..795d01a 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,3 +1,5 @@ +set -E + . "${curdir}/../db-functions" oneTimeSetUp() { @@ -8,7 +10,9 @@ oneTimeSetUp() { for p in "${pkgdir}"/*; do pushd $p >/dev/null linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' - [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || die 'makepkg failed' + [ -f *-any.pkg.tar.* ] \ + || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 \ + || die 'makepkg failed' popd >/dev/null done echo 'done' @@ -23,7 +27,7 @@ setUp() { local p local pkg - [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" + #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #echo "Using ${TMP}" @@ -82,17 +86,20 @@ checkAnyPackage() { local pkg=$2 local arch - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" done - [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - [ -f "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" + [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } checkPackage() { @@ -100,17 +107,21 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ + || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } checkRemovedPackage() { @@ -118,10 +129,13 @@ checkRemovedPackage() { local pkgbase=$2 local arch=$3 - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ + && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" } checkRemovedAnyPackage() { @@ -130,9 +144,12 @@ checkRemovedAnyPackage() { local arch for arch in i686 x86_64; do - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ + && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" } \ No newline at end of file -- cgit v1.2.3 From a422060414670bb49d2422a38467b73ae01e7ecb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 09:47:31 +0200 Subject: Use common functions to print messages, warnings and errors These functions are copied from makepkg --- test/lib/common.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 795d01a..5c76eb5 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -6,7 +6,7 @@ oneTimeSetUp() { local p pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" cp -r ${curdir}/packages/* "${pkgdir}" - echo -n 'Building packages...' + msg 'Building packages...' for p in "${pkgdir}"/*; do pushd $p >/dev/null linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' @@ -15,7 +15,6 @@ oneTimeSetUp() { || die 'makepkg failed' popd >/dev/null done - echo 'done' echo } @@ -29,14 +28,14 @@ setUp() { #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" - #echo "Using ${TMP}" + #msg "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing}/os/{i686,any,x86_64} mkdir -p "${TMP}/ftp/pool/"{packages,community} mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} - echo -n 'Creating svn repository...' + msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" svnadmin create "${TMP}/svn-community-repo" svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" @@ -49,7 +48,6 @@ setUp() { svn add -q "${TMP}/svn-packages-copy"/${pkg} svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done - echo 'done' cat < "${curdir}/../config.local" FTP_BASE="${TMP}/ftp" @@ -152,4 +150,4 @@ checkRemovedAnyPackage() { svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" -} \ No newline at end of file +} -- cgit v1.2.3 From cdf17a4c4c83c1363a59fa688654276c3d807eae Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 20:15:50 +0200 Subject: Rewrite of db-update * db-update now updates all repos with packages in its staging dirs * sanity checks are performed before any repo is touched * improved performance * less code; easier to maintain --- test/runTest | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index 75c7a05..06ca000 100755 --- a/test/runTest +++ b/test/runTest @@ -33,7 +33,7 @@ testAddSimplePackages() { done done - ../db-update extra + ../db-update for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -50,7 +50,7 @@ testAddAnyPackages() { releasePackage extra ${pkgbase} any done - ../db-update extra + ../db-update for pkgbase in ${pkgs[@]}; do checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz @@ -70,7 +70,7 @@ testAddSplitPackages() { done done - ../db-update extra + ../db-update for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -98,7 +98,7 @@ testRemovePackages() { done done - ../db-update extra + ../db-update for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -121,7 +121,7 @@ testRemoveAnyPackages() { releasePackage extra ${pkgbase} any done - ../db-update extra + ../db-update for pkgbase in ${pkgs[@]}; do ../db-remove ${pkgbase} extra any @@ -149,7 +149,7 @@ testMoveSimplePackages() { done done - ../db-update testing + ../db-update for arch in ${arches[@]}; do ../db-move pkg-simple-a testing extra ${arch} @@ -171,7 +171,7 @@ testMoveAnyPackages() { releasePackage testing ${pkgbase} any done - ../db-update testing + ../db-update ../db-move pkg-any-a testing extra any checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz @@ -192,7 +192,7 @@ testMoveSplitPackages() { done done - ../db-update testing + ../db-update for arch in ${arches[@]}; do ../db-move pkg-split-a testing extra ${arch} @@ -229,7 +229,7 @@ testCleanupSimplePackages() { done done - ../db-update extra + ../db-update for arch in ${arches[@]}; do ../db-remove pkg-simple-a extra ${arch} @@ -257,7 +257,7 @@ testCleanupAnyPackages() { releasePackage extra ${pkgbase} any done - ../db-update extra + ../db-update ../db-remove pkg-any-a extra any ../cron-jobs/ftpdir-cleanup >/dev/null @@ -283,7 +283,7 @@ testCleanupSplitPackages() { done done - ../db-update extra + ../db-update for arch in ${arches[@]}; do ../db-remove ${pkgs[0]} extra ${arch} @@ -322,7 +322,7 @@ testMovePackagesWithoutPool() { done done - ../db-update testing + ../db-update # transform two packages to old style layout for arch in ${arches[@]}; do @@ -364,7 +364,7 @@ testMoveAnyPackagesWithoutPool() { releasePackage testing ${pkgbase} any done - ../db-update testing + ../db-update # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do -- cgit v1.2.3 From 55aa721771c7486c447b270325c504724622fd00 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 22:41:16 +0200 Subject: Prepare support for multiple packages in db-move --- test/runTest | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index 06ca000..8c1aa04 100755 --- a/test/runTest +++ b/test/runTest @@ -152,7 +152,7 @@ testMoveSimplePackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-simple-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-simple-a done for arch in ${arches[@]}; do @@ -172,7 +172,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move pkg-any-a testing extra any + ../db-move testing extra any pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -195,7 +195,7 @@ testMoveSplitPackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-split-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-split-a done for arch in ${arches[@]}; do @@ -338,7 +338,7 @@ testMovePackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - ../db-move ${pkgbase} testing extra ${arch} + ../db-move testing extra ${arch} ${pkgbase} done done @@ -378,7 +378,7 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do - ../db-move ${pkgbase} testing extra any + ../db-move testing extra any ${pkgbase} done ../cron-jobs/ftpdir-cleanup >/dev/null -- cgit v1.2.3 From 79db58732efbab54911ccbbb8cd876da29ea48c8 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 18:21:33 +0200 Subject: Move packages of all arches within one transaction db-move does no longer need a specific architecture. It will move all architecures of a given package at once. testing2x has been rewritten to respect these changes and testing2x64 is no longer needed. --- test/runTest | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index 8c1aa04..03f94c2 100755 --- a/test/runTest +++ b/test/runTest @@ -151,9 +151,7 @@ testMoveSimplePackages() { ../db-update - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} pkg-simple-a - done + ../db-move testing extra pkg-simple-a for arch in ${arches[@]}; do checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} @@ -172,7 +170,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move testing extra any pkg-any-a + ../db-move testing extra pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -193,10 +191,7 @@ testMoveSplitPackages() { done ../db-update - - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} pkg-split-a - done + ../db-move testing extra pkg-split-a for arch in ${arches[@]}; do for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do @@ -336,11 +331,7 @@ testMovePackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} ${pkgbase} - done - done + ../db-move testing extra ${pkgs[@]} ../cron-jobs/ftpdir-cleanup >/dev/null @@ -377,9 +368,7 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null - for pkgbase in ${pkgs[@]}; do - ../db-move testing extra any ${pkgbase} - done + ../db-move testing extra ${pkgs[@]} ../cron-jobs/ftpdir-cleanup >/dev/null -- cgit v1.2.3 From ce604bc3a2569198fa749acca190fef036e059a1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 19:17:05 +0200 Subject: add test to check updating a package --- test/lib/common.inc | 3 ++- test/runTest | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 5c76eb5..e55ce38 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -75,8 +75,9 @@ releasePackage() { pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null archrelease ${repo}-${arch} >/dev/null 2&>1 + pkgver=$(. PKGBUILD; echo "${pkgver}-${pkgrel}") popd >/dev/null - cp "${pkgdir}/${pkgbase}"/*.pkg.tar.* "${STAGING}"/${repo}/ + cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}.pkg.tar.* "${STAGING}"/${repo}/ } checkAnyPackage() { diff --git a/test/runTest b/test/runTest index 03f94c2..a16165d 100755 --- a/test/runTest +++ b/test/runTest @@ -81,6 +81,24 @@ testAddSplitPackages() { done } +testUpdateAnyPackage() { + releasePackage extra pkg-any-a any + ../db-update + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage extra pkg-any-a any + ../db-update + + checkAnyPackage extra pkg-any-a-1-2-any.pkg.tar.xz any + + rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" +} # # db-remove -- cgit v1.2.3 From 583863043ad11eb203c479c9d0eea825a29ace39 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 19:21:38 +0200 Subject: add test for testing2x --- test/runTest | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index a16165d..95d8c6c 100755 --- a/test/runTest +++ b/test/runTest @@ -226,6 +226,32 @@ testMoveSplitPackages() { } +# +# testing2x +# + +testTesting2xAnyPackage() { + releasePackage core pkg-any-a any + ../db-update + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage testing pkg-any-a any + ../db-update + rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" + + ../testing2x pkg-any-a + + checkAnyPackage core pkg-any-a-1-2-any.pkg.tar.xz any + checkRemovedAnyPackage testing pkg-any-a +} + + # # ftpdir-cleanup # -- cgit v1.2.3 From 4daeb0a71e65618c56d672118675c9efd57c5979 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 17 Aug 2010 08:00:21 +0200 Subject: Add [staging] repository --- test/lib/common.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index e55ce38..a79558c 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -31,9 +31,9 @@ setUp() { #msg "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} - mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing}/os/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing,staging}/os/{i686,any,x86_64} mkdir -p "${TMP}/ftp/pool/"{packages,community} - mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} + mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing,staging} msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" -- cgit v1.2.3 From cb39feaff074c5e08ff2dfce8dfa04c545233b7e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 17 Aug 2010 16:41:31 +0200 Subject: Don't try to update no package Check if there are packages to update for given architecure. Previously db-update quit when only one arch of a package was available. --- test/runTest | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index 95d8c6c..72f9b1c 100755 --- a/test/runTest +++ b/test/runTest @@ -42,6 +42,12 @@ testAddSimplePackages() { done } +testAddSingleSimplePackage() { + releasePackage extra 'pkg-simple-a' 'i686' + ../db-update + checkPackage extra 'pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686' +} + testAddAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase -- cgit v1.2.3 From 8647de4f52e05eadc0a4832813e9a57c20a487dd Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 18 Aug 2010 11:58:02 +0200 Subject: Fix cleanup of old packages * This should fix the cleanup of packages that were not within the pacakge pool before being updated. * a test case for this was added --- test/runTest | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index 72f9b1c..cfc4ee6 100755 --- a/test/runTest +++ b/test/runTest @@ -395,6 +395,42 @@ testMovePackagesWithoutPool() { done } +testUpdateAnyPackageWithoutPool() { + local pkgname='pkg-any-a' + local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' + local pkg2='pkg-any-a-1-2-any.pkg.tar.xz' + local arch + + + releasePackage extra pkg-any-a any + ../db-update + # transform two packages to old style layout + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" "${FTP_BASE}/extra/os/any" + for arch in i686 x86_64; do + ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" + done + + pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + mv "${pkg2}" "${pkgdir}/${pkgname}/" + popd >/dev/null + + releasePackage extra ${pkgname} any + ../db-update + rm "${pkgdir}/${pkgname}/${pkg2}" + + ../cron-jobs/ftpdir-cleanup >/dev/null + + checkAnyPackage extra "${pkg2}" + + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + for arch in any i686 x86_64; do + [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" + done +} + testMoveAnyPackagesWithoutPool() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase @@ -428,6 +464,13 @@ testMoveAnyPackagesWithoutPool() { done checkRemovedAnyPackage testing ${pkgbase} done + + for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + for arch in any i686 x86_64; do + [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" + done + done } . "${curdir}/lib/shunit2" -- cgit v1.2.3 From 9e8897aeadb2aa51b70c5fc0ed1ae281b015d146 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 22 Aug 2010 22:01:09 +0200 Subject: add makepkg.conf for [multilib] --- test/lib/common.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index a79558c..9017aa5 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -31,9 +31,9 @@ setUp() { #msg "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} - mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing,staging}/os/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing,staging,multilib}/os/{i686,any,x86_64} mkdir -p "${TMP}/ftp/pool/"{packages,community} - mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing,staging} + mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing,staging,multilib} msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" -- cgit v1.2.3 From 328b1ce478e25902aba5d8f19024dadeaaf3f678 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Sep 2010 19:34:47 +0200 Subject: Simplify repo configuration * Repositories can now be defined in the config file for each host * added community-staging, gnome-unstable and kde-unstable * Exception is the adjust-permission cron-job; but we might want to use acls in future anyway Signed-off-by: Pierre Schmitz --- test/lib/common.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 9017aa5..71dfd3d 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,5 +1,6 @@ set -E +. "${curdir}/../config" . "${curdir}/../db-functions" oneTimeSetUp() { @@ -25,15 +26,24 @@ oneTimeTearDown() { setUp() { local p local pkg + local r + local a #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #msg "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} - mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing,staging,multilib}/os/{i686,any,x86_64} - mkdir -p "${TMP}/ftp/pool/"{packages,community} - mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing,staging,multilib} + + for r in ${PKGREPO[@]}; do + mkdir -p "${TMP}/staging/${r}" + for a in ${ARCHES[@]} any; do + mkdir -p "${TMP}/ftp/${r}/os/${a}" + done + done + for p in ${PKGPOOL[@]}; do + mkdir -p "${TMP}/ftp/${p}" + done msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" -- cgit v1.2.3 From cca13c2b41ba1389ce4187a728e05a376ad3ad0d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 5 Sep 2010 12:54:37 +0200 Subject: Fix updating of same package into different repositories at aonce See FS#20745 --- test/runTest | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index cfc4ee6..e254de0 100755 --- a/test/runTest +++ b/test/runTest @@ -106,6 +106,26 @@ testUpdateAnyPackage() { rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } +testUpdateAnyPackageInDifferentRepositoriesAtOnce() { + releasePackage extra pkg-any-a any + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage testing pkg-any-a any + + ../db-update + + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any + checkAnyPackage testing pkg-any-a-1-2-any.pkg.tar.xz any + + rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" +} + # # db-remove # -- cgit v1.2.3 From 6f29ee2f02c2a8e2991599ce1d76a59b58a7ee67 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 5 Sep 2010 13:32:27 +0200 Subject: Check if package exists in any other repository on update This also checks if the sam package exists within the old package layout (without package pool) --- test/runTest | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/runTest b/test/runTest index e254de0..b07b099 100755 --- a/test/runTest +++ b/test/runTest @@ -106,7 +106,7 @@ testUpdateAnyPackage() { rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } -testUpdateAnyPackageInDifferentRepositoriesAtOnce() { +testUpdateAnyPackageToDifferentRepositoriesAtOnce() { releasePackage extra pkg-any-a any pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null @@ -126,6 +126,22 @@ testUpdateAnyPackageInDifferentRepositoriesAtOnce() { rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } +testUpdateSameAnyPackageToDifferentRepositories() { + releasePackage extra pkg-any-a any + ../db-update + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any + + releasePackage testing pkg-any-a any + ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) + + local arch + for arch in i686 x86_64; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + done +} + # # db-remove # @@ -493,4 +509,31 @@ testMoveAnyPackagesWithoutPool() { done } +testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { + local pkg + local arch + + releasePackage extra pkg-any-a any + ../db-update + + # transform a package to old style layout + for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" + for arch in i686 x86_64; do + ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" + done + done + + releasePackage testing pkg-any-a any + ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) + + for arch in i686 x86_64; do + ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q pkg-any-a) \ + && fail "pkg-any-a should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" + done +} + + . "${curdir}/lib/shunit2" -- cgit v1.2.3 From f121126f8166fb6dc261ea82f2890ba6693d047e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 11 Sep 2010 22:52:23 +0200 Subject: Use local config instead of guessing by hostname Using the hostname to decide which repos to use is not releiable and hard to test. Instead use config.local to configure these. config files for sigurd and gerolde were added which can be copied or symlinked to config.local on the specific host. --- test/lib/common.inc | 26 ++++++++++++++------------ test/runTest | 16 ++++++++-------- 2 files changed, 22 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 71dfd3d..a0d864a 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -29,13 +29,15 @@ setUp() { local r local a - #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" + [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #msg "Using ${TMP}" - mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} + PKGREPOS=('core' 'extra' 'testing') + PKGPOOL='pool/packages' + mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} - for r in ${PKGREPO[@]}; do + for r in ${PKGREPOS[@]}; do mkdir -p "${TMP}/staging/${r}" for a in ${ARCHES[@]} any; do mkdir -p "${TMP}/ftp/${r}/os/${a}" @@ -47,9 +49,7 @@ setUp() { msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" - svnadmin create "${TMP}/svn-community-repo" svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" - svn checkout -q "file://${TMP}/svn-community-repo" "${TMP}/svn-community-copy" for p in "${pkgdir}"/*; do pkg=$(basename $p) @@ -63,6 +63,8 @@ setUp() { FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" SVNREPOCOMMUNITY="file://${TMP}/svn-community-repo" + PKGREPOS=(${PKGREPOS[@]}) + PKGPOOL="${PKGPOOL}" CLEANUP_DESTDIR="${TMP}/package-cleanup" SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" @@ -95,12 +97,12 @@ checkAnyPackage() { local pkg=$2 local arch - [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ - || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" done [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" @@ -116,18 +118,18 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ - || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") + local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" diff --git a/test/runTest b/test/runTest index b07b099..4681944 100755 --- a/test/runTest +++ b/test/runTest @@ -321,7 +321,7 @@ testCleanupSimplePackages() { for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' ${arch} - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" @@ -344,7 +344,7 @@ testCleanupAnyPackages() { local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' checkRemovedAnyPackage extra 'pkg-any-a' - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" @@ -375,7 +375,7 @@ testCleanupSplitPackages() { for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do checkRemovedPackage extra ${pkgs[0]} ${arch} - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] && fail "$(get_pkgpool_for_host)/${pkg} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done @@ -410,7 +410,7 @@ testMovePackagesWithoutPool() { for old in 0 2; do for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done done done @@ -441,7 +441,7 @@ testUpdateAnyPackageWithoutPool() { releasePackage extra pkg-any-a any ../db-update # transform two packages to old style layout - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" "${FTP_BASE}/extra/os/any" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" "${FTP_BASE}/extra/os/any" for arch in i686 x86_64; do ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" done @@ -461,7 +461,7 @@ testUpdateAnyPackageWithoutPool() { checkAnyPackage extra "${pkg2}" - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" for arch in any i686 x86_64; do [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" done @@ -482,7 +482,7 @@ testMoveAnyPackagesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done @@ -519,7 +519,7 @@ testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" done -- cgit v1.2.3 From cb2dcc6ee207e9c5ba4b875d70e387e6347591ed Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 20 Nov 2010 16:11:59 +0100 Subject: Fix sourceballs cron job * add unit test for sourceballs and cleanup * introduce SRCPOOL and LOGDIR variables in config --- test/lib/common.inc | 7 ++++--- test/runTest | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index a0d864a..14dc000 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -43,9 +43,9 @@ setUp() { mkdir -p "${TMP}/ftp/${r}/os/${a}" done done - for p in ${PKGPOOL[@]}; do - mkdir -p "${TMP}/ftp/${p}" - done + mkdir -p "${TMP}/ftp/${PKGPOOL}" + mkdir -p "${TMP}/ftp/${SRCPOOL}" + mkdir -p "${TMP}/log" msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" @@ -69,6 +69,7 @@ setUp() { SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" TMPDIR="${TMP}/tmp" + LOGDIR="${TMP}/log" CLEANUP_DRYRUN=false eot . "${curdir}/../config" diff --git a/test/runTest b/test/runTest index 4681944..d3e2eff 100755 --- a/test/runTest +++ b/test/runTest @@ -535,5 +535,64 @@ testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { done } +# +#sourceballs tests +# + +testSourceballs() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + + ../cron-jobs/sourceballs + + for log in errors failed; do + if [ -s "${LOGDIR}/sourceballs/${log}.txt" ]; then + fail "${LOGDIR}/sourceballs/${log}.txt includes the following errors:" + cat "${LOGDIR}/sourceballs/${log}.txt" + fi + done + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + +testSourceballsCleanup() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + ../cron-jobs/sourceballs + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-a extra ${arch} + done + ../cron-jobs/ftpdir-cleanup >/dev/null + + ../cron-jobs/sourceballs + for log in errors failed; do + if [ -s "${LOGDIR}/sourceballs/${log}.txt" ]; then + fail "${LOGDIR}/sourceballs/${log}.txt includes the following errors:" + cat "${LOGDIR}/sourceballs/${log}.txt" + fi + done + [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" + [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" +} . "${curdir}/lib/shunit2" -- cgit v1.2.3 From a7591f4be3f9e741f5d1e5aeadd3ab20b497a252 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 20 Nov 2010 20:38:38 +0100 Subject: Simplify sourceballs creation * Read package lists directly from DB file * Make SVNREPO configurable --- test/lib/common.inc | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 14dc000..e47ae2d 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -62,7 +62,6 @@ setUp() { cat < "${curdir}/../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" - SVNREPOCOMMUNITY="file://${TMP}/svn-community-repo" PKGREPOS=(${PKGREPOS[@]}) PKGPOOL="${PKGPOOL}" CLEANUP_DESTDIR="${TMP}/package-cleanup" -- cgit v1.2.3 From 30a128a864bdbfc294b6ba6a49c9264570bb3c58 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 21 Nov 2010 13:23:09 +0100 Subject: sourceballs: Don't write any log This is consistent with the other dbscripts. The output will be send to the mailinglist. --- test/lib/common.inc | 2 -- test/runTest | 13 ------------- 2 files changed, 15 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index e47ae2d..6619c0a 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -45,7 +45,6 @@ setUp() { done mkdir -p "${TMP}/ftp/${PKGPOOL}" mkdir -p "${TMP}/ftp/${SRCPOOL}" - mkdir -p "${TMP}/log" msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" @@ -68,7 +67,6 @@ setUp() { SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" TMPDIR="${TMP}/tmp" - LOGDIR="${TMP}/log" CLEANUP_DRYRUN=false eot . "${curdir}/../config" diff --git a/test/runTest b/test/runTest index d3e2eff..6c60ddc 100755 --- a/test/runTest +++ b/test/runTest @@ -553,13 +553,6 @@ testSourceballs() { ../db-update ../cron-jobs/sourceballs - - for log in errors failed; do - if [ -s "${LOGDIR}/sourceballs/${log}.txt" ]; then - fail "${LOGDIR}/sourceballs/${log}.txt includes the following errors:" - cat "${LOGDIR}/sourceballs/${log}.txt" - fi - done for pkgbase in ${pkgs[@]}; do [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" done @@ -585,12 +578,6 @@ testSourceballsCleanup() { ../cron-jobs/ftpdir-cleanup >/dev/null ../cron-jobs/sourceballs - for log in errors failed; do - if [ -s "${LOGDIR}/sourceballs/${log}.txt" ]; then - fail "${LOGDIR}/sourceballs/${log}.txt includes the following errors:" - cat "${LOGDIR}/sourceballs/${log}.txt" - fi - done [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" } -- cgit v1.2.3 From cf642f924a4404f85926619324e59b3c878c1284 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 21 Nov 2010 13:59:30 +0100 Subject: sourceballs: Support any packages --- test/runTest | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index 6c60ddc..fe22ce7 100755 --- a/test/runTest +++ b/test/runTest @@ -558,6 +558,21 @@ testSourceballs() { done } +testAnySourceballs() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + ../db-update + + ../cron-jobs/sourceballs + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + testSourceballsCleanup() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') -- cgit v1.2.3 From 5869af885163b763abb204dff2cc847556fb247b Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 22 Nov 2010 14:35:30 +0100 Subject: sourceballs: add for split packages --- test/runTest | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/runTest b/test/runTest index fe22ce7..f438704 100755 --- a/test/runTest +++ b/test/runTest @@ -573,6 +573,27 @@ testAnySourceballs() { done } +testSplitSourceballs() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + ../cron-jobs/sourceballs + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + testSourceballsCleanup() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') -- cgit v1.2.3 From cadd215e9d726030bd7b86396eda47c2c69c1bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20B=C3=A9langer?= Date: Wed, 24 Nov 2010 15:13:13 -0500 Subject: Added seperate dryrun options for the packages and sources cleanup scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric Bélanger Signed-off-by: Pierre Schmitz --- test/lib/common.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 6619c0a..d7ea3d4 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -68,6 +68,7 @@ setUp() { STAGING="${TMP}/staging" TMPDIR="${TMP}/tmp" CLEANUP_DRYRUN=false + SOURCE_CLEANUP_DRYRUN=false eot . "${curdir}/../config" } -- cgit v1.2.3 From 5f72b8029c07f3357014d8716f18f21ce649c98a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 25 Nov 2010 06:55:03 +0100 Subject: Provide more real test packages * Use devtools instead of plain makepkg * This is a preparation for some more advanced test cases. --- test/lib/common.inc | 39 ++++++++++-- test/lib/makepkg-i686.conf | 115 ------------------------------------ test/lib/makepkg-x86_64.conf | 115 ------------------------------------ test/packages/pkg-any-a/PKGBUILD | 3 +- test/packages/pkg-any-b/PKGBUILD | 3 +- test/packages/pkg-simple-a/Makefile | 1 + test/packages/pkg-simple-a/PKGBUILD | 13 +++- test/packages/pkg-simple-a/test.c | 1 + test/packages/pkg-simple-b/Makefile | 1 + test/packages/pkg-simple-b/PKGBUILD | 13 +++- test/packages/pkg-simple-b/test.c | 1 + test/packages/pkg-split-a/Makefile | 1 + test/packages/pkg-split-a/PKGBUILD | 16 ++++- test/packages/pkg-split-a/test.c | 1 + test/packages/pkg-split-b/Makefile | 1 + test/packages/pkg-split-b/PKGBUILD | 17 +++++- test/packages/pkg-split-b/test.c | 1 + test/runTest | 24 ++++---- test/src/Makefile | 5 ++ test/src/test.c | 7 +++ 20 files changed, 120 insertions(+), 258 deletions(-) delete mode 100644 test/lib/makepkg-i686.conf delete mode 100644 test/lib/makepkg-x86_64.conf create mode 120000 test/packages/pkg-simple-a/Makefile create mode 120000 test/packages/pkg-simple-a/test.c create mode 120000 test/packages/pkg-simple-b/Makefile create mode 120000 test/packages/pkg-simple-b/test.c create mode 120000 test/packages/pkg-split-a/Makefile create mode 120000 test/packages/pkg-split-a/test.c create mode 120000 test/packages/pkg-split-b/Makefile create mode 120000 test/packages/pkg-split-b/test.c create mode 100644 test/src/Makefile create mode 100644 test/src/test.c (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index d7ea3d4..34de9eb 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -5,15 +5,42 @@ set -E oneTimeSetUp() { local p + local d + local a + local pkgname + local pkgarch + local pkgversion + local build pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" cp -r ${curdir}/packages/* "${pkgdir}" msg 'Building packages...' - for p in "${pkgdir}"/*; do - pushd $p >/dev/null - linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' - [ -f *-any.pkg.tar.* ] \ - || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 \ - || die 'makepkg failed' + for d in "${pkgdir}"/*; do + pushd $d >/dev/null + pkgname=($(. PKGBUILD; echo ${pkgname[@]})) + pkgarch=($(. PKGBUILD; echo ${arch[@]})) + pkgversion=$(. PKGBUILD; echo ${pkgver}-${pkgrel}) + + build=true + for a in ${pkgarch[@]}; do + for p in ${pkgname[@]}; do + [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false + done + done + + if ! ${build}; then + if [ "${pkgarch[0]}" == 'any' ]; then + extra-x86_64-build || die 'extra-x86_64-build failed' + else + for a in ${pkgarch[@]}; do + extra-${a}-build || die "extra-${a}-build failed" + done + fi + for a in ${pkgarch[@]}; do + for p in ${pkgname[@]}; do + cp ${p}-${pkgversion}-${a}${PKGEXT} ${curdir}/packages/$(basename ${d}) + done + done + fi popd >/dev/null done echo diff --git a/test/lib/makepkg-i686.conf b/test/lib/makepkg-i686.conf deleted file mode 100644 index 553f943..0000000 --- a/test/lib/makepkg-i686.conf +++ /dev/null @@ -1,115 +0,0 @@ -# -# /etc/makepkg.conf -# - -######################################################################### -# SOURCE ACQUISITION -######################################################################### -# -#-- The download utilities that makepkg should use to acquire sources -# Format: 'protocol::agent' -DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u' - 'http::/usr/bin/wget -c -t 3 --waitretry=3 -O %o %u' - 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate -O %o %u' - 'rsync::/usr/bin/rsync -z %u %o' - 'scp::/usr/bin/scp -C %u %o') - -# Other common tools: -# /usr/bin/snarf -# /usr/bin/lftpget -c -# /usr/bin/curl - -######################################################################### -# ARCHITECTURE, COMPILE FLAGS -######################################################################### -# -CARCH="i686" -CHOST="i686-pc-linux-gnu" - -#-- Exclusive: will only run on i686 -# -march (or -mcpu) builds exclusively for an architecture -# -mtune optimizes for an architecture, but builds for whole processor family -CFLAGS="-march=i686 -mtune=generic -O2 -pipe" -CXXFLAGS="-march=i686 -mtune=generic -O2 -pipe" -LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed" -#-- Make Flags: change this for DistCC/SMP systems -#MAKEFLAGS="-j2" - -######################################################################### -# BUILD ENVIRONMENT -######################################################################### -# -# Defaults: BUILDENV=(fakeroot !distcc color !ccache) -# A negated environment option will do the opposite of the comments below. -# -#-- fakeroot: Allow building packages as a non-root user -#-- distcc: Use the Distributed C/C++/ObjC compiler -#-- color: Colorize output messages -#-- ccache: Use ccache to cache compilation -# -BUILDENV=(fakeroot !distcc color !ccache) -# -#-- If using DistCC, your MAKEFLAGS will also need modification. In addition, -#-- specify a space-delimited list of hosts running in the DistCC cluster. -#DISTCC_HOSTS="" - -######################################################################### -# GLOBAL PACKAGE OPTIONS -# These are default values for the options=() settings -######################################################################### -# -# Default: OPTIONS=(strip docs libtool emptydirs zipman purge) -# A negated option will do the opposite of the comments below. -# -#-- strip: Strip symbols from binaries/libraries in STRIP_DIRS -#-- docs: Save doc directories specified by DOC_DIRS -#-- libtool: Leave libtool (.la) files in packages -#-- emptydirs: Leave empty directories in packages -#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip -#-- purge: Remove files specified by PURGE_TARGETS -# -OPTIONS=(strip docs libtool emptydirs zipman purge) - -#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 -INTEGRITY_CHECK=(md5) -#-- Options to be used when stripping binaries. See `man strip' for details. -STRIP_BINARIES="--strip-all" -#-- Options to be used when stripping shared libraries. See `man strip' for details. -STRIP_SHARED="--strip-unneeded" -#-- Options to be used when stripping static libraries. See `man strip' for details. -STRIP_STATIC="--strip-debug" -#-- Manual (man and info) directories to compress (if zipman is specified) -MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) -#-- Doc directories to remove (if !docs is specified) -DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) -#-- Directories to be searched for the strip option (if strip is specified) -STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin}) -#-- Files to be removed from all packages (if purge is specified) -PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) - -######################################################################### -# PACKAGE OUTPUT -######################################################################### -# -# Default: put built package and cached source in build directory -# -#-- Destination: specify a fixed directory where all packages will be placed -#PKGDEST=/home/packages -#-- Source cache: specify a fixed directory where source files will be cached -#SRCDEST=/home/sources -#-- Source packages: specify a fixed directory where all src packages will be placed -#SRCPKGDEST=/home/srcpackages -#-- Packager: name/email of the person or organization building packages -#PACKAGER="John Doe " - -######################################################################### -# EXTENSION DEFAULTS -######################################################################### -# -# WARNING: Do NOT modify these variables unless you know what you are -# doing. -# -PKGEXT='.pkg.tar.xz' -SRCEXT='.src.tar.gz' - -# vim: set ft=sh ts=2 sw=2 et: diff --git a/test/lib/makepkg-x86_64.conf b/test/lib/makepkg-x86_64.conf deleted file mode 100644 index e53375f..0000000 --- a/test/lib/makepkg-x86_64.conf +++ /dev/null @@ -1,115 +0,0 @@ -# -# /etc/makepkg.conf -# - -######################################################################### -# SOURCE ACQUISITION -######################################################################### -# -#-- The download utilities that makepkg should use to acquire sources -# Format: 'protocol::agent' -DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u' - 'http::/usr/bin/wget -c -t 3 --waitretry=3 -O %o %u' - 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate -O %o %u' - 'rsync::/usr/bin/rsync -z %u %o' - 'scp::/usr/bin/scp -C %u %o') - -# Other common tools: -# /usr/bin/snarf -# /usr/bin/lftpget -c -# /usr/bin/curl - -######################################################################### -# ARCHITECTURE, COMPILE FLAGS -######################################################################### -# -CARCH="x86_64" -CHOST="x86_64-unknown-linux-gnu" - -#-- Exclusive: will only run on x86_64 -# -march (or -mcpu) builds exclusively for an architecture -# -mtune optimizes for an architecture, but builds for whole processor family -CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" -CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" -LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed" -#-- Make Flags: change this for DistCC/SMP systems -#MAKEFLAGS="-j2" - -######################################################################### -# BUILD ENVIRONMENT -######################################################################### -# -# Defaults: BUILDENV=(fakeroot !distcc color !ccache) -# A negated environment option will do the opposite of the comments below. -# -#-- fakeroot: Allow building packages as a non-root user -#-- distcc: Use the Distributed C/C++/ObjC compiler -#-- color: Colorize output messages -#-- ccache: Use ccache to cache compilation -# -BUILDENV=(fakeroot !distcc color !ccache) -# -#-- If using DistCC, your MAKEFLAGS will also need modification. In addition, -#-- specify a space-delimited list of hosts running in the DistCC cluster. -#DISTCC_HOSTS="" - -######################################################################### -# GLOBAL PACKAGE OPTIONS -# These are default values for the options=() settings -######################################################################### -# -# Default: OPTIONS=(strip docs libtool emptydirs zipman purge) -# A negated option will do the opposite of the comments below. -# -#-- strip: Strip symbols from binaries/libraries in STRIP_DIRS -#-- docs: Save doc directories specified by DOC_DIRS -#-- libtool: Leave libtool (.la) files in packages -#-- emptydirs: Leave empty directories in packages -#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip -#-- purge: Remove files specified by PURGE_TARGETS -# -OPTIONS=(strip docs libtool emptydirs zipman purge) - -#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 -INTEGRITY_CHECK=(md5) -#-- Options to be used when stripping binaries. See `man strip' for details. -STRIP_BINARIES="--strip-all" -#-- Options to be used when stripping shared libraries. See `man strip' for details. -STRIP_SHARED="--strip-unneeded" -#-- Options to be used when stripping static libraries. See `man strip' for details. -STRIP_STATIC="--strip-debug" -#-- Manual (man and info) directories to compress (if zipman is specified) -MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) -#-- Doc directories to remove (if !docs is specified) -DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) -#-- Directories to be searched for the strip option (if strip is specified) -STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin}) -#-- Files to be removed from all packages (if purge is specified) -PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) - -######################################################################### -# PACKAGE OUTPUT -######################################################################### -# -# Default: put built package and cached source in build directory -# -#-- Destination: specify a fixed directory where all packages will be placed -#PKGDEST=/home/packages -#-- Source cache: specify a fixed directory where source files will be cached -#SRCDEST=/home/sources -#-- Source packages: specify a fixed directory where all src packages will be placed -#SRCPKGDEST=/home/srcpackages -#-- Packager: name/email of the person or organization building packages -#PACKAGER="John Doe " - -######################################################################### -# EXTENSION DEFAULTS -######################################################################### -# -# WARNING: Do NOT modify these variables unless you know what you are -# doing. -# -PKGEXT='.pkg.tar.xz' -SRCEXT='.src.tar.gz' - -# vim: set ft=sh ts=2 sw=2 et: diff --git a/test/packages/pkg-any-a/PKGBUILD b/test/packages/pkg-any-a/PKGBUILD index 348bc4b..8749a35 100644 --- a/test/packages/pkg-any-a/PKGBUILD +++ b/test/packages/pkg-any-a/PKGBUILD @@ -7,5 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - true + install -d -m755 ${pkgdir}/usr/share/${pkgname} + echo 'test' > ${pkgdir}/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-any-b/PKGBUILD b/test/packages/pkg-any-b/PKGBUILD index fd42748..e6a0498 100644 --- a/test/packages/pkg-any-b/PKGBUILD +++ b/test/packages/pkg-any-b/PKGBUILD @@ -7,5 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - true + install -d -m755 ${pkgdir}/usr/share/${pkgname} + echo 'test' > ${pkgdir}/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-simple-a/Makefile b/test/packages/pkg-simple-a/Makefile new file mode 120000 index 0000000..50be211 --- /dev/null +++ b/test/packages/pkg-simple-a/Makefile @@ -0,0 +1 @@ +../../src/Makefile \ No newline at end of file diff --git a/test/packages/pkg-simple-a/PKGBUILD b/test/packages/pkg-simple-a/PKGBUILD index 78f3c8e..953ecfa 100644 --- a/test/packages/pkg-simple-a/PKGBUILD +++ b/test/packages/pkg-simple-a/PKGBUILD @@ -5,7 +5,18 @@ pkgdesc="A package called ${pkgname}" arch=('i686' 'x86_64') url='http://www.archlinux.org/' license=('GPL') +depends=('glibc') +makedepends=('gcc') +source=('Makefile' 'test.c') +md5sums=('c6cb8dcc86253355fed559416d0c8dcf' + '3c1e4279feb678fd9cabaccdb28e40d0') + +build() { + cd ${srcdir} + make +} package() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname} } diff --git a/test/packages/pkg-simple-a/test.c b/test/packages/pkg-simple-a/test.c new file mode 120000 index 0000000..ed5b5ac --- /dev/null +++ b/test/packages/pkg-simple-a/test.c @@ -0,0 +1 @@ +../../src/test.c \ No newline at end of file diff --git a/test/packages/pkg-simple-b/Makefile b/test/packages/pkg-simple-b/Makefile new file mode 120000 index 0000000..50be211 --- /dev/null +++ b/test/packages/pkg-simple-b/Makefile @@ -0,0 +1 @@ +../../src/Makefile \ No newline at end of file diff --git a/test/packages/pkg-simple-b/PKGBUILD b/test/packages/pkg-simple-b/PKGBUILD index 1ef298e..95ffd09 100644 --- a/test/packages/pkg-simple-b/PKGBUILD +++ b/test/packages/pkg-simple-b/PKGBUILD @@ -5,7 +5,18 @@ pkgdesc="A package called ${pkgname}" arch=('i686' 'x86_64') url='http://www.archlinux.org/' license=('GPL') +depends=('glibc') +makedepends=('gcc') +source=('Makefile' 'test.c') +md5sums=('c6cb8dcc86253355fed559416d0c8dcf' + '3c1e4279feb678fd9cabaccdb28e40d0') + +build() { + cd ${srcdir} + make +} package() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname} } diff --git a/test/packages/pkg-simple-b/test.c b/test/packages/pkg-simple-b/test.c new file mode 120000 index 0000000..ed5b5ac --- /dev/null +++ b/test/packages/pkg-simple-b/test.c @@ -0,0 +1 @@ +../../src/test.c \ No newline at end of file diff --git a/test/packages/pkg-split-a/Makefile b/test/packages/pkg-split-a/Makefile new file mode 120000 index 0000000..50be211 --- /dev/null +++ b/test/packages/pkg-split-a/Makefile @@ -0,0 +1 @@ +../../src/Makefile \ No newline at end of file diff --git a/test/packages/pkg-split-a/PKGBUILD b/test/packages/pkg-split-a/PKGBUILD index 6ac77ea..e941976 100644 --- a/test/packages/pkg-split-a/PKGBUILD +++ b/test/packages/pkg-split-a/PKGBUILD @@ -6,11 +6,23 @@ pkgdesc="A split package called ${pkgbase}" arch=('i686' 'x86_64') url='http://www.archlinux.org/' license=('GPL') +depends=('glibc') +makedepends=('gcc') +source=('Makefile' 'test.c') +md5sums=('c6cb8dcc86253355fed559416d0c8dcf' + '3c1e4279feb678fd9cabaccdb28e40d0') + +build() { + cd ${srcdir} + make +} package_pkg-split-a1() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} } package_pkg-split-a2() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} } diff --git a/test/packages/pkg-split-a/test.c b/test/packages/pkg-split-a/test.c new file mode 120000 index 0000000..ed5b5ac --- /dev/null +++ b/test/packages/pkg-split-a/test.c @@ -0,0 +1 @@ +../../src/test.c \ No newline at end of file diff --git a/test/packages/pkg-split-b/Makefile b/test/packages/pkg-split-b/Makefile new file mode 120000 index 0000000..50be211 --- /dev/null +++ b/test/packages/pkg-split-b/Makefile @@ -0,0 +1 @@ +../../src/Makefile \ No newline at end of file diff --git a/test/packages/pkg-split-b/PKGBUILD b/test/packages/pkg-split-b/PKGBUILD index e1817b7..6ddbc45 100644 --- a/test/packages/pkg-split-b/PKGBUILD +++ b/test/packages/pkg-split-b/PKGBUILD @@ -7,10 +7,23 @@ arch=('i686' 'x86_64') url='http://www.archlinux.org/' license=('GPL') +depends=('glibc') +makedepends=('gcc') +source=('Makefile' 'test.c') +md5sums=('c6cb8dcc86253355fed559416d0c8dcf' + '3c1e4279feb678fd9cabaccdb28e40d0') + +build() { + cd ${srcdir} + make +} + package_pkg-split-b1() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} } package_pkg-split-b2() { - true + cd ${srcdir} + make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} } diff --git a/test/packages/pkg-split-b/test.c b/test/packages/pkg-split-b/test.c new file mode 120000 index 0000000..ed5b5ac --- /dev/null +++ b/test/packages/pkg-split-b/test.c @@ -0,0 +1 @@ +../../src/test.c \ No newline at end of file diff --git a/test/runTest b/test/runTest index f438704..0fcdf18 100755 --- a/test/runTest +++ b/test/runTest @@ -8,12 +8,8 @@ curdir=$(readlink -e $(dirname $0)) # testPackages() { - local p - for p in "${pkgdir}"/*; do - pushd $p >/dev/null - namcap *.pkg.tar.* || fail 'namcap failed' - popd >/dev/null - done + # TODO: namcap -r depends fails with i686 packages + find "${pkgdir}" -name "*${PKGEXT}" -exec namcap -e depends {} + || fail 'namcap failed' } @@ -94,7 +90,7 @@ testUpdateAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -103,7 +99,7 @@ testUpdateAnyPackage() { checkAnyPackage extra pkg-any-a-1-2-any.pkg.tar.xz any - rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } testUpdateAnyPackageToDifferentRepositoriesAtOnce() { @@ -112,7 +108,7 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -123,7 +119,7 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any checkAnyPackage testing pkg-any-a-1-2-any.pkg.tar.xz any - rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } testUpdateSameAnyPackageToDifferentRepositories() { @@ -279,13 +275,13 @@ testTesting2xAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + extra-i686-build >/dev/null 2>&1 mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null releasePackage testing pkg-any-a any ../db-update - rm "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" ../testing2x pkg-any-a @@ -449,13 +445,13 @@ testUpdateAnyPackageWithoutPool() { pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD svn commit -q -m"update pkg to pkgrel=2" >/dev/null - makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 + extra-i686-build >/dev/null 2>&1 mv "${pkg2}" "${pkgdir}/${pkgname}/" popd >/dev/null releasePackage extra ${pkgname} any ../db-update - rm "${pkgdir}/${pkgname}/${pkg2}" + rm -f "${pkgdir}/${pkgname}/${pkg2}" ../cron-jobs/ftpdir-cleanup >/dev/null diff --git a/test/src/Makefile b/test/src/Makefile new file mode 100644 index 0000000..105b730 --- /dev/null +++ b/test/src/Makefile @@ -0,0 +1,5 @@ +all: + gcc $(CFLAGS) -o test test.c + +install: + install -D -m755 test $(DESTDIR)/usr/bin/$(DESTBIN) diff --git a/test/src/test.c b/test/src/test.c new file mode 100644 index 0000000..a661689 --- /dev/null +++ b/test/src/test.c @@ -0,0 +1,7 @@ +#include +#include + +int main(void) { + printf("Arch is the best!\n"); + return EXIT_SUCCESS; +} -- cgit v1.2.3 From 793d78130ba808ee688c8b7139a2bc6180b29534 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 25 Nov 2010 08:18:26 +0100 Subject: Split tests into several files * tests can be run seperatly * runTest will run all tests that have the x bit set --- test/lib/common.inc | 17 +- test/runTest | 628 +---------------------------------------- test/test.d/db-move.sh | 76 +++++ test/test.d/db-remove.sh | 52 ++++ test/test.d/db-update.sh | 127 +++++++++ test/test.d/ftpdir-cleanup.sh | 93 ++++++ test/test.d/packages.sh | 11 + test/test.d/pool-transition.sh | 152 ++++++++++ test/test.d/sourceballs.sh | 85 ++++++ test/test.d/testing2x.sh | 27 ++ 10 files changed, 644 insertions(+), 624 deletions(-) create mode 100755 test/test.d/db-move.sh create mode 100755 test/test.d/db-remove.sh create mode 100755 test/test.d/db-update.sh create mode 100755 test/test.d/ftpdir-cleanup.sh create mode 100755 test/test.d/packages.sh create mode 100755 test/test.d/pool-transition.sh create mode 100755 test/test.d/sourceballs.sh create mode 100755 test/test.d/testing2x.sh (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 34de9eb..ba5d685 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,7 +1,7 @@ set -E -. "${curdir}/../config" -. "${curdir}/../db-functions" +. "$(dirname ${BASH_SOURCE[0]})/../../config" +. "$(dirname ${BASH_SOURCE[0]})/../../db-functions" oneTimeSetUp() { local p @@ -12,7 +12,7 @@ oneTimeSetUp() { local pkgversion local build pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" - cp -r ${curdir}/packages/* "${pkgdir}" + cp -r $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do pushd $d >/dev/null @@ -37,13 +37,12 @@ oneTimeSetUp() { fi for a in ${pkgarch[@]}; do for p in ${pkgname[@]}; do - cp ${p}-${pkgversion}-${a}${PKGEXT} ${curdir}/packages/$(basename ${d}) + cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/$(basename ${d}) done done fi popd >/dev/null done - echo } oneTimeTearDown() { @@ -56,7 +55,7 @@ setUp() { local r local a - [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" + [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #msg "Using ${TMP}" @@ -85,7 +84,7 @@ setUp() { svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done - cat < "${curdir}/../config.local" + cat < "$(dirname ${BASH_SOURCE[0]})/../../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" PKGREPOS=(${PKGREPOS[@]}) @@ -97,12 +96,12 @@ setUp() { CLEANUP_DRYRUN=false SOURCE_CLEANUP_DRYRUN=false eot - . "${curdir}/../config" + . "$(dirname ${BASH_SOURCE[0]})/../../config" } tearDown() { rm -rf "${TMP}" - rm -f "${curdir}/../config.local" + rm -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" echo } diff --git a/test/runTest b/test/runTest index 0fcdf18..b8713d8 100755 --- a/test/runTest +++ b/test/runTest @@ -1,617 +1,15 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) -. "${curdir}/lib/common.inc" - -# -# self test -# - -testPackages() { - # TODO: namcap -r depends fails with i686 packages - find "${pkgdir}" -name "*${PKGEXT}" -exec namcap -e depends {} + || fail 'namcap failed' -} - - -# -# db-update -# - -testAddSimplePackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} - done - done -} - -testAddSingleSimplePackage() { - releasePackage extra 'pkg-simple-a' 'i686' - ../db-update - checkPackage extra 'pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686' -} - -testAddAnyPackages() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any - done - - ../db-update - - for pkgbase in ${pkgs[@]}; do - checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz - done -} - -testAddSplitPackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-split-a' 'pkg-split-b') - local pkg - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do - checkPackage extra $(basename ${pkg}) ${arch} - done - done - done -} - -testUpdateAnyPackage() { - releasePackage extra pkg-any-a any - ../db-update - - pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null - sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 - mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" - popd >/dev/null - - releasePackage extra pkg-any-a any - ../db-update - - checkAnyPackage extra pkg-any-a-1-2-any.pkg.tar.xz any - - rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" -} - -testUpdateAnyPackageToDifferentRepositoriesAtOnce() { - releasePackage extra pkg-any-a any - - pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null - sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 - mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" - popd >/dev/null - - releasePackage testing pkg-any-a any - - ../db-update - - checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any - checkAnyPackage testing pkg-any-a-1-2-any.pkg.tar.xz any - - rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" -} - -testUpdateSameAnyPackageToDifferentRepositories() { - releasePackage extra pkg-any-a any - ../db-update - checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any - - releasePackage testing pkg-any-a any - ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) - - local arch - for arch in i686 x86_64; do - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ - && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - done -} - -# -# db-remove -# - -testRemovePackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-remove ${pkgbase} extra ${arch} - done - done - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackage extra ${pkgbase} ${arch} - done - done -} - -testRemoveAnyPackages() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any - done - - ../db-update - - for pkgbase in ${pkgs[@]}; do - ../db-remove ${pkgbase} extra any - done - - for pkgbase in ${pkgs[@]}; do - checkRemovedAnyPackage extra ${pkgbase} - done -} - - -# -# db-move -# - -testMoveSimplePackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} - done - done - - ../db-update - - ../db-move testing extra pkg-simple-a - - for arch in ${arches[@]}; do - checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} - - checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch} - done -} - -testMoveAnyPackages() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - - for pkgbase in ${pkgs[@]}; do - releasePackage testing ${pkgbase} any - done - - ../db-update - ../db-move testing extra pkg-any-a - - checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz - checkRemovedAnyPackage testing pkg-any-a - checkAnyPackage testing pkg-any-b-1-1-any.pkg.tar.xz -} - -testMoveSplitPackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-split-a' 'pkg-split-b') - local pkg - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} - done - done - - ../db-update - ../db-move testing extra pkg-split-a - - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do - checkPackage extra $(basename ${pkg}) ${arch} - done - done - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-b"/*-${arch}.pkg.tar.*; do - checkPackage testing $(basename ${pkg}) ${arch} - done - done - - checkRemovedAnyPackage testing pkg-split-a -} - - -# -# testing2x -# - -testTesting2xAnyPackage() { - releasePackage core pkg-any-a any - ../db-update - - pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null - sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 - mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" - popd >/dev/null - - releasePackage testing pkg-any-a any - ../db-update - rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" - - ../testing2x pkg-any-a - - checkAnyPackage core pkg-any-a-1-2-any.pkg.tar.xz any - checkRemovedAnyPackage testing pkg-any-a -} - - -# -# ftpdir-cleanup -# - -testCleanupSimplePackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for arch in ${arches[@]}; do - local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" - checkRemovedPackage extra 'pkg-simple-a' ${arch} - [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" - [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" - - local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" - checkPackage extra ${pkg2} ${arch} - done -} - -testCleanupAnyPackages() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - local arch='any' - - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any - done - - ../db-update - ../db-remove pkg-any-a extra any - ../cron-jobs/ftpdir-cleanup >/dev/null - - local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' - checkRemovedAnyPackage extra 'pkg-any-a' - [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" - [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" - - local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" - checkAnyPackage extra ${pkg2} -} - -testCleanupSplitPackages() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-split-a' 'pkg-split-b') - local pkg - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - for arch in ${arches[@]}; do - ../db-remove ${pkgs[0]} extra ${arch} - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do - checkRemovedPackage extra ${pkgs[0]} ${arch} - [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" - [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" - done - - for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}.pkg.tar.*; do - checkPackage extra $(basename ${pkg}) ${arch} - done - done -} - -# -# transition tests -# - -testMovePackagesWithoutPool() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') - local pkgbase - local arch - local pkg - local old - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} - done - done - - ../db-update - - # transform two packages to old style layout - for arch in ${arches[@]}; do - for old in 0 2; do - for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" - done - done - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - ../db-move testing extra ${pkgs[@]} - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do - checkPackage extra $(basename ${pkg}) ${arch} - done - checkRemovedPackage testing ${pkgbase} ${arch} - done - done -} - -testUpdateAnyPackageWithoutPool() { - local pkgname='pkg-any-a' - local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' - local pkg2='pkg-any-a-1-2-any.pkg.tar.xz' - local arch - - - releasePackage extra pkg-any-a any - ../db-update - # transform two packages to old style layout - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" "${FTP_BASE}/extra/os/any" - for arch in i686 x86_64; do - ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" - done - - pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null - sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - extra-i686-build >/dev/null 2>&1 - mv "${pkg2}" "${pkgdir}/${pkgname}/" - popd >/dev/null - - releasePackage extra ${pkgname} any - ../db-update - rm -f "${pkgdir}/${pkgname}/${pkg2}" - - ../cron-jobs/ftpdir-cleanup >/dev/null - - checkAnyPackage extra "${pkg2}" - - [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" - for arch in any i686 x86_64; do - [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" - done -} - -testMoveAnyPackagesWithoutPool() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - local arch - local pkg - - for pkgbase in ${pkgs[@]}; do - releasePackage testing ${pkgbase} any - done - - ../db-update - - # transform a package to old style layout - for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" - for arch in i686 x86_64; do - ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" - done - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - ../db-move testing extra ${pkgs[@]} - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for pkgbase in ${pkgs[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do - checkAnyPackage extra $(basename ${pkg}) - done - checkRemovedAnyPackage testing ${pkgbase} - done - - for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do - pkg=$(basename $pkg) - for arch in any i686 x86_64; do - [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" - done - done -} - -testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { - local pkg - local arch - - releasePackage extra pkg-any-a any - ../db-update - - # transform a package to old style layout - for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" - for arch in i686 x86_64; do - ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" - done - done - - releasePackage testing pkg-any-a any - ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) - - for arch in i686 x86_64; do - ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q pkg-any-a) \ - && fail "pkg-any-a should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" - done -} - -# -#sourceballs tests -# - -testSourceballs() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - ../db-update - - ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" - done -} - -testAnySourceballs() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any - done - ../db-update - - ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" - done -} - -testSplitSourceballs() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-split-a' 'pkg-split-b') - local pkg - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - - ../db-update - - ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" - done -} - -testSourceballsCleanup() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b') - local pkgbase - local arch - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} - done - done - ../db-update - ../cron-jobs/sourceballs - - for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} - done - ../cron-jobs/ftpdir-cleanup >/dev/null - - ../cron-jobs/sourceballs - [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" - [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" -} - -. "${curdir}/lib/shunit2" +. "$(dirname ${BASH_SOURCE[0]})/lib/common.inc" + +for t in "$(dirname ${BASH_SOURCE[0]})/test.d/"*.sh; do + l=$(basename ${t} .sh) + if [ -x ${t} ]; then + msg "Running test '${l}'" + ${t} + [ $? -ne 0 ] && die "Test '${l}' failed" + echo -e "\n\n\n" + else + warning "Skipping test ${l}" + fi +done diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh new file mode 100755 index 0000000..57cbf71 --- /dev/null +++ b/test/test.d/db-move.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testMoveSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update + + ../db-move testing extra pkg-simple-a + + for arch in ${arches[@]}; do + checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + + checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch} + done +} + +testMoveAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage testing ${pkgbase} any + done + + ../db-update + ../db-move testing extra pkg-any-a + + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz + checkRemovedAnyPackage testing pkg-any-a + checkAnyPackage testing pkg-any-b-1-1-any.pkg.tar.xz +} + +testMoveSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update + ../db-move testing extra pkg-split-a + + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/pkg-split-b"/*-${arch}.pkg.tar.*; do + checkPackage testing $(basename ${pkg}) ${arch} + done + done + + checkRemovedAnyPackage testing pkg-split-a +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh new file mode 100755 index 0000000..b66466d --- /dev/null +++ b/test/test.d/db-remove.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testRemovePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-remove ${pkgbase} extra ${arch} + done + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackage extra ${pkgbase} ${arch} + done + done +} + +testRemoveAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + ../db-remove ${pkgbase} extra any + done + + for pkgbase in ${pkgs[@]}; do + checkRemovedAnyPackage extra ${pkgbase} + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh new file mode 100755 index 0000000..3c41b39 --- /dev/null +++ b/test/test.d/db-update.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testAddSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + done + done +} + +testAddSingleSimplePackage() { + releasePackage extra 'pkg-simple-a' 'i686' + ../db-update + checkPackage extra 'pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686' +} + +testAddAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz + done +} + +testAddSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done + done +} + +testUpdateAnyPackage() { + releasePackage extra pkg-any-a any + ../db-update + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + extra-i686-build >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage extra pkg-any-a any + ../db-update + + checkAnyPackage extra pkg-any-a-1-2-any.pkg.tar.xz any + + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" +} + +testUpdateAnyPackageToDifferentRepositoriesAtOnce() { + releasePackage extra pkg-any-a any + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + extra-i686-build >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage testing pkg-any-a any + + ../db-update + + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any + checkAnyPackage testing pkg-any-a-1-2-any.pkg.tar.xz any + + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" +} + +testUpdateSameAnyPackageToDifferentRepositories() { + releasePackage extra pkg-any-a any + ../db-update + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any + + releasePackage testing pkg-any-a any + ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) + + local arch + for arch in i686 x86_64; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh new file mode 100755 index 0000000..e9b977b --- /dev/null +++ b/test/test.d/ftpdir-cleanup.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testCleanupSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-a extra ${arch} + done + + ../cron-jobs/ftpdir-cleanup >/dev/null + + for arch in ${arches[@]}; do + local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" + checkRemovedPackage extra 'pkg-simple-a' ${arch} + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" + + local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" + checkPackage extra ${pkg2} ${arch} + done +} + +testCleanupAnyPackages() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + local arch='any' + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update + ../db-remove pkg-any-a extra any + ../cron-jobs/ftpdir-cleanup >/dev/null + + local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' + checkRemovedAnyPackage extra 'pkg-any-a' + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" + + local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" + checkAnyPackage extra ${pkg2} +} + +testCleanupSplitPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-remove ${pkgs[0]} extra ${arch} + done + + ../cron-jobs/ftpdir-cleanup >/dev/null + + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do + checkRemovedPackage extra ${pkgs[0]} ${arch} + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" + done + + for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/packages.sh b/test/test.d/packages.sh new file mode 100755 index 0000000..324f73a --- /dev/null +++ b/test/test.d/packages.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testPackages() { + # TODO: namcap -r depends fails with i686 packages + find "${pkgdir}" -name "*${PKGEXT}" -exec namcap -e depends {} + || fail 'namcap failed' +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/pool-transition.sh b/test/test.d/pool-transition.sh new file mode 100755 index 0000000..6d82e00 --- /dev/null +++ b/test/test.d/pool-transition.sh @@ -0,0 +1,152 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testMovePackagesWithoutPool() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgbase + local arch + local pkg + local old + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update + + # transform two packages to old style layout + for arch in ${arches[@]}; do + for old in 0 2; do + for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + done + done + done + + ../cron-jobs/ftpdir-cleanup >/dev/null + + ../db-move testing extra ${pkgs[@]} + + ../cron-jobs/ftpdir-cleanup >/dev/null + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-${arch}.pkg.tar.*; do + checkPackage extra $(basename ${pkg}) ${arch} + done + checkRemovedPackage testing ${pkgbase} ${arch} + done + done +} + +testUpdateAnyPackageWithoutPool() { + local pkgname='pkg-any-a' + local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' + local pkg2='pkg-any-a-1-2-any.pkg.tar.xz' + local arch + + + releasePackage extra pkg-any-a any + ../db-update + # transform two packages to old style layout + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" "${FTP_BASE}/extra/os/any" + for arch in i686 x86_64; do + ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" + done + + pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + extra-i686-build >/dev/null 2>&1 + mv "${pkg2}" "${pkgdir}/${pkgname}/" + popd >/dev/null + + releasePackage extra ${pkgname} any + ../db-update + rm -f "${pkgdir}/${pkgname}/${pkg2}" + + ../cron-jobs/ftpdir-cleanup >/dev/null + + checkAnyPackage extra "${pkg2}" + + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" + for arch in any i686 x86_64; do + [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" + done +} + +testMoveAnyPackagesWithoutPool() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + local arch + local pkg + + for pkgbase in ${pkgs[@]}; do + releasePackage testing ${pkgbase} any + done + + ../db-update + + # transform a package to old style layout + for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + for arch in i686 x86_64; do + ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + done + done + + ../cron-jobs/ftpdir-cleanup >/dev/null + + ../db-move testing extra ${pkgs[@]} + + ../cron-jobs/ftpdir-cleanup >/dev/null + + for pkgbase in ${pkgs[@]}; do + for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do + checkAnyPackage extra $(basename ${pkg}) + done + checkRemovedAnyPackage testing ${pkgbase} + done + + for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + for arch in any i686 x86_64; do + [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" + done + done +} + +testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { + local pkg + local arch + + releasePackage extra pkg-any-a any + ../db-update + + # transform a package to old style layout + for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do + pkg=$(basename $pkg) + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" + for arch in i686 x86_64; do + ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" + done + done + + releasePackage testing pkg-any-a any + ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) + + for arch in i686 x86_64; do + ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q pkg-any-a) \ + && fail "pkg-any-a should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh new file mode 100755 index 0000000..45e9b1d --- /dev/null +++ b/test/test.d/sourceballs.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testSourceballs() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + + ../cron-jobs/sourceballs + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + +testAnySourceballs() { + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + ../db-update + + ../cron-jobs/sourceballs + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + +testSplitSourceballs() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + ../cron-jobs/sourceballs + for pkgbase in ${pkgs[@]}; do + [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + done +} + +testSourceballsCleanup() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + ../cron-jobs/sourceballs + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-a extra ${arch} + done + ../cron-jobs/ftpdir-cleanup >/dev/null + + ../cron-jobs/sourceballs + [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" + [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh new file mode 100755 index 0000000..436716d --- /dev/null +++ b/test/test.d/testing2x.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testTesting2xAnyPackage() { + releasePackage core pkg-any-a any + ../db-update + + pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null + sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD + svn commit -q -m"update pkg to pkgrel=2" >/dev/null + extra-i686-build >/dev/null 2>&1 + mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" + popd >/dev/null + + releasePackage testing pkg-any-a any + ../db-update + rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" + + ../testing2x pkg-any-a + + checkAnyPackage core pkg-any-a-1-2-any.pkg.tar.xz any + checkRemovedAnyPackage testing pkg-any-a +} + +. "${curdir}/../lib/shunit2" -- cgit v1.2.3 From 72ed0011f7ff967d8a402c84c5ab5783f9db9987 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 25 Nov 2010 13:31:20 +0100 Subject: sourceballs no longer depends on ftpdir-cleanup being run --- test/test.d/sourceballs.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 45e9b1d..8cba017 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -75,7 +75,6 @@ testSourceballsCleanup() { for arch in ${arches[@]}; do ../db-remove pkg-simple-a extra ${arch} done - ../cron-jobs/ftpdir-cleanup >/dev/null ../cron-jobs/sourceballs [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" -- cgit v1.2.3 From e792abefa6eff4cf54616add0b19d731d486045f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 25 Nov 2010 16:03:44 +0100 Subject: Rewrote create-filelists * use correct locking of the repos * added test case * removes file lists of deleted packages * add compression independent symlink to files db --- test/test.d/create-filelists.sh | 110 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 test/test.d/create-filelists.sh (limited to 'test') diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh new file mode 100755 index 0000000..da76710 --- /dev/null +++ b/test/test.d/create-filelists.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testCreateSimpleFileLists() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + + ../cron-jobs/create-filelists + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/${pkgbase}"; then + fail "usr/bin/${pkgbase} not found in ${arch}/extra.files.tar.gz" + fi + done + done +} + +testCreateAnyFileLists() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + ../db-update + + ../cron-jobs/create-filelists + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/share/${pkgbase}/test"; then + fail "usr/share/${pkgbase}/test not found in ${arch}/extra.files.tar.gz" + fi + done + done +} + +testCreateSplitFileLists() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-split-a' 'pkg-split-b') + local pkg + local pkgbase + local pkgname + local pkgnames + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + + ../cron-jobs/create-filelists + for pkgbase in ${pkgs[@]}; do + pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) + for pkgname in ${pkgnames[@]}; do + for arch in ${arches[@]}; do + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/${pkgname}"; then + fail "usr/bin/${pkgname} not found in ${arch}/extra.files.tar.gz" + fi + done + done + done +} + + +testCleanupFileLists() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + ../db-update + ../cron-jobs/create-filelists + + for arch in ${arches[@]}; do + ../db-remove pkg-simple-a extra ${arch} + done + ../cron-jobs/create-filelists + + for arch in ${arches[@]}; do + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/pkg-simple-b"; then + fail "usr/bin/pkg-simple-b not found in ${arch}/extra.files.tar.gz" + fi + if bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra.files.tar.gz" | grep -q "usr/bin/pkg-simple-a"; then + fail "usr/bin/pkg-simple-a still found in ${arch}/extra.files.tar.gz" + fi + done + +} + +. "${curdir}/../lib/shunit2" -- cgit v1.2.3 From 69721f4e42fa296de2d5a568d07758888c354328 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Nov 2010 03:08:59 +0100 Subject: Fix test: copy target of symlinks --- test/lib/common.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index ba5d685..208400c 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -12,7 +12,7 @@ oneTimeSetUp() { local pkgversion local build pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" - cp -r $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" + cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do pushd $d >/dev/null @@ -79,7 +79,7 @@ setUp() { for p in "${pkgdir}"/*; do pkg=$(basename $p) mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} - cp "${p}/PKGBUILD" "${TMP}/svn-packages-copy"/${pkg}/trunk/ + cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/ svn add -q "${TMP}/svn-packages-copy"/${pkg} svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done -- cgit v1.2.3 From 6037b3e9aa414d94cd14b8c51b9b04be054c5e04 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 2 Dec 2010 18:06:45 +0100 Subject: db-update: Fail if a set of split packages is incomplete --- test/test.d/db-update.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 3c41b39..ad0be32 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -124,4 +124,27 @@ testUpdateSameAnyPackageToDifferentRepositories() { done } + +testAddIncompleteSplitPackage() { + local arches=('i686' 'x86_64') + local repo='extra' + local pkgbase='pkg-split-a' + local arch + + for arch in ${arches[@]}; do + releasePackage ${repo} ${pkgbase} ${arch} + done + + # remove a split package to make db-update fail + rm "${STAGING}"/extra/${pkgbase}1-* + + ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" + + for arch in ${arches[@]}; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + done +} + . "${curdir}/../lib/shunit2" -- cgit v1.2.3 From 7222a50e44f815fd2ba17a9a94efd3cc9fa4bcd7 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 27 Jan 2011 13:30:02 +0100 Subject: test: add testUpdateSameAnyPackageToSameRepository --- test/test.d/db-update.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index ad0be32..5a3d01d 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -108,6 +108,15 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { rm -f "${pkgdir}/pkg-any-a/pkg-any-a-1-2-any.pkg.tar.xz" } +testUpdateSameAnyPackageToSameRepository() { + releasePackage extra pkg-any-a any + ../db-update + checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz any + + releasePackage extra pkg-any-a any + ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to the same repository should fail'; return 1) +} + testUpdateSameAnyPackageToDifferentRepositories() { releasePackage extra pkg-any-a any ../db-update @@ -118,9 +127,9 @@ testUpdateSameAnyPackageToDifferentRepositories() { local arch for arch in i686 x86_64; do - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ - && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" done } -- cgit v1.2.3