rbb 99/02/25 08:42:39
Added: apr/test Makefile testfile.c
Log:
Test program for the file I/O. And, the makefile required to build it.
I would really like to see people create test programs as they make apr
functions.
Revision Changes Path
1.1 apache-apr/apr/test/Makefile
Index: Makefile
===================================================================
##
## Apache Makefile, automatically generated by Configure script.
## Hand-edited changes will be lost if the Configure script is re-run.
## Sources: - ../Makefile.config (via Configuration.apaci)
## - ./Makefile.tmpl
##
##
## Inherited Makefile options from Configure script
## (Begin of automatically generated section)
##
SRCDIR=..
EXTRA_CFLAGS=-g
EXTRA_LDFLAGS=
EXTRA_LIBS= -L../file_io -lfile
EXTRA_INCLUDES=
EXTRA_DEPS=
OSDIR=
INCDIR=../../include
INCLUDES0=-I $(INCDIR)
SHELL=/bin/sh
CC=gcc
CPP=gcc -E
TARGET=
OPTIM=
CFLAGS_SHLIB=-fpic -DSHARED_MODULE
LD_SHLIB=ld
LDFLAGS_SHLIB=-Bshareable
LDFLAGS_SHLIB_EXPORT=-rdynamic
CFLAGS1= -DLINUX=2 -pthread -DUSE_HSREGEX
INCLUDES1=
LIBS_SHLIB=
LDFLAGS1=
MFLAGS_STATIC=--no-print-directory
REGLIB=regex/libregex.a
RANLIB=ranlib
LIBS1= -lm -lcrypt -lndbm -ldl
##
## (End of automatically generated section)
##
CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
LIBS=$(EXTRA_LIBS) $(LIBS1)
INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
OBJS= testfile.o \
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBS) $<
testfile:
$(CC) testfile.c $(INCLUDES) $(CFLAGS) $(LIBS) $<
clean:
rm -f *.o $(LIB)
distclean: clean
-rm -f Makefile
# We really don't expect end users to use this rule. It works only with
# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after
# using it.
depend:
cp Makefile.tmpl Makefile.tmpl.bak \
&& sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
&& gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
&& sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
-e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
> Makefile.tmpl \
&& rm Makefile.new
#Dependencies
$(OBJS): Makefile
# DO NOT REMOVE
alloc.o: open.c
1.1 apache-apr/apr/test/testfile.c
Index: testfile.c
===================================================================
#include "apr_file_io.h"
#include "apr_errno.h"
#include "apr_general.h"
#include "errno.h"
#include <stdio.h>
void main()
{
apr_file_t *thefile = NULL;
apr_status_t status = 0;
apr_int32_t flag = APR_READ | APR_CREATE | APR_NONBLOCK;
fprintf(stdout, "Opening file.......");
thefile = apr_open("test.fil", flag, 444);
if (thefile == NULL) {
perror("Didn't open file");
exit(-1);
}
else {
fprintf(stdout, "OK\n");
}
fprintf(stdout, "Checking file.......");
if (thefile->filedes < 0) {
fprintf(stderr, "Bad file des\n");
exit(-1);
}
if (strcmp(thefile->fname, "rbb.fil") != 0) {
fprintf(stderr, "wrong filename\n");
exit(-1);
}
else {
fprintf(stdout, "OK\n");
}
fprintf(stdout, "Closing File.......");
status = apr_close(*thefile);
if (status == APR_FAILURE) {
fprintf(stderr, "Couldn't close the file\n");
exit(-1);
}
else {
fprintf(stdout, "OK\n");
}
}