|
root / base / usr / src / test / libc-tests / tests / aligned_alloc.ksh
aligned_alloc.ksh Bash 75 lines 1.6 KB
 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
#! /usr/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2024 Oxide Computer Company
#

#
# Wrap up the aligned_alloc() tests with the different malloc libraries
# that make sense to test as this calls into their implementation of
# memalign. Currently we test libc, libumem, and libmtmalloc. mapmalloc
# is skipped because it doesn't implement memalign. libmtmalloc
# currently doesn't have an ENOMEM/EAGAIN test strategy.
#

unalias -a
set -o pipefail
export LANG=C.UTF-8

alloc_arg0="$(basename $0)"
alloc_dir="$(dirname $0)"
alloc_exit=0
alloc_file="aligned_alloc"
alloc_libraries="none
libumem.so
libmtmalloc.so"
alloc_archs="32
64"

function warn
{
	typeset msg="$*"
	echo "TEST FAILED: $msg" >&2
	alloc_exit=1
}

function run_one
{
	typeset preload="$1"
	typeset suffix="$2"

	if [[ "$1" != none ]]; then
		export LD_PRELOAD=$preload
	fi

	printf "Running %u-bit tests with library %s\n" $suffix "$preload"

	if ! $alloc_dir/$alloc_file.$suffix; then
		alloc_exit=1
	fi

	unset LD_PRELOAD
}

for lib in ${alloc_libraries[@]}; do
	for arch in ${alloc_archs[@]}; do
		run_one "$lib" "$arch"
	done
done

if ((alloc_exit != 0)); then
	printf "Some library/architecture variants failed!\n" >&2
fi

exit $alloc_exit