File: run.sh

package info (click to toggle)
win32-loader 0.10.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,868 kB
  • sloc: ansic: 2,492; sh: 706; asm: 344; makefile: 338
file content (127 lines) | stat: -rwxr-xr-x 2,985 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
#!/bin/sh
# Licensed under the zlib/libpng license (same as NSIS)
#
# Script to perform cpio tests
#
# Usage: run.sh [<helper dir [<Windows architecture> [<test dir>]]]

set -e

CPIO_NAME="archive.cpio"
OUTPUT="output.log"
SCRIPT="cpio_test.nsi"
SOURCEDIR=$(cd "$(dirname "$0")"; pwd -P)
TOPDIR=$(cd "${SOURCEDIR}/../.."; pwd -P)
HELPERDIR=${1:-"${TOPDIR}/build"}

INSTALLER="${SCRIPT%.*}.exe"
UNINSTALLER="uninstall.exe"

TESTID=

ERROR_SUCCESS=0
ERROR_FILE_NOT_FOUND=2
ERROR_INVALID_DATA=13

. "${SOURCEDIR}/../common/funcs.sh"

before() {
	make_installer "-XOutFile ${PWD}/${INSTALLER}" \
		"${SOURCEDIR}/${SCRIPT}"
}

after() {
	[ -n "${TESTID}" -a -f "${TESTID}" ] && rm "${TESTID}"
	[ -f "${CPIO_NAME}" ] && rm "${CPIO_NAME}"
	[ -f "${OUTPUT}" ] && rm "${OUTPUT}"
	[ -f "${INSTALLER}" ] && rm "${INSTALLER}"
	[ -f "${UNINSTALLER}" ] && rm "${UNINSTALLER}"
}

check_cpio() {
	result=$1
	if [ "${result}" = "${ERROR_SUCCESS}" ]; then
		cpio --extract --to-stdout < "${CPIO_NAME}" | \
			diff -q "${t}" -
		if [ $? -ne 0 ]; then
			result=${ERROR_INVALID_DATA}
		fi
	fi
	result=$(assert_equal "${ERROR_SUCCESS}" "${result}")
	check_result $? "${result} ($2)"
}

test_it() {
	if [ $# -gt 0 ]; then
		t="${1}"
		echo "${t}"
		run_installer ${INSTALLER} "/IN=${t}" "/OUT=${CPIO_NAME}" \
			"/RESULT=${OUTPUT}" || exit 1
		result=$(tail -n 1 ${OUTPUT})
		check_cpio ${result} "Installer"
		rm -f ${OUTPUT}
		run_uninstaller ${UNINSTALLER} "/IN=${t}" "/OUT=${CPIO_NAME}" \
			"/RESULT=${OUTPUT}" || exit 1
		result=$(tail -n 1 ${OUTPUT})
		check_cpio ${result} "Uninstaller"
		[ -f "${t}" ] && rm "${t}"
		[ -f "${CPIO_NAME}" ] && rm "${CPIO_NAME}"
		rm -f ${OUTPUT}
	fi
}

test_non_existent_file() {
        t="non_existent_file"
	echo "${t}"
	run_installer ${INSTALLER} "/IN=${t}" "/OUT=${CPIO_NAME}" \
		"/RESULT=${OUTPUT}" || exit 1
	result=$(assert_equal $(tail -n 1 ${OUTPUT}) \
		"${ERROR_FILE_NOT_FOUND}")
	check_result $? "${result} (Installer)"
	rm -f ${OUTPUT}
	run_uninstaller ${UNINSTALLER} "/IN=${t}" "/OUT=${CPIO_NAME}" \
		"/RESULT=${OUTPUT}" || exit 1
	result=$(assert_equal $(tail -n 1 ${OUTPUT}) \
		"${ERROR_FILE_NOT_FOUND}")
	check_result $? "${result} (Uninstaller)"
	rm -f ${OUTPUT}

}

test_empty_file() {
        TESTID="empty_file"
	touch ${TESTID}
	test_it "${TESTID}"
}

test_preseed_cfg() {
	TESTID=preseed_cfg
	cat << EOF > ${TESTID}
d-i debian-installer/locale string en_CA
d-i netcfg/get_domain string string example.com
d-i netcfg/get_domain seen false
d-i time/zone string America/New_York
d-i time/zone seen false
d-i console-keymaps-at/keymap select us
d-i console-keymaps-at/keymap seen false
d-i netcfg/get_hostname string debian
d-i netcfg/get_hostname seen false
d-i passwd/user-fullname string user
d-i passwd/user-fullname seen false
d-i mirror/http/proxy seen true
EOF
	test_it "${TESTID}"
}

main() {
	test_non_existent_file
	test_empty_file
	test_preseed_cfg
}

[ $# -gt 1 ] && shift
wine_set_up "${@}"
before
main
after
wine_clean_up "${@}"