OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 CcTest::CcTest(TestFunction* callback, const char* file, | 38 CcTest::CcTest(TestFunction* callback, const char* file, |
39 const char* name, bool enabled) | 39 const char* name, bool enabled) |
40 : callback_(callback), name_(name), prev_(last_) { | 40 : callback_(callback), name_(name), prev_(last_) { |
41 // Find the base name of this test (const_cast required on Windows). | 41 // Find the base name of this test (const_cast required on Windows). |
42 char *basename = strrchr(const_cast<char *>(file), '/'); | 42 char *basename = strrchr(const_cast<char *>(file), '/'); |
43 if (!basename) { | 43 if (!basename) { |
44 basename = strrchr(const_cast<char *>(file), '\\'); | 44 basename = strrchr(const_cast<char *>(file), '\\'); |
45 } | 45 } |
46 if (!basename) { | 46 if (!basename) { |
47 basename = strdup(file); | 47 basename = v8::internal::OS::StrDup(file); |
48 } else { | 48 } else { |
49 basename = strdup(basename + 1); | 49 basename = v8::internal::OS::StrDup(basename + 1); |
50 } | 50 } |
51 // Drop the extension, if there is one. | 51 // Drop the extension, if there is one. |
52 char *extension = strrchr(basename, '.'); | 52 char *extension = strrchr(basename, '.'); |
53 if (extension) *extension = 0; | 53 if (extension) *extension = 0; |
54 // Install this test in the list of tests | 54 // Install this test in the list of tests |
55 file_ = basename; | 55 file_ = basename; |
56 enabled_ = enabled; | 56 enabled_ = enabled; |
57 prev_ = last_; | 57 prev_ = last_; |
58 last_ = this; | 58 last_ = this; |
59 } | 59 } |
(...skipping 10 matching lines...) Expand all Loading... |
70 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); | 70 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
71 int tests_run = 0; | 71 int tests_run = 0; |
72 bool print_run_count = true; | 72 bool print_run_count = true; |
73 for (int i = 1; i < argc; i++) { | 73 for (int i = 1; i < argc; i++) { |
74 char* arg = argv[i]; | 74 char* arg = argv[i]; |
75 if (strcmp(arg, "--list") == 0) { | 75 if (strcmp(arg, "--list") == 0) { |
76 PrintTestList(CcTest::last()); | 76 PrintTestList(CcTest::last()); |
77 print_run_count = false; | 77 print_run_count = false; |
78 | 78 |
79 } else { | 79 } else { |
80 char* arg_copy = strdup(arg); | 80 char* arg_copy = v8::internal::OS::StrDup(arg); |
81 char* testname = strchr(arg_copy, '/'); | 81 char* testname = strchr(arg_copy, '/'); |
82 if (testname) { | 82 if (testname) { |
83 // Split the string in two by nulling the slash and then run | 83 // Split the string in two by nulling the slash and then run |
84 // exact matches. | 84 // exact matches. |
85 *testname = 0; | 85 *testname = 0; |
86 char* file = arg_copy; | 86 char* file = arg_copy; |
87 char* name = testname + 1; | 87 char* name = testname + 1; |
88 CcTest* test = CcTest::last(); | 88 CcTest* test = CcTest::last(); |
89 while (test != NULL) { | 89 while (test != NULL) { |
90 if (test->enabled() | 90 if (test->enabled() |
(...skipping 19 matching lines...) Expand all Loading... |
110 test = test->prev(); | 110 test = test->prev(); |
111 } | 111 } |
112 } | 112 } |
113 free(arg_copy); | 113 free(arg_copy); |
114 } | 114 } |
115 } | 115 } |
116 if (print_run_count && tests_run != 1) | 116 if (print_run_count && tests_run != 1) |
117 printf("Ran %i tests.\n", tests_run); | 117 printf("Ran %i tests.\n", tests_run); |
118 return 0; | 118 return 0; |
119 } | 119 } |
OLD | NEW |