pike.git / bin / test_pike.pike

version» Context lines:

pike.git/bin/test_pike.pike:5:   #if !efun(_verify_internals)   #define _verify_internals()   #endif         int main(int argc, string *argv)   {    int e, verbose, successes, errors, t, check;    string *tests;    program testprogram; -  int start, fail; +  int start, fail, mem; +  int loop=1;       for(e=1;e<argc;e++)    {    string opt;    int arg;    arg=1;    if(sscanf(argv[e],"--%s=%d",opt,arg)==2)    opt="--"+opt;    else if(sscanf(argv[e],"-%s%d",opt,arg)==2)    opt="-"+opt;
pike.git/bin/test_pike.pike:42:    case "--start-test":    start=arg;    start--;    break;       case "-f":    case "--fail":    fail+=arg;    break;    +  +  case "-l": +  case "--loop": +  loop+=arg; +  break; +     case "-t":    case "--trace":    t+=arg;    break;       case "-c":    case "--check":    check++;    break;    -  +  +  case "-m": +  case "--mem": +  case "--memory": +  mem++; +  break; +     default:    if(tests)    {    perror("Unknown argument: "+opt+".\n");    exit(1);    }    tests=(read_bytes(argv[e])||"")/"\n....\n";    }    }   
pike.git/bin/test_pike.pike:74:    tests=(clone((program)"/precompiled/file","stdin")->read(0x7fffffff)||"")/"\n....\n";    }       if(!tests)    {    perror("Failed to read test file!\n");    exit(1);    }       tests=tests[0..sizeof(tests)-2]; +  +  while(loop--) +  { +  successes=errors=0; +     for(e=start;e<sizeof(tests);e++)    {    string test,condition;    int type;    object o;    mixed a,b;       if(check) _verify_internals();       test=tests[e];
pike.git/bin/test_pike.pike:204:    default:    perror(sprintf("Unknown test type (%O).\n",type));    errors++;    }    }       if(check > 2) _verify_internals();       if(fail && errors)    exit(1); +  +  a=b=0;    }       if(errors + successes != sizeof(tests))    {    perror("Errors + Successes != number of tests!\n");    errors++;    }       if(errors || verbose)    {    perror("Failed tests: "+errors+".\n");    }    -  +  } +  if(mem) +  { +  int total; +  tests=0; +  gc(); +  mapping tmp=_memory_usage(); +  write(sprintf("%-10s: %6s %10s\n","Category","num","bytes")); +  foreach(sort(indices(tmp)),string foo) +  { +  if(sscanf(foo,"%s_bytes",foo)) +  { +  write(sprintf("%-10s: %6d %10d\n", +  foo+"s", +  tmp["num_"+foo+"s"], +  tmp[foo+"_bytes"])); +  total+=tmp[foo+"_bytes"]; +  } +  } +  write(sprintf("%-10s: %6s %10d\n", +  "Total", +  "", +  total)); +  } +     return errors;   }