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 | |
| 5 | #include "memory_tool.h" |
| 6 | |
| 7 | #include "process_with_id.h" |
| 8 | |
| 9 | namespace debugd { |
| 10 | |
| 11 | const char* kMemtesterpath = "/usr/sbin/memtester"; |
| 12 | |
| 13 | MemtesterTool::MemtesterTool() { } |
| 14 | MemtesterTool::~MemtesterTool() { } |
| 15 | |
| 16 | std::string MemtesterTool::Start(const DBus::FileDescriptor& outfd, |
| 17 | const uint32_t& memory, |
| 18 | DBus::Error& error) { |
| 19 | ProcessWithId* p = CreateProcess(false); |
| 20 | if (!p) |
| 21 | return ""; |
| 22 | |
| 23 | p->AddArg(kMemtesterpath); |
| 24 | p->AddArg(StringPrintf("%u", memory)); |
| 25 | p->AddArg("1"); |
| 26 | p->BindFd(outfd.get(), STDOUT_FILENO); |
| 27 | p->BindFd(outfd.get(), STDERR_FILENO); |
| 28 | LOG(INFO) << "memtester: running process id: " << p->id(); |
| 29 | p->Start(); |
| 30 | return p->id(); |
| 31 | } |
| 32 | |
| 33 | }; // namespace debugd |