Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #include "debugd/src/memory_tool.h" |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 6 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 7 | #include "debugd/src/process_with_id.h" |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 8 | |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 9 | namespace debugd { |
| 10 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 11 | namespace { |
| 12 | |
| 13 | const char kMemtesterpath[] = "/usr/sbin/memtester"; |
| 14 | |
| 15 | } // namespace |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 16 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 17 | std::string MemtesterTool::Start(const dbus::FileDescriptor& outfd, |
Eric Caruso | c93a15c | 2017-04-24 16:15:12 -0700 | [diff] [blame] | 18 | const uint32_t& memory) { |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 19 | ProcessWithId* p = CreateProcess(false); |
| 20 | if (!p) |
| 21 | return ""; |
| 22 | |
| 23 | p->AddArg(kMemtesterpath); |
Eric Caruso | 96d03d3 | 2017-04-25 18:01:17 -0700 | [diff] [blame] | 24 | p->AddArg(base::StringPrintf("%u", memory)); |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 25 | p->AddArg("1"); |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 26 | p->BindFd(outfd.value(), STDOUT_FILENO); |
| 27 | p->BindFd(outfd.value(), STDERR_FILENO); |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 28 | LOG(INFO) << "memtester: running process id: " << p->id(); |
| 29 | p->Start(); |
| 30 | return p->id(); |
| 31 | } |
| 32 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 33 | } // namespace debugd |