summaryrefslogtreecommitdiffstats
path: root/debian/transcode/transcode-1.1.7/testsuite/test-tcmodchain.sh
blob: 3502c8c7b640175193ad7561553e5886d76ec331 (plain)
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
#!/bin/bash
#
# test-tcmodchain.sh -- modules compatibility testsuite.
# (C) 2007-2010 - Francesco Romani <fromani -at- gmail -dot- com>
#
# This file is part of transcode, a video stream processing tool.
#
# transcode 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 of the License, or
# (at your option) any later version.
#
# transcode 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, see <http://www.gnu.org/licenses/>.

# FIXME: default args,

# get program path, if given
TCMODCHAIN="tcmodchain"
if [ -n "$1" ]; then
	TCMODCHAIN="$1"
fi

if [ ! -x "$TCMODCHAIN" ]; then
	echo "missing tcmodchain program, test aborted" 1>&2
	exit 1
fi

# test helper

# $1, $2 -> modules
# $3, expected return code
function check_test() {
	if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
		echo "bad test parameters (skipped)" 1>&2
		return 1
	fi
	$TCMODCHAIN -C $1 $2 -d 0 # silent operation
	local RET="$?"
	if [ "$RET" == "$3" ]; then
		printf "testing check (%16s) with (%16s) | OK\n" $1 $2
	else
		printf "testing check (%16s) with (%16s) | >> FAILED << [exp=%i|got=%i]\n" $1 $2 $3 $RET
	fi
	return $RET
}

# $1, $2 -> modules
# $3, expected result list
function list_test() {
	if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
		echo "bad test parameters (skipped)" 1>&2
		return 1
	fi
	local GOT=$( $TCMODCHAIN -L $1 $2 | sort | tr '\n' ' ' | sed s/\ $//g )
	if [ "$GOT" == "$3" ]; then
		printf "testing list  (%16s) with (%16s) | OK\n" $1 $2
	else
		printf "testing list  (%16s) with (%16s) | >> FAILED <<\n" $1 $2
		printf "    expected=\"%s\"" $3
		printf "    received=\"%s\"" $GOT
	fi
	return $RET
}



## `check' (-C) tests first
#
check_test "encode:null" "multiplex:null" 0
check_test "encode:copy" "multiplex:null" 0
check_test "encode:xvid" "multiplex:null" 0
check_test "encode:x264" "multiplex:null" 0
check_test "encode:lame" "multiplex:null" 0
check_test "encode:faac" "multiplex:null" 0
check_test "encode:lzo"  "multiplex:null" 0
#
check_test "encode:null" "multiplex:raw" 0
check_test "encode:copy" "multiplex:raw" 0
check_test "encode:xvid" "multiplex:raw" 0
check_test "encode:x264" "multiplex:raw" 0
check_test "encode:lame" "multiplex:raw" 0
check_test "encode:faac" "multiplex:raw" 0
check_test "encode:lzo"  "multiplex:raw" 0
#
check_test "encode:null" "multiplex:avi" 0
check_test "encode:copy" "multiplex:avi" 0
check_test "encode:xvid" "multiplex:avi" 0
check_test "encode:x264" "multiplex:avi" 0
check_test "encode:lame" "multiplex:avi" 0
check_test "encode:faac" "multiplex:avi" 0
check_test "encode:lzo"  "multiplex:avi" 0
#
# see manpage for return code meaning
check_test "encode:null" "multiplex:y4m" 0
check_test "encode:copy" "multiplex:y4m" 0
check_test "encode:xvid" "multiplex:y4m" 3
check_test "encode:x264" "multiplex:y4m" 3
check_test "encode:lame" "multiplex:y4m" 3
check_test "encode:faac" "multiplex:y4m" 3
check_test "encode:lzo"  "multiplex:y4m" 3
#
## `check' (-L) tests then
#
list_test "encode:*" "multiplex:null" "copy faac lame lzo null x264 xvid"
list_test "encode:*" "multiplex:raw"  "copy faac lame lzo null x264 xvid"
list_test "encode:*" "multiplex:avi"  "copy faac lame lzo null x264 xvid"
list_test "encode:*" "multiplex:y4m"  "copy null"
#
list_test "encode:copy" "multiplex:*" "avi null raw y4m"
list_test "encode:faac" "multiplex:*" "avi null raw"
list_test "encode:lame" "multiplex:*" "avi null raw"
list_test "encode:lzo"  "multiplex:*" "avi null raw"
list_test "encode:null" "multiplex:*" "avi null raw y4m"
list_test "encode:x264" "multiplex:*" "avi null raw"
list_test "encode:xvid" "multiplex:*" "avi null raw"