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