1#!/usr/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#
14# Copyright 2018, Richard Lowe.
15#
16
17# Test that a simple use of linker-sets, that is, automatically generated start
18# and end symbols for sections can be generated and used.
19
20TESTDIR=$(dirname $0)
21
22tmpdir=/tmp/test.$$
23mkdir $tmpdir
24cd $tmpdir
25
26cleanup() {
27    cd /
28    rm -fr $tmpdir
29}
30
31trap 'cleanup' EXIT
32
33# We expect any alternate linker to be in LD_ALTEXEC for us already
34gcc -o simple ${TESTDIR}/simple-src.c -Wall -Wextra
35if (( $? != 0 )); then
36    print -u2 "compilation of ${TESTDIR}/simple-src.c failed";
37    exit 1;
38fi
39
40./simple > simple.$$.out 2>&1
41
42if (( $? != 0 )); then
43    print -u2 "execution of ${TESTDIR}/simple-src.c failed";
44    exit 1;
45fi
46
47diff -u ${TESTDIR}/simple.out simple.$$.out
48if (( $? != 0 )); then
49    print -u2 "${TESTDIR}/simple-src.c output mismatch"
50    exit 1;
51fi
52