blob: d8e8b03d901e1063dde2c680a27551f6b281daa0 [file] [log] [blame]
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -07001// 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 Vakulenko262be3f2014-07-30 15:25:50 -07005#include "debugd/src/memory_tool.h"
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -07006
Alex Vakulenko262be3f2014-07-30 15:25:50 -07007#include "debugd/src/process_with_id.h"
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -07008
Ben Chan55903dd2014-04-24 00:29:04 -07009using base::StringPrintf;
10
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070011namespace debugd {
12
Ben Chana0011d82014-05-13 00:19:29 -070013namespace {
14
15const char kMemtesterpath[] = "/usr/sbin/memtester";
16
17} // namespace
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070018
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070019std::string MemtesterTool::Start(const DBus::FileDescriptor& outfd,
Eric Carusoc93a15c2017-04-24 16:15:12 -070020 const uint32_t& memory) {
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070021 ProcessWithId* p = CreateProcess(false);
22 if (!p)
23 return "";
24
25 p->AddArg(kMemtesterpath);
26 p->AddArg(StringPrintf("%u", memory));
27 p->AddArg("1");
28 p->BindFd(outfd.get(), STDOUT_FILENO);
29 p->BindFd(outfd.get(), STDERR_FILENO);
30 LOG(INFO) << "memtester: running process id: " << p->id();
31 p->Start();
32 return p->id();
33}
34
Ben Chana0011d82014-05-13 00:19:29 -070035} // namespace debugd