OBJS=../rootlinks.o ../util.o ../file.o ../services.o ../environment.o ../os.o ../cmds.o

AnsiCC()

#if defined(ultrix) && defined(mips)
CC=gcc
LD=gcc
#endif

CFLAGS=-DPOSIX -I..

#if defined(_AIX) && (AIXV >= 30)
MACHLIBS = -lodm -lcfg -ls
#endif

#ifdef sun
LDLIBS=/usr/athena/lib/libresolv.a -lsocket -lnsl -lelf -ldl
#endif

LIBS=$(MACHLIBS)

#if 1
FIND_MOUNT=-mount
#else
FIND_MOUNT=-xdev
#endif

SimpleProgram(test,test.o $(OBJS),$(LIBS),./test)

tests: test test_walk test_find test_vno test_header test_get_service \
		test_set_env test_parse

test_walk:
	./test 1 | sort > test_walk.1
	find / $(FIND_MOUNT) -print | sort > test_walk.2
	@echo "May fail if items in root cannot be searched"
	-diff test_walk.1 test_walk.2
	./test 2 | sort > test_walk.3
	find / $(FIND_MOUNT) -type l -print | sort > test_walk.4
	@echo "May fail if items in root cannot be searched"
	-diff test_walk.3 test_walk.4
	$(RM) test_walk.{1,2,3,4}

test_find:
	./test 4

test_vno:
	./test 5

test_header:
	./test 6

test_get_service:
	$(RM) -r /tmp/test_mkserv
	./test 7

test_set_env:
	@echo "Environment tests.................."
	@echo "Check the following for proper values"
	./test 8 | egrep "No|RVDROOT|OSROOT|SRVDIR|^PATH|LOGFILE|VERS|MACH=|SERVERD""
	@echo
	@echo "Check RVDROOT, OSROOT, and SRVDIR"
	RVDROOT=/foo ./test 8 | egrep "SRVDIR|RVDROOT|OSROOT|^PATH"
	@echo
	OSROOT=/foo ./test 8 | egrep "SRVDIR|RVDROOT|OSROOT|^PATH"
	@echo
	SRVDIR=/foo ./test 8 | egrep "SRVDIR|RVDROOT|OSROOT|^PATH"
	@echo
	@echo "The following should not change"
	LOGFILE=/foo ./test 8 | egrep "LOGFILE"
	@echo "Environment tests end...."

test_parse:
	./test 9

clean::
	$(RM) test_walk.1 test_walk.2 test_walk.3 test_walk.4

