From ff66bcc0a38767be7cc348156e52b61fc3320902 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Sun, 28 Jan 2001 23:23:22 +0000 Subject: Get tests building, and actually checking for libapr.la revisions to save debugging agrivation. Shout if I broke it. Win32 users should find the aprtest.dsw DevStudio workspace a lovely little place to get work done. [No help from MS - notice the .pl Makefile.in rewriter :-] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@61163 13f79535-47bb-0310-9956-ffa450edef68 --- test/MakeWin32Make.pl | 1 + test/Makefile.in | 42 +++++++++++------------ test/testfile.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++- test/testoc.c | 4 +-- test/testsockopt.c | 7 +++- 5 files changed, 123 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/MakeWin32Make.pl b/test/MakeWin32Make.pl index a0c6318f2..cb2cce517 100644 --- a/test/MakeWin32Make.pl +++ b/test/MakeWin32Make.pl @@ -19,6 +19,7 @@ while ($t = <$srcfl>) { $t =~ s|-g ||; } $t =~ s|\@LDFLAGS\@||; + $t =~ s|\.\./libapr\.la|../LibD/apr.lib|; $t =~ s|\@RM\@|del|; if ($t =~ s|(\$\(RM\)) -f|$1|) { diff --git a/test/Makefile.in b/test/Makefile.in index 2f475a6d2..e1e1b67cc 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -34,65 +34,65 @@ INCDIR=../include INCLUDES=-I$(INCDIR) -testfile@EXEEXT@: testfile.lo +testfile@EXEEXT@: testfile.lo ../libapr.la $(LINK) testfile.lo $(ALL_LIBS) -testflock@EXEEXT@: testflock.lo +testflock@EXEEXT@: testflock.lo ../libapr.la $(LINK) testflock.lo $(ALL_LIBS) ### why the export-dynamic? -testdso@EXEEXT@: testdso.lo +testdso@EXEEXT@: testdso.lo ../libapr.la $(LINK) --export-dynamic testdso.lo $(ALL_LIBS) -testoc@EXEEXT@: testoc.lo +testoc@EXEEXT@: testoc.lo ../libapr.la $(LINK) testoc.lo $(ALL_LIBS) -occhild@EXEEXT@: occhild.lo +occhild@EXEEXT@: occhild.lo ../libapr.la $(LINK) occhild.lo $(ALL_LIBS) -mod_test.so: mod_test.lo - $(LINK) --module mod_test.lo +mod_test.so: mod_test.lo ../libapr.la + $(LINK) --module mod_test.lo $(ALL_LIBS) -testargs@EXEEXT@: testargs.lo +testargs@EXEEXT@: testargs.lo ../libapr.la $(LINK) testargs.lo $(ALL_LIBS) -testcontext@EXEEXT@: testcontext.lo +testcontext@EXEEXT@: testcontext.lo ../libapr.la $(LINK) testcontext.lo $(ALL_LIBS) -testproc@EXEEXT@: testproc.lo +testproc@EXEEXT@: testproc.lo ../libapr.la $(LINK) testproc.lo $(ALL_LIBS) -testthread@EXEEXT@: testthread.lo +testthread@EXEEXT@: testthread.lo ../libapr.la $(LINK) testthread.lo $(ALL_LIBS) -testsock@EXEEXT@: testsock.lo client@EXEEXT@ server@EXEEXT@ sendfile@EXEEXT@ +testsock@EXEEXT@: testsock.lo client@EXEEXT@ server@EXEEXT@ sendfile@EXEEXT@ ../libapr.la $(LINK) testsock.lo $(ALL_LIBS) -client@EXEEXT@: client.lo +client@EXEEXT@: client.lo ../libapr.la $(LINK) client.lo $(ALL_LIBS) -server@EXEEXT@: server.lo sendfile.lo +server@EXEEXT@: server.lo sendfile.lo ../libapr.la $(LINK) server.lo $(ALL_LIBS) -sendfile@EXEEXT@: sendfile.lo +sendfile@EXEEXT@: sendfile.lo ../libapr.la $(LINK) sendfile.lo $(ALL_LIBS) -testtime@EXEEXT@: testtime.lo +testtime@EXEEXT@: testtime.lo ../libapr.la $(LINK) testtime.lo $(ALL_LIBS) -testmmap@EXEEXT@: testmmap.lo +testmmap@EXEEXT@: testmmap.lo ../libapr.la $(LINK) testmmap.lo $(ALL_LIBS) -testshmem@EXEEXT@: testshmem.lo +testshmem@EXEEXT@: testshmem.lo ../libapr.la $(LINK) testshmem.lo $(ALL_LIBS) -testpipe@EXEEXT@: testpipe.lo +testpipe@EXEEXT@: testpipe.lo ../libapr.la $(LINK) testpipe.lo $(ALL_LIBS) -testuuid@EXEEXT@: testuuid.lo +testuuid@EXEEXT@: testuuid.lo ../libapr.la $(LINK) testuuid.lo $(ALL_LIBS) -testsockopt@EXEEXT@: testsockopt.lo +testsockopt@EXEEXT@: testsockopt.lo ../libapr.la $(LINK) testsockopt.lo $(ALL_LIBS) # DO NOT REMOVE diff --git a/test/testfile.c b/test/testfile.c index 0bafdd346..2b8868266 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -57,6 +57,7 @@ #include #include #include "apr_file_io.h" +#include "apr_file_info.h" #include "apr_network_io.h" #include "apr_errno.h" #include "apr_general.h" @@ -65,6 +66,27 @@ #include #endif +struct view_fileinfo +{ + apr_int32_t bits; + char *description; +} vfi[] = { + APR_FINFO_MTIME, "MTIME", + APR_FINFO_CTIME, "CTIME", + APR_FINFO_ATIME, "ATIME", + APR_FINFO_SIZE, "SIZE", + APR_FINFO_DEV, "DEV", + APR_FINFO_INODE, "INODE", + APR_FINFO_NLINK, "NLINK", + APR_FINFO_TYPE, "TYPE", + APR_FINFO_USER, "USER", + APR_FINFO_GROUP, "GROUP", + APR_FINFO_UPROT, "UPROT", + APR_FINFO_GPROT, "GPROT", + APR_FINFO_WPROT, "WPROT", + 0, NULL +}; + int test_filedel(apr_pool_t *); int testdirs(apr_pool_t *); static void test_read(apr_pool_t *); @@ -79,6 +101,7 @@ int main(void) apr_pool_t *context; apr_pool_t *cont2; apr_file_t *thefile = NULL; + apr_finfo_t finfo; apr_socket_t *testsock = NULL; apr_pollfd_t *sdset = NULL; apr_status_t status; @@ -90,6 +113,8 @@ int main(void) const char *str; char *filename = "test.fil"; char *teststr; + apr_uid_t uid; + apr_gid_t gid; #if APR_FILES_AS_SOCKETS apr_int32_t num; #endif @@ -227,6 +252,25 @@ int main(void) fprintf(stdout, "OK\n"); } + fprintf(stdout, "\tGetting fileinfo......."); + status = apr_getfileinfo(&finfo, APR_FINFO_NORM, thefile); + if (status == APR_INCOMPLETE) { + int i; + fprintf(stdout, "INCOMPLETE\n"); + for (i = 0; vfi[i].bits; ++i) + if (vfi[i].bits & ~finfo.valid) + fprintf(stdout, "\t Missing %s\n", vfi[i].description); + } + else if (status != APR_SUCCESS) { + fprintf(stderr, "Couldn't get the fileinfo\n"); + exit(-1); + } + else { + fprintf(stdout, "OK\n"); + } + gid = finfo.group; + uid = finfo.user; + fprintf(stdout, "\tClosing File......."); status = apr_close(thefile); if (status != APR_SUCCESS) { @@ -236,7 +280,54 @@ int main(void) else { fprintf(stdout, "OK\n"); } - + + fprintf(stdout, "\tStat'ing file......."); + status = apr_stat(&finfo, filename, APR_FINFO_NORM, context); + if (status == APR_INCOMPLETE) { + int i; + fprintf(stdout, "INCOMPLETE\n"); + for (i = 0; vfi[i].bits; ++i) + if (vfi[i].bits & ~finfo.valid) + fprintf(stdout, "\t Missing %s\n", vfi[i].description); + } + else if (status != APR_SUCCESS) { + fprintf(stderr, "Couldn't stat the file\n"); + exit(-1); + } + else { + fprintf(stdout, "OK\n"); + } + + if (finfo.valid & APR_FINFO_GROUP) { + fprintf(stdout, "\tComparing group ids......."); + status = apr_get_groupname(&buf, finfo.group, context); + if (status != APR_SUCCESS) { + fprintf(stderr, "Couldn't retrieve the group name\n"); + exit(-1); + } + status = apr_compare_groups(finfo.group, gid); + if (status != APR_SUCCESS) { + fprintf(stderr, "gid's for %s don't match\n", buf); + exit(-1); + } + fprintf(stdout, "gid's for %s match\n", buf); + } + + if (finfo.valid & APR_FINFO_USER) { + fprintf(stdout, "\tComparing user ids......."); + status = apr_get_username(&buf, finfo.user, context); + if (status != APR_SUCCESS) { + fprintf(stderr, "Couldn't retrieve the user name\n"); + exit(-1); + } + status = apr_compare_users(finfo.user, uid); + if (status != APR_SUCCESS) { + fprintf(stderr, "uid's for %s don't match\n", buf); + exit(-1); + } + fprintf(stdout, "uid's for %s match\n", buf); + } + fprintf(stdout, "\tDeleting file......."); status = apr_remove_file(filename, context); if (status != APR_SUCCESS) { @@ -261,6 +352,7 @@ int main(void) test_filedel(context); test_read(context); + apr_destroy_pool(context); return 1; } diff --git a/test/testoc.c b/test/testoc.c index 6c4ac6971..bb641e330 100644 --- a/test/testoc.c +++ b/test/testoc.c @@ -151,11 +151,11 @@ int main(int argc, char *argv[]) fprintf(stdout, "[PARENT] Checking on children..........\n"); apr_check_other_child(); - - return 1; #else fprintf(stdout, "OC failed!\n"); fprintf(stdout, "Other_child is not supported on this platform\n"); #endif + + return 1; } diff --git a/test/testsockopt.c b/test/testsockopt.c index 236820d92..6c9403d68 100644 --- a/test/testsockopt.c +++ b/test/testsockopt.c @@ -78,6 +78,11 @@ static void failureno(apr_socket_t *sock) exit(-1); } +static void closeapr(void) +{ + apr_terminate(); +} + int main(void) { apr_pool_t *context; @@ -90,7 +95,7 @@ int main(void) fprintf(stderr, "Couldn't initialize."); exit(-1); } - atexit(apr_terminate); + atexit(closeapr); if (apr_create_pool(&context, NULL) != APR_SUCCESS) { fprintf(stderr, "Couldn't allocate context."); exit(-1); -- cgit v1.2.1