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 15 function 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 27 function 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 36 if [[ -z $ELF_TESTS ]]; then 37 print -u2 "Don't know where the test data is rooted"; 38 exit 1; 39 fi 40 41 make -f ${ELF_TESTS}/tests/tls/x86/ld/Makefile.test 42 43 dis_test "call-->nop" main half-ldm \ 44 'main\+0x9: 0f 1f 44 00 00 nopl 0x0(%eax,%eax)' 45 46 ./half-ldm | grep_test 'half-ldm execution' \ 47 '^foo: foo ([a-f0-9]*)$'