pike.git / bin / test_pike.pike

version» Context lines:

pike.git/bin/test_pike.pike:1:   #!/usr/local/bin/pike    - /* $Id: test_pike.pike,v 1.14 1998/10/14 05:47:06 hubbe Exp $ */ + /* $Id: test_pike.pike,v 1.15 1999/01/21 09:11:42 hubbe Exp $ */      #include <simulate.h>      #if !efun(_verify_internals)   #define _verify_internals()   #endif      int foo(string opt)   {    if(opt=="" || !opt) return 1;    return (int)opt;   }      mapping(string:int) cond_cache=([]);    -  + #if constant(thread_create) + #define HAVE_DEBUG + #endif +    int main(int argc, string *argv)   {    int e, verbose, successes, errors, t, check;    string *tests,tmp;    program testprogram;    int start, fail, mem;    int loop=1;    int end=0x7fffffff; -  +  string extra_info="";    -  +  + #if constant(signal) && constant(signum) +  if(signum("SIGQUIT")>=0) +  { +  signal(signum("SIGQUIT"),lambda() +  { +  master()->handle_error( ({"\nSIGQUIT recived, printing backtrace and continuing.\n",backtrace() }) ); +  }); +  } + #endif +     string *args=backtrace()[0][3];    args=args[..sizeof(args)-1-argc];    add_constant("RUNPIKE",Array.map(args,Process.sh_quote)*" ");       foreach(Getopt.find_all_options(argv,aggregate(    ({"help",Getopt.NO_ARG,({"-h","--help"})}),    ({"verbose",Getopt.NO_ARG,({"-v","--verbose"})}),    ({"start",Getopt.HAS_ARG,({"-s","--start-test"})}),    ({"end",Getopt.HAS_ARG,({"--end-after"})}),    ({"fail",Getopt.MAY_HAVE_ARG,({"-f","--fail"})}),    ({"loop",Getopt.MAY_HAVE_ARG,({"-l","--loop"})}),    ({"trace",Getopt.MAY_HAVE_ARG,({"-t","--trace"})}),    ({"check",Getopt.MAY_HAVE_ARG,({"-c","--check"})}),    ({"mem",Getopt.MAY_HAVE_ARG,({"-m","--mem","--memory"})}), -  + #ifdef HAVE_DEBUG +  ({"debug",Getopt.MAY_HAVE_ARG,({"-d","--debug"})}), + #endif    )),array opt)    {    switch(opt[0])    {    case "help":    werror("Usage: "+argv[e]+" [-v | --verbose] [-h | --help] [-t <testno>] <testfile>\n");    return 0;       case "verbose": verbose+=foo(opt[1]); break;    case "start": start=foo(opt[1]); start--; break;    case "end": end=foo(opt[1]); break;    case "fail": fail+=foo(opt[1]); break;    case "loop": loop+=foo(opt[1]); break;    case "trace": t+=foo(opt[1]); break;    case "check": check+=foo(opt[1]); break;    case "mem": mem+=foo(opt[1]); break; -  +  + #ifdef HAVE_DEBUG +  case "debug": +  { +  object p=Stdio.Port(); +  p->bind(0); +  werror("Debug port is: %s\n",p->query_address()); +  sscanf(p->query_address(),"%*s %d",int portno); +  extra_info+=sprintf(" dport:%d",portno); +  thread_create(lambda(object p){ +  while(p) +  { +  if(object o=p->accept()) +  { +  object q=Stdio.FILE(); +  q->assign(o); +  destruct(o); +  Tools.Hilfe.GenericHilfe(q,q);    }    } -  +  },p); +  } + #endif +  } +  }       argv=Getopt.get_args(argv,1);    if(sizeof(argv)<1)    {    if(!tmp)    {    werror("No tests?\n");    exit(1);    }    }
pike.git/bin/test_pike.pike:114:    successes++;    continue;    }    }       sscanf(test,"%s\n%s",type,test);    sscanf(type,"%*s expected result: %s",type);       if(verbose)    { -  werror("Doing test %d (%d total)\n",e+1,successes+errors+1); +  werror("Doing test %d (%d total)%s\n",e+1,successes+errors+1,extra_info);    if(verbose>1)    werror(test+"\n");    }       if(check > 1) _verify_internals();       string fname = argv[f] + ": Test " + (e + 1);       switch(type)    {