diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 18:40:43 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 18:40:43 +0000 |
commit | e628fe18c8caa03a62770d095a79e9e1b6a88b49 (patch) | |
tree | 0278c46f448d42f52d7b41fddca1c5f0606a087b /webkit/tools/test_shell/test_shell_main.cc | |
parent | 58989e64342e17a630cf98a1c8efa514eba7c1ce (diff) | |
download | chromium_src-e628fe18c8caa03a62770d095a79e9e1b6a88b49.zip chromium_src-e628fe18c8caa03a62770d095a79e9e1b6a88b49.tar.gz chromium_src-e628fe18c8caa03a62770d095a79e9e1b6a88b49.tar.bz2 |
[Mac/Linux] clean up the shmem file at the end of each testshell run.
- Mac/Linux back shmem with a file, but the file isn't cleaned up (since it could be shared), this pulls over the same basic code we used in chrome_test_suite to clean up the files there also so they don't leak a fill up the bots.
BUG=32391
TEST=nothing, http://crbug.com/36261 prevents this from really cleaning up resource leaks
Review URL: http://codereview.chromium.org/651038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell_main.cc')
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index d3db465..9bfd720 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -50,6 +50,15 @@ const char* const kStatsFilePrefix = "testshell_"; int kStatsFileThreads = 20; int kStatsFileCounters = 200; +void RemoveSharedMemoryFile(std::string& filename) { + // Stats uses SharedMemory under the hood. On posix, this results in a file + // on disk. +#if defined(OS_POSIX) + base::SharedMemory memory; + memory.Delete(UTF8ToWide(filename)); +#endif +} + } // namespace int main(int argc, char* argv[]) { @@ -233,10 +242,13 @@ int main(int argc, char* argv[]) { // Load and initialize the stats table. Attempt to construct a somewhat // unique name to isolate separate instances from each other. - StatsTable *table = new StatsTable( - // truncate the random # to 32 bits for the benefit of Mac OS X, to - // avoid tripping over its maximum shared memory segment name length - kStatsFilePrefix + Uint64ToString(base::RandUint64() & 0xFFFFFFFFL), + + // truncate the random # to 32 bits for the benefit of Mac OS X, to + // avoid tripping over its maximum shared memory segment name length + std::string stats_filename = + kStatsFilePrefix + Uint64ToString(base::RandUint64() & 0xFFFFFFFFL); + RemoveSharedMemoryFile(stats_filename); + StatsTable *table = new StatsTable(stats_filename, kStatsFileThreads, kStatsFileCounters); StatsTable::set_current(table); @@ -370,6 +382,7 @@ int main(int argc, char* argv[]) { // Tear down shared StatsTable; prevents unit_tests from leaking it. StatsTable::set_current(NULL); delete table; + RemoveSharedMemoryFile(stats_filename); return 0; } |