File: test_build.sh

package info (click to toggle)
flashprog 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,104 kB
  • sloc: ansic: 61,779; makefile: 919; sh: 310
file content (45 lines) | stat: -rwxr-xr-x 1,592 bytes parent folder | download
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
#!/bin/sh
set -e

TEMP_DIR=$(mktemp -d)
trap "rm -rf ${TEMP_DIR}" EXIT

dd bs=$((128*1024)) count=1 </dev/urandom >"${TEMP_DIR}/rand"
dd bs=$((128*1024)) count=1 </dev/urandom >"${TEMP_DIR}/rand2"
dd bs=$((128*1024)) count=1 </dev/zero | tr '\000' '\377' >"${TEMP_DIR}/empty"

test_prog() {
	prog="$1"

	if [ "${CROSS_COMPILE}" ]; then
		return 0
	fi

	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -w "${TEMP_DIR}/rand"
	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -r "${TEMP_DIR}/bak"
	cmp "${TEMP_DIR}/rand" "${TEMP_DIR}/bak"

	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -c M25P10 -w "${TEMP_DIR}/rand2"
	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -c M25P10 -v "${TEMP_DIR}/rand2"

	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -c M25P10 -E
	"${prog}" -p dummy:emulate=M25P10.RES,image="${TEMP_DIR}/image" -c M25P10 -v "${TEMP_DIR}/empty"
}

if [ "${MAKECMD=make}" ]; then
	${MAKECMD} clean
	eval ${MAKECMD} -j${CPUS:-$(nproc)} CC="\"${CC:-ccache cc}\"" ${MAKEARGS-CONFIG_EVERYTHING=yes}
	test_prog ./flashprog
fi

if [ "${MESONCMD=meson}" ]; then
	eval ${MESONCMD} setup ${MESONARGS--D programmer=all --buildtype release} "${TEMP_DIR}/build"
	ninja ${CPUS:+-j${CPUS}} -C "${TEMP_DIR}/build"
	test_prog "${TEMP_DIR}/build/flashprog"

	if [ "${MAKECMD}" -a ! "${CROSS_COMPILE}" ]; then
		./flashprog -L >"${TEMP_DIR}/flashprog.supported"
		"${TEMP_DIR}/build/flashprog" -L >"${TEMP_DIR}/mashprog.supported"
		diff -u "${TEMP_DIR}/flashprog.supported" "${TEMP_DIR}/mashprog.supported"
	fi
fi