xref: /aosp_15_r20/external/strace/tests-m32/qualify_personality.sh (revision cf84ac9a129d8ea9952db616b4e9b904c4bdde56)
1*cf84ac9aSAndroid Build Coastguard Worker#! /bin/sh -efu
2*cf84ac9aSAndroid Build Coastguard Worker#
3*cf84ac9aSAndroid Build Coastguard Worker# Common code for per-personality qualification tests
4*cf84ac9aSAndroid Build Coastguard Worker#
5*cf84ac9aSAndroid Build Coastguard Worker# Copyright (c) 2018 The strace developers.
6*cf84ac9aSAndroid Build Coastguard Worker# All rights reserved.
7*cf84ac9aSAndroid Build Coastguard Worker#
8*cf84ac9aSAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without
9*cf84ac9aSAndroid Build Coastguard Worker# modification, are permitted provided that the following conditions
10*cf84ac9aSAndroid Build Coastguard Worker# are met:
11*cf84ac9aSAndroid Build Coastguard Worker# 1. Redistributions of source code must retain the above copyright
12*cf84ac9aSAndroid Build Coastguard Worker#    notice, this list of conditions and the following disclaimer.
13*cf84ac9aSAndroid Build Coastguard Worker# 2. Redistributions in binary form must reproduce the above copyright
14*cf84ac9aSAndroid Build Coastguard Worker#    notice, this list of conditions and the following disclaimer in the
15*cf84ac9aSAndroid Build Coastguard Worker#    documentation and/or other materials provided with the distribution.
16*cf84ac9aSAndroid Build Coastguard Worker# 3. The name of the author may not be used to endorse or promote products
17*cf84ac9aSAndroid Build Coastguard Worker#    derived from this software without specific prior written permission.
18*cf84ac9aSAndroid Build Coastguard Worker#
19*cf84ac9aSAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20*cf84ac9aSAndroid Build Coastguard Worker# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21*cf84ac9aSAndroid Build Coastguard Worker# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22*cf84ac9aSAndroid Build Coastguard Worker# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23*cf84ac9aSAndroid Build Coastguard Worker# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24*cf84ac9aSAndroid Build Coastguard Worker# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25*cf84ac9aSAndroid Build Coastguard Worker# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26*cf84ac9aSAndroid Build Coastguard Worker# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27*cf84ac9aSAndroid Build Coastguard Worker# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28*cf84ac9aSAndroid Build Coastguard Worker# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*cf84ac9aSAndroid Build Coastguard Worker
30*cf84ac9aSAndroid Build Coastguard Worker. "${srcdir=.}/init.sh"
31*cf84ac9aSAndroid Build Coastguard Worker
32*cf84ac9aSAndroid Build Coastguard Worker[ 2 -le "$#" ] ||
33*cf84ac9aSAndroid Build Coastguard Worker	fail_ 'No personality designation ("64", "32", "x32") specified'
34*cf84ac9aSAndroid Build Coastguard Worker
35*cf84ac9aSAndroid Build Coastguard Workerpers="$1"
36*cf84ac9aSAndroid Build Coastguard Workershift
37*cf84ac9aSAndroid Build Coastguard Workertrace_expr="$1"
38*cf84ac9aSAndroid Build Coastguard Workershift
39*cf84ac9aSAndroid Build Coastguard Workerskip="${1-}"
40*cf84ac9aSAndroid Build Coastguard Worker
41*cf84ac9aSAndroid Build Coastguard Workercase "$STRACE_NATIVE_ARCH" in
42*cf84ac9aSAndroid Build Coastguard Workerx86_64)
43*cf84ac9aSAndroid Build Coastguard Worker	supported_pers='64 32 x32'
44*cf84ac9aSAndroid Build Coastguard Worker	;;
45*cf84ac9aSAndroid Build Coastguard Workerx32)
46*cf84ac9aSAndroid Build Coastguard Worker	supported_pers='x32 32'
47*cf84ac9aSAndroid Build Coastguard Worker	;;
48*cf84ac9aSAndroid Build Coastguard Workeraarch64|powerpc64|riscv|s390x|sparc64|tile)
49*cf84ac9aSAndroid Build Coastguard Worker	supported_pers='64 32'
50*cf84ac9aSAndroid Build Coastguard Worker	;;
51*cf84ac9aSAndroid Build Coastguard Worker*)
52*cf84ac9aSAndroid Build Coastguard Worker	supported_pers="$(($SIZEOF_LONG * 8))"
53*cf84ac9aSAndroid Build Coastguard Worker	;;
54*cf84ac9aSAndroid Build Coastguard Workeresac
55*cf84ac9aSAndroid Build Coastguard Worker
56*cf84ac9aSAndroid Build Coastguard Worker# Detect current personality designation
57*cf84ac9aSAndroid Build Coastguard Workerif [ "x$STRACE_NATIVE_ARCH" = "x$STRACE_ARCH" ]; then
58*cf84ac9aSAndroid Build Coastguard Worker	case "$STRACE_NATIVE_ARCH" in
59*cf84ac9aSAndroid Build Coastguard Worker	x32)
60*cf84ac9aSAndroid Build Coastguard Worker		cur_pers=x32
61*cf84ac9aSAndroid Build Coastguard Worker		;;
62*cf84ac9aSAndroid Build Coastguard Worker	*)
63*cf84ac9aSAndroid Build Coastguard Worker		cur_pers="$(($SIZEOF_LONG * 8))"
64*cf84ac9aSAndroid Build Coastguard Worker		;;
65*cf84ac9aSAndroid Build Coastguard Worker	esac
66*cf84ac9aSAndroid Build Coastguard Workerelse
67*cf84ac9aSAndroid Build Coastguard Worker	if [ "x$SIZEOF_KERNEL_LONG_T" = "x$SIZEOF_LONG" ]; then
68*cf84ac9aSAndroid Build Coastguard Worker		[ 4 -eq "$SIZEOF_LONG" ] ||
69*cf84ac9aSAndroid Build Coastguard Worker			fail_ "sizeof(long) = $SIZEOF_LONG != 4"
70*cf84ac9aSAndroid Build Coastguard Worker		cur_pers=32
71*cf84ac9aSAndroid Build Coastguard Worker	else
72*cf84ac9aSAndroid Build Coastguard Worker		[ 8 -eq "$SIZEOF_KERNEL_LONG_T" ] ||
73*cf84ac9aSAndroid Build Coastguard Worker			fail_ "sizeof(kernel_long_t) = $SIZEOF_KERNEL_LONG_T != 8"
74*cf84ac9aSAndroid Build Coastguard Worker		[ 4 -eq "$SIZEOF_LONG" ] ||
75*cf84ac9aSAndroid Build Coastguard Worker			fail_ "sizeof(long) = $SIZEOF_LONG != 4"
76*cf84ac9aSAndroid Build Coastguard Worker		cur_pers=x32
77*cf84ac9aSAndroid Build Coastguard Worker	fi
78*cf84ac9aSAndroid Build Coastguard Workerfi
79*cf84ac9aSAndroid Build Coastguard Worker
80*cf84ac9aSAndroid Build Coastguard Workerpers_found=0
81*cf84ac9aSAndroid Build Coastguard Workerset -- $supported_pers
82*cf84ac9aSAndroid Build Coastguard Workerfor i; do
83*cf84ac9aSAndroid Build Coastguard Worker	[ "x$pers" != "x$i" ] || pers_found=1
84*cf84ac9aSAndroid Build Coastguard Workerdone
85*cf84ac9aSAndroid Build Coastguard Worker
86*cf84ac9aSAndroid Build Coastguard Worker[ "$pers_found" = 1 ] ||
87*cf84ac9aSAndroid Build Coastguard Worker	skip_ "Personality '$pers' is not supported on architecture" \
88*cf84ac9aSAndroid Build Coastguard Worker	      "'$STRACE_NATIVE_ARCH' (supported personalities: $supported_pers)"
89*cf84ac9aSAndroid Build Coastguard Worker
90*cf84ac9aSAndroid Build Coastguard Worker# If tested personality is not equivalent to current personality, reset $NAME,
91*cf84ac9aSAndroid Build Coastguard Worker# so "$NAME.in", which is used by test_trace_expr, points to an empty file.
92*cf84ac9aSAndroid Build Coastguard Worker[ "x$pers" = "x$cur_pers" ] || NAME=qualify_personality_empty
93*cf84ac9aSAndroid Build Coastguard Worker
94*cf84ac9aSAndroid Build Coastguard Workertest_trace_expr "$skip" -e trace="${trace_expr}@${pers}"
95