File: testsuite_functions

package info (click to toggle)
cdbs 0.4.52
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,032 kB
  • ctags: 55
  • sloc: sh: 4,535; xml: 2,075; makefile: 157; perl: 64; python: 16; ansic: 7; java: 5
file content (131 lines) | stat: -rw-r--r-- 2,895 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# -*- mode: sh; coding: utf-8 -*-
# Copyright © 2003 Jeff Bailey <jbailey@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.

if test "$(basename $(pwd))" != 'test'; then
  echo "error: test must be run in test subdir"
  exit 1
fi

_cdbs_test_basedir=`pwd`/workdir
WORKDIR=$_cdbs_test_basedir/cdbs-testsuite-0.1
SRCDIR=$(realpath $(dirname $0)/../)

eval `dpkg-architecture -s`

setup_workdir () {
  clean_workdir
  mkdir -p $WORKDIR/debian
  cp -R debian/* $WORKDIR/debian
}

clean_workdir () {
  if [ ! $_cdbs_noclean ]; then
    rm -rf $_cdbs_test_basedir
  fi
}

return_fail () {
  if [ ! $_cdbs_quiet ]; then
    echo "This test has failed."
  fi
  exit 1
}

return_ignore () {
  if [ ! $_cdbs_quiet ]; then
    echo "This test has been skipped."
  fi
  exit 77
}

return_pass () {
  if [ ! $_cdbs_quiet ]; then
    echo "This test has passed."
  fi
  exit 0
}

build_package () {
  pushd $WORKDIR >/dev/null
  build_package_1
  popd >/dev/null
}

clean_package () {
  pushd $WORKDIR >/dev/null
  clean_package_1
  popd >/dev/null
}

get_package_contents () {
  tempd=$(mktemp -d)
  dpkg -X "$1" "$tempd"
  rm -rf "$tempd"
}

build_package_1 () {
  eval "dpkg-buildpackage -rfakeroot -us -uc $_cdbs_silent"
  _cdbs_retval=$?
  if [ $_cdbs_retval != 0 ]; then
    return_fail
  fi
}  

clean_package_1 () {
  eval "fakeroot ./debian/rules clean $_cdbs_silent"
  _cdbs_retval=$?
  if [ $_cdbs_retval != 0 ]; then
    return_fail
  fi
}  

test_tarballs () {
  eval "make tarballs $_cdbs_silent"
}

options () {
  progname="`basename \"$0\"`"

while [ $# != 0 ]; do
        case "$1" in
	--noclean)	_cdbs_noclean=yes;;
        --quiet)        _cdbs_quiet=yes;;
        --help)         usage; exit 0;;
        *) echo >&2 "$progname: unknown option or argument $1"; usage; exit 2;;
        esac
        shift
done

# Handle the TESTS_SILENT case
if [ $TESTS_SILENT ]; then
  _cdbs_quiet="yes"
fi

if [ $_cdbs_quiet ]; then
  _cdbs_silent=">/dev/null 2>&1"
fi

}

usage () {
    echo "usage:"
    echo " --noclean            Do not delete temporary files"
    echo " --quiet              Silence all output"
    echo " --help               Display this message"
}