1#!/bin/sh -ex
2# $OpenBSD: test.sh,v 1.1 2012/06/15 20:50:06 matthew Exp $
3
4export LD_LIBRARY_PATH=.
5export LD_TRACE_LOADED_OBJECTS_FMT1='lib%o.so\n'
6export LD_TRACE_LOADED_OBJECTS_FMT2='%o\n'
7
8res=0
9
10test() {
11  if "$@"; then
12    echo "passed"
13  else
14    echo "FAILED"
15    res=1
16  fi
17}
18
19for i in 1 2 3; do
20  test ldd lib${i}.so
21  test ./dlopen -lib${i}.so
22
23  for j in 1 2 3; do
24    test env LD_PRELOAD=lib${j}.so ./dlopen +lib${i}.so
25    test ./dlopen${j} +lib${i}.so
26  done
27done
28
29exit $res
30