summaryrefslogtreecommitdiffstats
path: root/tests/plat_is_concerned.sh
blob: 126e36a713ccb7ff101a1ba2fc89b93848bfa9fe (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
#!/bin/sh
#
# plat_is_concerned() tests
#
# Copyright (C) 2014  Patrick "P. J." McDermott
#
# This file is part of the ProteanOS Development Kit.
#
# The ProteanOS Development Kit 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 3 of the
# License, or (at your option) any later version.
#
# The ProteanOS Development Kit 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 the ProteanOS Development Kit.  If not, see
# <http://www.gnu.org/licenses/>.

do_test()
{
	local host_plat="${1}"
	local plats="${2}"
	local result="${3}"

	if plat_is_concerned "${host_plat}" "${plats}"; then
		if ! ${result}; then
			printf 'False positive:\n'
			printf '  Host platform:     "%s"\n' "${host_plat}"
			printf '  Package platforms: "%s"\n' "${plats}"
			tests_es=1
		fi
	else
		if ${result}; then
			printf 'False negative:\n'
			printf '  Host platform:     "%s"\n' "${host_plat}"
			printf '  Package platforms: "%s"\n' "${plats}"
			tests_es=1
		fi
	fi
}

main()
{
	# Platform: all
	do_test dev 'all' false
	do_test ao751h 'all' false
	do_test all 'all' true

	# Platform: any
	do_test dev 'any' true
	do_test ao751h 'any' true
	do_test all 'any' false

	# Platform: dev
	do_test dev 'dev' true
	do_test ao751h 'dev' false
	do_test all 'dev' false

	# Platform: !dev
	do_test dev '!dev' false
	do_test ao751h '!dev' true
	do_test all '!dev' false

	# Platform: dev dimension2400
	do_test 'dev' 'dev dimension2400' true
	do_test 'ao751h' 'dev dimension2400' false
	do_test 'all' 'dev dimension2400' false

	# Platform: dev all
	do_test 'dev' 'dev all' true
	do_test 'ao751h' 'dev all' false
	do_test 'all' 'dev all' true

	return 0
}