Home | History | Annotate | Download | only in util
      1 // Copyright 2009 The RE2 Authors.  All Rights Reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 #include <stdio.h>
      6 #include <sys/resource.h>
      7 #include "util/test.h"
      8 
      9 DEFINE_string(test_tmpdir, "/var/tmp", "temp directory");
     10 
     11 struct Test {
     12   void (*fn)(void);
     13   const char *name;
     14 };
     15 
     16 static Test tests[10000];
     17 static int ntests;
     18 
     19 void RegisterTest(void (*fn)(void), const char *name) {
     20   tests[ntests].fn = fn;
     21   tests[ntests++].name = name;
     22 }
     23 
     24 namespace re2 {
     25 int64 VirtualProcessSize() {
     26   struct rusage ru;
     27   getrusage(RUSAGE_SELF, &ru);
     28   return (int64)ru.ru_maxrss*1024;
     29 }
     30 }  // namespace re2
     31 
     32 int main(int argc, char **argv) {
     33   for (int i = 0; i < ntests; i++) {
     34     printf("%s\n", tests[i].name);
     35     tests[i].fn();
     36   }
     37   printf("PASS\n");
     38   return 0;
     39 }
     40