9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER END
038dc6b3d39a14038605fbb3fc6a9bb76dd27fa8ahl# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Use is subject to license terms.
038dc6b3d39a14038605fbb3fc6a9bb76dd27fa8ahl# This test verifies that USDT providers are removed when its associated
038dc6b3d39a14038605fbb3fc6a9bb76dd27fa8ahl# load object is closed via dlclose(3dl).
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeeif [ $# != 1 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahlall: main livelib.so deadlib.so
9512fe850e98fdd448c638ca63fdd92a8a510255ahlmain: main.o prov.o
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -o main main.o
9512fe850e98fdd448c638ca63fdd92a8a510255ahlmain.o: main.c
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -c main.c
9512fe850e98fdd448c638ca63fdd92a8a510255ahllivelib.so: livelib.o prov.o
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -shared -o livelib.so livelib.o prov.o -lc
9512fe850e98fdd448c638ca63fdd92a8a510255ahllivelib.o: livelib.c prov.h
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -fPIC -c livelib.c
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprov.o: livelib.o prov.d
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee $dtrace -G -s prov.d livelib.o
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprov.h: prov.d
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee $dtrace -h -s prov.d
9512fe850e98fdd448c638ca63fdd92a8a510255ahldeadlib.so: deadlib.o
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -shared -o deadlib.so deadlib.o -lc
9512fe850e98fdd448c638ca63fdd92a8a510255ahldeadlib.o: deadlib.c
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchi gcc -m32 -fPIC -c deadlib.c
9512fe850e98fdd448c638ca63fdd92a8a510255ahl rm -f main.o livelib.o prov.o prov.h deadlib.o
9512fe850e98fdd448c638ca63fdd92a8a510255ahlclobber: clean
9512fe850e98fdd448c638ca63fdd92a8a510255ahl rm -f main livelib.so deadlib.so
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprovider test_prov {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe go();
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#include "prov.h"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl TEST_PROV_GO();
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#include <dlfcn.h>
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#include <unistd.h>
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#include <stdio.h>
9512fe850e98fdd448c638ca63fdd92a8a510255ahlmain(int argc, char **argv)
9512fe850e98fdd448c638ca63fdd92a8a510255ahl void *live;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("dlopen of livelib.so failed: %s\n", dlerror());
9512fe850e98fdd448c638ca63fdd92a8a510255ahl return (1);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl (void) dlclose(live);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl return (0);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl syscall::pause:entry
9512fe850e98fdd448c638ca63fdd92a8a510255ahl /pid == \$target/
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee system("$dtrace -l -P test_prov*");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl system("kill %d", \$target);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl /i++ == 5/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("failed\n");