httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/test mod_test.c testdso.c Makefile.in
Date Tue, 04 Apr 2000 03:51:55 GMT
rbb         00/04/03 20:51:55

  Modified:    src/lib/apr/test Makefile.in
  Added:       src/lib/apr/test mod_test.c testdso.c
  Log:
  Adding tests for dso support and the Makefile.  This also updates some
  dependancies.  These tests work on Linux, and I assume the work on
  BeOS.  Everybody else, YMMV.
  Submitted by:	David Reid
  Reviewed by:	Ryan Bloom
  
  Revision  Changes    Path
  1.13      +77 -42    apache-2.0/src/lib/apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/Makefile.in,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Makefile.in	2000/03/01 16:21:17	1.12
  +++ Makefile.in	2000/04/04 03:51:55	1.13
  @@ -24,7 +24,9 @@
   	htdigest@EXEEXT@ \
   	testmmap@EXEEXT@ \
   	testshmem@EXEEXT@ \
  -	testpipe@EXEEXT@
  +	testpipe@EXEEXT@ \
  +	testdso@EXEEXT@ \
  +	mod_test.so
   
   OBJS= testfile.o \
   	testproc.o \
  @@ -35,7 +37,9 @@
           testcontext.o \
   	ab_apr.o \
   	htdigest.o \
  -         testmmap.o
  +	testmmap.o \
  +	testdso.o \
  +	mod_test.o
   
   .c.o:
   	$(CC) -c $(CFLAGS) $(INCLUDES) $<
  @@ -45,6 +49,12 @@
   testfile@EXEEXT@: testfile.o
   	$(CC) $(CFLAGS) testfile.o -o testfile@EXEEXT@ $(LDFLAGS) 
   
  +testdso@EXEEXT@: testdso.o
  +	$(CC) $(CFLAGS) --export-dynamic -fPIC testdso.o -o testdso@EXEEXT@ $(LDFLAGS) 
  +
  +mod_test.so: mod_test.o
  +	$(CC) -shared mod_test.o -o mod_test.so 
  +
   testargs@EXEEXT@: testargs.o
   	$(CC) $(CFLAGS) testargs.o -o testargs@EXEEXT@ $(LDFLAGS) 
   
  @@ -103,43 +113,68 @@
   	    && rm Makefile.new
   
   # DO NOT REMOVE
  -ab_apr.o: ab_apr.c $(INCDIR)/apr_network_io.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h $(INCDIR)/apr_file_io.h $(INCDIR)/apr_time.h
  -abc.o: abc.c $(INCDIR)/apr_file_io.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h
  -client.o: client.c $(INCDIR)/apr_network_io.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h
  -htdigest.o: htdigest.c $(INCDIR)/apr_lib.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h \
  - $(INCDIR)/apr_file_io.h $(INCDIR)/apr_md5.h
  -htpasswd.o: htpasswd.c $(INCDIR)/apr_signal.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h $(INCDIR)/apr_lib.h $(INCDIR)/apr_file_io.h
  -logresolve.o: logresolve.c $(INCDIR)/apr_config.h
  -rotatelogs.o: rotatelogs.c $(INCDIR)/apr_config.h
  -server.o: server.c $(INCDIR)/apr_network_io.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h
  -suexec.o: suexec.c $(INCDIR)/apr_config.h suexec.h
  -testargs.o: testargs.c $(INCDIR)/apr_file_io.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h $(INCDIR)/apr_lib.h
  -testfile.o: testfile.c $(INCDIR)/apr_file_io.h \
  - $(INCDIR)/apr_general.h $(INCDIR)/apr_config.h \
  - $(INCDIR)/apr_errno.h $(INCDIR)/apr_lib.h
  -testproc.o: testproc.c $(INCDIR)/apr_thread_proc.h \
  - $(INCDIR)/apr_file_io.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_win.h \
  - $(INCDIR)/apr_lib.h 
  -testsock.o: testsock.c $(INCDIR)/apr_thread_proc.h \
  - $(INCDIR)/apr_file_io.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_win.h \
  - $(INCDIR)/apr_lib.h
  -testthread.o: testthread.c $(INCDIR)/apr_thread_proc.h \
  - $(INCDIR)/apr_file_io.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_win.h \
  - $(INCDIR)/apr_lock.h
  -testtime.o: testtime.c $(INCDIR)/apr_time.h $(INCDIR)/apr_general.h \
  - $(INCDIR)/apr_config.h $(INCDIR)/apr_errno.h
  +ab_apr.o: ab_apr.c ../include/apr_network_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_file_io.h ../include/apr_time.h \
  + ../include/apr_getopt.h
  +abc.o: abc.c ../include/apr_file_io.h ../include/apr_general.h \
  + ../include/apr.h ../include/apr_errno.h ../include/apr_time.h
  +client.o: client.c ../include/apr_network_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_file_io.h ../include/apr_time.h /usr/include/errno.h
  +htdigest.o: htdigest.c ../include/apr_lib.h ../include/apr_general.h \
  + ../include/apr.h ../include/apr_errno.h ../include/apr_file_io.h \
  + ../include/apr_time.h ../include/apr_thread_proc.h \
  + ../include/apr_md5.h
  +htpasswd.o: htpasswd.c ../include/apr_signal.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_lib.h ../include/apr_file_io.h ../include/apr_time.h \
  + ../include/apr_thread_proc.h
  +logresolve.o: logresolve.c ../include/apr_config.h
  +mod_test.o: mod_test.c
  +rotatelogs.o: rotatelogs.c ../include/apr_config.h
  +server.o: server.c ../include/apr_network_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_file_io.h ../include/apr_time.h
  +testargs.o: testargs.c ../include/apr_file_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_time.h ../include/apr_lib.h \
  + ../include/apr_thread_proc.h ../include/apr_getopt.h
  +testcontext.o: testcontext.c ../include/apr_file_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_time.h ../include/apr_lib.h \
  + ../include/apr_thread_proc.h
  +testdso.o: testdso.c ../include/apr_config.h ../include/apr_general.h \
  + ../include/apr.h ../include/apr_errno.h ../include/apr_pools.h \
  + ../include/apr_lib.h ../include/apr_file_io.h ../include/apr_time.h \
  + ../include/apr_thread_proc.h ../include/apr_dso.h
  +testfile.o: testfile.c ../include/apr_file_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_time.h ../include/apr_lib.h \
  + ../include/apr_thread_proc.h
  +testmmap.o: testmmap.c ../include/apr_mmap.h ../include/apr_general.h \
  + ../include/apr.h ../include/apr_errno.h ../include/apr_network_io.h \
  + ../include/apr_file_io.h ../include/apr_time.h \
  + ../include/apr_portable.h ../include/apr_thread_proc.h \
  + ../include/apr_lock.h ../include/apr_lib.h
  +testpipe.o: testpipe.c ../include/apr_file_io.h \
  + ../include/apr_general.h ../include/apr.h ../include/apr_errno.h \
  + ../include/apr_time.h ../include/apr_lib.h \
  + ../include/apr_thread_proc.h
  +testproc.o: testproc.c ../include/apr_thread_proc.h \
  + ../include/apr_file_io.h ../include/apr_general.h ../include/apr.h \
  + ../include/apr_errno.h ../include/apr_time.h ../include/apr_lib.h \
  + /usr/include/errno.h
  +testshmem.o: testshmem.c ../include/apr_shmem.h ../include/apr.h \
  + ../include/apr_general.h ../include/apr_errno.h ../include/apr_lock.h \
  + ../include/apr_lib.h ../include/apr_file_io.h ../include/apr_time.h \
  + ../include/apr_thread_proc.h /usr/include/errno.h
  +testsock.o: testsock.c ../include/apr_thread_proc.h \
  + ../include/apr_file_io.h ../include/apr_general.h ../include/apr.h \
  + ../include/apr_errno.h ../include/apr_time.h ../include/apr_lib.h
  +testthread.o: testthread.c ../include/apr_thread_proc.h \
  + ../include/apr_file_io.h ../include/apr_general.h ../include/apr.h \
  + ../include/apr_errno.h ../include/apr_time.h ../include/apr_lock.h \
  + /usr/include/errno.h
  +testtime.o: testtime.c ../include/apr_time.h ../include/apr_general.h \
  + ../include/apr.h ../include/apr_errno.h /usr/include/errno.h
  
  
  
  1.1                  apache-2.0/src/lib/apr/test/mod_test.c
  
  Index: mod_test.c
  ===================================================================
  #include <stdio.h>
  
  int goodbyes = 0;
  
  void print_hello(void)
  {
      fprintf(stdout,"Hello - I'm a DSO!\n");
  }
  
  int print_goodbye(int reps)
  {
      int i = 0;
      for (i = 0;i < reps; i++) {
          fprintf (stdout, "Goodbye from the DSO! (%d of %d)\n", i+1, reps);
      }
      goodbyes = reps;
  }
  
  
  
  1.1                  apache-2.0/src/lib/apr/test/testdso.c
  
  Index: testdso.c
  ===================================================================
  #include "apr_config.h"
  #include "apr_general.h"
  #include "apr_pools.h"
  #include "apr_errno.h"
  #include "apr_dso.h"
  #include <string.h>
  
  #define LIB_NAME "mod_test.so"
  
  int main (int argc, char ** argv)
  {
      ap_dso_handle_t *h = NULL;
      ap_dso_handle_sym_t func1 = NULL;
      ap_dso_handle_sym_t func2 = NULL;
      ap_context_t *cont;
      void (*function)(void);
      void (*function1)(int);
      int *retval;
      char filename[256];   
  
      getcwd(filename, 256);
      strcat(filename, "/");
      strcat(filename, LIB_NAME);
  
      ap_initialize();
      atexit(ap_terminate);
          
      if (ap_create_context(&cont, NULL) != APR_SUCCESS) {
          fprintf(stderr, "Couldn't allocate context.");
          exit(-1);
      }
  
      fprintf(stdout,"Initializing DSO's.........................");
      if (ap_dso_init() != APR_SUCCESS) {
          fprintf(stderr, "Couldn't initialize DSO's !");
          exit (-1);
      }
      fprintf(stdout,"OK\n");
      fprintf(stdout,"Trying to load DSO now.....................");
      fflush(stdout);
      if (ap_dso_load(&h, filename, cont) != APR_SUCCESS){
          fprintf(stderr, "Failed to load %s!\n", filename);
          exit (-1);
      }
      fprintf(stdout,"OK\n");
  
      fprintf(stdout,"Trying to get the DSO's attention..........");
      fflush(stdout);
      if (ap_dso_sym(&func1, h, "print_hello") != APR_SUCCESS) { 
          fprintf(stderr, "Failed!\n");
          exit (-1);
      }        
      fprintf(stdout,"OK\n");
      
      function = (void *)func1;
      (*function)();
  
      fprintf(stdout,"Saying farewell 5 times....................");
      fflush(stdout);
      if (ap_dso_sym(&func2, h, "print_goodbye") != APR_SUCCESS) {
          fprintf(stderr, "Failed!\n");
          exit (-1);
      }        
      fprintf(stdout,"OK\n");
  
      function1 = (void *)(int)func2;
      (*function1)(5);
  
      fprintf(stdout,"Checking how many times I said goodbye..");
      fflush(stdout);
      if (ap_dso_sym(&func1, h, "goodbyes") != APR_SUCCESS) {
          fprintf(stderr, "Failed!\n");
          exit (-1);
      }
      retval = (int *)func1;
      fprintf(stdout,"%d..", (*retval));
      fflush(stdout);
      if ((*retval) == 5){
          fprintf(stderr,"OK\n");
      } else {
          fprintf(stderr,"Failed!\n");
      }
         
      fprintf(stdout,"Trying to unload DSO now...................");
      if (ap_dso_unload(h) != APR_SUCCESS) {
          fprintf(stderr, "Failed!\n");
          exit (-1);
      }
      fprintf(stdout,"OK\n");
  
      fprintf(stdout,"Checking it's been unloaded................");
      fflush(stdout);
      if (ap_dso_sym(&func1, h, "print_hello") == APR_SUCCESS) {
          fprintf(stderr, "Failed!\n");
          exit (-1);
      }        
      fprintf(stdout,"OK\n");
      
      return 0;
  }
  
  
  

Mime
View raw message