# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config

INCDIRS= -I${DESTDIR}/include -I..
LDIRS= -L${DESTDIR}/lib -L${DESTDIR}/lib/afs -L..
LIBS= -llwp -ldes -lrxkad -lauth -lcmd -lubik -lprot -lsys -lrx -lafscom_err -lkauth

# the only tests _known_ to work are multiklog and the tcl scripts.

all test tests: multiklog

install:
dest:

clean:
	$(RM) -f *.o core

multiklog: multiklog.o
	$(AFS_LDRULE) multiklog.o ${LDIRS} ${LIBS} -lafsutil

test_date: ../kautils.o test_date.o ${utilib}
	$(AFS_LDRULE) test_date.o ../kautils.o ${LDIRS} ${LIBS} -lafsutil

test_badtix: test_badtix.o
	$(AFS_LDRULE) test_badtix.o ${LDIRS} ${LIBS}

decode_ticket: decode_ticket.o
	$(AFS_LDRULE) decode_ticket.o ${LDIRS} ${LIBS}

test_interim_ktc: test_interim_ktc.o
	$(AFS_LDRULE) test_interim_ktc.o ${LDIRS} ${LIBS}

test_rxkad_free: test_rxkad_free.o
	$(AFS_LDRULE) test_rxkad_free.o ${LDIRS} ${LIBS}

test_getticket: test_getticket.o
	$(AFS_LDRULE) test_getticket.o ${LDIRS} ${LIBS}

background: background.c
	$(CC) $(AFS_CPPFLAGS) $(AFS_CFLAGS) $(AFS_LDFLAGS) \
		${LDIRS} ${LIBS} -o background background.c

# test_interim_ktc depends on normally running ka & pr servers.  Also on
# the current user having write access to the working directory.  Also
# on the user "tester" being defined with ViceId=1031.  The password
# must be specified on the make line the others can be overridden by
# specifying a value for TESTERVALUES.  To test remote authentication, a
# test account in another cell must be available.  The default is the
# cell "cellname" and the user tester with Vice Id 510, and the
# same password as in the local cell.  These can be over-ridden by
# specifying a difference value for REMOTETESTER.  An empty value for
# REMOTETESTER will disable testing of remote authentication.

TESTERNAME=xxx
TESTERPASSWORD=xxx
#TESTERVALUES=-tester tester -testId 1031
TESTERVALUES=
REMOTEPASSWORD=${TESTERPASSWORD}
REMOTETESTER=-remoteTester $(TESTERNAME) -remoteTestPassword ${REMOTEPASSWORD} -remoteTestId 510 -remoteCell cellname

# test_kaserver starts a server in the background and tests it.

# test_rxkad_free checks for rxkad object/connection usage and checks for
#   core leaks.  Normally it makes 100 calls to the kaserver, doing a GetEntry
#   call.  This requests an admin ticket 100 times and creates a ubik
#   connection 100 times.  With the -doauth switch specified it calls
#   ka_UserAuthenticate instead, which uses rxnull connections, but also
#   exercises the ptserver code, particularly, pr_Initialize, 100 times.

runtest: background multiklog test_badtix test_interim_ktc test_rxkad_free
	test_interim_ktc ${TESTERVALUES} -testPassword ${TESTERPASSWORD} ${REMOTETESTER}
	test_kaserver
	test_rxkad_free -waitforreap -a $(TESTERNAME) -p $(TESTERPASSWORD)
	test_rxkad_free -doauth -waitforreap -a $(TESTERNAME) -p $(TESTERPASSWORD)
