File: run

package info (click to toggle)
signify-openbsd 32-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 676 kB
  • sloc: ansic: 5,445; makefile: 174; sh: 72
file content (65 lines) | stat: -rwxr-xr-x 1,552 bytes parent folder | download | duplicates (3)
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
#! /bin/sh
#
# Simple test harness for OpenBSD's Signify tests.
# Copyright (C) 2019 Adrian Perez de Castro <aperez@igalia.com>
#
# Distributed under terms of the MIT license.
#

_th__dir_path=$(dirname "$0")

_th__sha256_program=$(command -v sha256)
if ! [ -x "$_th__sha256_program" ] ; then
	# Try to use GNU coreutils' sha256sum as fallback.
	_th__sha256_program=$(command -v sha256sum)
	if ! [ -x "$_th__sha256_program" ] ; then
		echo 'Cannot find sha256/sha256sum' 1>&2
		exit 1
	fi
	if "$_th__sha256_program" --version 2> /dev/null | grep -q coreutils ; then
		sha256 () {
			"$_th__sha256_program" --tag "$@"
		}
	else
		echo 'The sha256sum program is not the GNU coreutils version' 1>&2
		exit 1
	fi
fi

_th__sha512_program=$(command -v sha512)
if ! [ -x "$_th__sha512_program" ] ; then
	# Ditto, try for sha512sum.
	_th__sha512_program=$(command -v sha512sum)
	if ! [ -x "$_th__sha512_program" ] ; then
		echo 'Cannot find sha512/sha512sum' 1>&2
		exit 1
	fi
	if "$_th__sha512_program" --version 2> /dev/null | grep -q coreutils ; then
		sha512 () {
			"$_th__sha512_program" --tag "$@"
		}
	else
		echo 'The sha512sum program is not the GNU coreutils version' 1>&2
		exit 1
	fi
fi

# Point to the locally-built signify program
signify () {
	echo " - signify $* ..." 1>&2
	"../../signify" "$@"
}

# Harness configured. Go!
echo 'Running tests:'
cd "$_th__dir_path" || exit 2
set -- "$(pwd)"
test -d out || mkdir out
cd out || exit 3
. ../signify.sh ; rc=$?
if [ $rc -eq 0 ] ; then
	echo 'Tests passed.'
else
	echo 'Tests failed.'
fi
exit $rc