blob: 49140c98e8c24ffd6eff8516d71b74d2273a2f72 [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
5#include "memory_tool.h"
6
7#include "process_with_id.h"
8
Ben Chan55903dd2014-04-24 00:29:04 -07009using base::StringPrintf;
10
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070011namespace debugd {
12
13const char* kMemtesterpath = "/usr/sbin/memtester";
14
15MemtesterTool::MemtesterTool() { }
16MemtesterTool::~MemtesterTool() { }
17
18std::string MemtesterTool::Start(const DBus::FileDescriptor& outfd,
19 const uint32_t& memory,
20 DBus::Error& error) {
21 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
35}; // namespace debugd