File: utils.sh

package info (click to toggle)
ust 2.14.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,368 kB
  • sloc: xml: 78,798; ansic: 47,114; sh: 5,806; java: 2,202; makefile: 1,833; python: 727; cpp: 384
file content (63 lines) | stat: -rwxr-xr-x 1,466 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
#!/bin/bash
#
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (c) 2019 Michael Jeanson <mjeanson@efficios.com>
# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
#

# This file is meant to be sourced at the start of shell script-based tests.


# Error out when encountering an undefined variable
set -u

# If "readlink -f" is available, get a resolved absolute path to the
# tests source dir, otherwise make do with a relative path.
scriptdir="$(dirname "${BASH_SOURCE[0]}")"
if readlink -f "." >/dev/null 2>&1; then
	testsdir=$(readlink -f "$scriptdir/..")
else
	testsdir="$scriptdir/.."
fi

# Allow overriding the source and build directories
if [ "x${UST_TESTS_SRCDIR:-}" = "x" ]; then
	UST_TESTS_SRCDIR="$testsdir"
fi
export UST_TESTS_SRCDIR

if [ "x${UST_TESTS_BUILDDIR:-}" = "x" ]; then
	UST_TESTS_BUILDDIR="$testsdir"
fi
export UST_TESTS_BUILDDIR

# The OS on which we are running. See [1] for possible values of 'uname -s'.
# We do a bit of translation to ease our life down the road for comparison.
# Export it so that called executables can use it.
# [1] https://en.wikipedia.org/wiki/Uname#Examples
if [ "x${UST_OS_TYPE:-}" = "x" ]; then
	UST_OS_TYPE="$(uname -s)"
	case "$UST_OS_TYPE" in
	MINGW*)
		UST_OS_TYPE="mingw"
		;;
	Darwin)
		UST_OS_TYPE="darwin"
		;;
	Linux)
		UST_OS_TYPE="linux"
		;;
	CYGWIN*)
		UST_OS_TYPE="cygwin"
		;;
	FreeBSD)
		UST_OS_TYPE="freebsd"
		;;
	*)
		UST_OS_TYPE="unsupported"
		;;
	esac
fi
export UST_OS_TYPE