xref: /illumos-gate/usr/src/test/elf-tests/tests/tls/i386/ld/i386-ld-test.sh (revision 4db555a5389470c6f15aa8b50a38ca5d533d0641)
1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13# Copyright 2012, Richard Lowe.
14
15function grep_test {
16    name=$1
17    pattern=$2
18
19    if /usr/bin/grep -q "${pattern}"; then
20	print -u2 "pass: $name"
21        else
22        print -u2 "FAIL: $name"
23        exit 1
24    fi
25}
26
27function dis_test {
28    name=${1}
29    func=${2}
30    file=${3}
31    pattern=${4}
32
33    dis -F${func} ${file} | grep_test "${name}" "${pattern}"
34}
35
36TESTDIR=$(dirname $0)
37make -f ${TESTDIR}/Makefile.test TESTDIR=${TESTDIR}
38
39dis_test "call-->nop" main half-ldm \
40    'main\+0x9:  0f 1f 44 00 00     nopl   0x0(%eax,%eax)'
41
42./half-ldm | grep_test 'half-ldm execution' \
43    '^foo: foo ([a-f0-9]*)$'
44