IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38377


Ignore:
Timestamp:
Jun 5, 2015, 11:18:52 AM (11 years ago)
Author:
eugene
Message:

update tests

Location:
branches/eam_branches/ohana.20150429/src/libohana
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libohana/Makefile

    r37807 r38377  
    11default: install
    22help:
    3         @echo "make options: install libohana clean dist test typetest"
     3        @echo "make options: install libohana clean dist test test.clean"
    44
    55include ../../Makefile.System
     
    1010MAN     =       $(HOME)/doc
    1111INC     =       $(HOME)/include
    12 TESTDIR =       $(HOME)/test
     12TESTDIR =       $(HOME)/test
     13TESTBIN =       $(HOME)/test
    1314include ../../Makefile.Common
    1415
     
    1718FULL_CPPFLAGS = $(BASE_CPPFLAGS)
    1819FULL_LDFLAGS  = $(BASE_LDFLAGS)
    19 TFLAGS        = $(FULL_CFLAGS) $(FULL_CPPFLAGS) $(FULL_LDFLAGS) -lohana -ltap_ohana
    2020
    21 install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) typetest
     21TEST_CFLAGS   = $(BASE_CFLAGS)
     22TEST_CPPFLAGS = $(BASE_CPPFLAGS)
     23TEST_LDFLAGS  = $(BASE_LDFLAGS) -lohana -ltap_ohana
     24
     25install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE)
    2226libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE)
    2327
     
    5155# $(SRC)/gsl_utils.$(ARCH).o     \
    5256
    53 TYPETEST = \
    54 $(TESTDIR)/typetest.$(ARCH)
    55 
    56 $(TYPETEST) : $(LIB)/libohana.$(ARCH).a
    57 
    58 typetest: $(TYPETEST)
    59         for i in $(TYPETEST); do $$i || exit 1; done
    60 
    61 TEST = \
    62 $(TESTDIR)/memtest.$(ARCH)
    63 # $(TESTDIR)/string.$(ARCH)
    64 
    65 testcode: install $(TEST)
    66 test:
    67         $(MAKE) testcode
    68         for i in $(TEST); do $$i; done
    69 
    70 quicktest:
    71         for i in $(TEST); do $$i; done
    72 
    7357$(OBJS): $(INCS)
    7458
     
    7963$(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE)
    8064
    81 $(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c
    82         $(CC) $^ -o $@ $(TFLAGS)
     65TESTPROG = memtest typetest string
     66$(TESTPROG) : % : $(TESTBIN)/% $(OBJS)
     67test: $(TESTPROG)
     68        for i in $(TESTPROG); do $(TESTBIN)/$$i; done
    8369
    84 .PHONY: test
    85 
  • branches/eam_branches/ohana.20150429/src/libohana/include/ohana.h

    r38372 r38377  
    286286char   *strcreate              PROTO((char *string));
    287287char   *strncreate             PROTO((char *string, int n));
    288 int     strextend              PROTO((char *input, char *format,...)) OHANA_FORMAT(printf, 2, 3);
     288int     strextend              PROTO((char **input, char *format,...)) OHANA_FORMAT(printf, 2, 3);
    289289int     scan_line              PROTO((FILE *f, char *line));
    290290int     scan_line_maxlen       PROTO((FILE *f, char *line, int maxlen));
  • branches/eam_branches/ohana.20150429/src/libohana/src/string.c

    r38372 r38377  
    5151}
    5252
    53 int strextend (char *input, char *format,...) {
    54 
    55   char tmpextra[1024], tmpline[1024];
    56   va_list argp;
    57 
    58   va_start (argp, format);
    59   vsnprintf (tmpextra, 1024, format, argp);
    60   snprintf (tmpline, 1024, "%s %s", input, tmpextra);
    61   strcpy (input, tmpline);
    62 
    63   return TRUE;
    64 }
    65 
    6653/* create a new string of length n from this string */
    6754char *strncreate (char *string, int n) {
     
    7663  line[n] = 0;
    7764  return (line);
     65}
     66
     67// extend input as needed to add the formatted pieces
     68// if input is NULL, allocate a new line
     69// the result of the format must be < 1024 bytes
     70int strextend (char **input, char *format,...) {
     71
     72  int Nchar;
     73  char tmpextra[1024], tmpline, *output;
     74  va_list argp;
     75
     76  va_start (argp, format);
     77  Nchar = vsnprintf (tmpextra, 1024, format, argp);
     78  if (Nchar > 1024 - 1) return FALSE;
     79
     80  if (*input) {
     81    Nchar = snprintf (&tmpline, 0, "%s %s", *input, tmpextra);
     82    ALLOCATE (output, char, Nchar + 1);
     83    snprintf (output, Nchar + 1, "%s %s", *input, tmpextra);
     84    free (*input);
     85  } else {
     86    Nchar = strlen(tmpextra) + 1;
     87    ALLOCATE (output, char, Nchar);
     88    strcpy (output, tmpextra);
     89  }
     90  *input = output;
     91
     92  return TRUE;
    7893}
    7994
  • branches/eam_branches/ohana.20150429/src/libohana/test

    • Property svn:ignore
      •  

        old new  
        44*.darwin_x86
        55*.dSYM
         6memtest
         7string
         8typetest
  • branches/eam_branches/ohana.20150429/src/libohana/test/string.c

    r10313 r38377  
    44int main (void) {
    55
    6   plan_tests (16);
     6  plan_tests (20);
    77
    88  diag ("libohana string.c tests");
     
    6767    skip_end();
    6868  }
     69
     70  /*** strextend ***/
     71  {
     72    int status;
     73    char *string = NULL;
     74
     75    status = strextend(&string, "hello %s", "there");
     76    ok (status, "strextend for NULL input");
     77    ok (!strcmp(string, "hello there"), "strextend format");
     78   
     79    status = strextend(&string, "more words %d", 2);
     80    ok (status, "strextend for non-NULL input");
     81    ok (!strcmp(string, "hello there more words 2"), "strextend format");
     82  }
     83   
    6984  return exit_status();
    7085}
Note: See TracChangeset for help on using the changeset viewer.