blob: 5990bf9336277df5d8279357bf1737a13002b072 [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
9namespace debugd {
10
11const char* kMemtesterpath = "/usr/sbin/memtester";
12
13MemtesterTool::MemtesterTool() { }
14MemtesterTool::~MemtesterTool() { }
15
16std::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