Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: test/cctest/cctest.cc

Issue 42329: Getting rid of OS::StrDup and OS::StrNDup which were sometimes misused. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-win32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
37 37
38 CcTest::CcTest(TestFunction* callback, const char* file, const char* name, 38 CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
39 const char* dependency, bool enabled) 39 const char* dependency, bool enabled)
40 : callback_(callback), name_(name), dependency_(dependency), prev_(last_) { 40 : callback_(callback), name_(name), dependency_(dependency), 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 = v8::internal::OS::StrDup(file); 47 basename = v8::internal::StrDup(file);
48 } else { 48 } else {
49 basename = v8::internal::OS::StrDup(basename + 1); 49 basename = v8::internal::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 15 matching lines...) Expand all
75 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 75 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
76 int tests_run = 0; 76 int tests_run = 0;
77 bool print_run_count = true; 77 bool print_run_count = true;
78 for (int i = 1; i < argc; i++) { 78 for (int i = 1; i < argc; i++) {
79 char* arg = argv[i]; 79 char* arg = argv[i];
80 if (strcmp(arg, "--list") == 0) { 80 if (strcmp(arg, "--list") == 0) {
81 PrintTestList(CcTest::last()); 81 PrintTestList(CcTest::last());
82 print_run_count = false; 82 print_run_count = false;
83 83
84 } else { 84 } else {
85 char* arg_copy = v8::internal::OS::StrDup(arg); 85 char* arg_copy = v8::internal::StrDup(arg);
86 char* testname = strchr(arg_copy, '/'); 86 char* testname = strchr(arg_copy, '/');
87 if (testname) { 87 if (testname) {
88 // Split the string in two by nulling the slash and then run 88 // Split the string in two by nulling the slash and then run
89 // exact matches. 89 // exact matches.
90 *testname = 0; 90 *testname = 0;
91 char* file = arg_copy; 91 char* file = arg_copy;
92 char* name = testname + 1; 92 char* name = testname + 1;
93 CcTest* test = CcTest::last(); 93 CcTest* test = CcTest::last();
94 while (test != NULL) { 94 while (test != NULL) {
95 if (test->enabled() 95 if (test->enabled()
(...skipping 12 matching lines...) Expand all
108 while (test != NULL) { 108 while (test != NULL) {
109 if (test->enabled() 109 if (test->enabled()
110 && (strcmp(test->file(), file_or_name) == 0 110 && (strcmp(test->file(), file_or_name) == 0
111 || strcmp(test->name(), file_or_name) == 0)) { 111 || strcmp(test->name(), file_or_name) == 0)) {
112 test->Run(); 112 test->Run();
113 tests_run++; 113 tests_run++;
114 } 114 }
115 test = test->prev(); 115 test = test->prev();
116 } 116 }
117 } 117 }
118 free(arg_copy); 118 v8::internal::DeleteArray<char>(arg_copy);
119 } 119 }
120 } 120 }
121 if (print_run_count && tests_run != 1) 121 if (print_run_count && tests_run != 1)
122 printf("Ran %i tests.\n", tests_run); 122 printf("Ran %i tests.\n", tests_run);
123 return 0; 123 return 0;
124 } 124 }
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698