blob: 57ccf3196136a48d4ab3d4937f9eeaab06a30201 [file] [log] [blame]
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <sys/utsname.h>
#include <string>
#include <base/optional.h>
#include "diagnostics/cros_healthd/system/system_utilities.h"
#include "diagnostics/cros_healthd/system/system_utilities_constants.h"
namespace diagnostics {
// Fake implementation of the SystemUtilities interface.
class FakeSystemUtilities final : public SystemUtilities {
FakeSystemUtilities(const FakeSystemUtilities&) = delete;
FakeSystemUtilities& operator=(const FakeSystemUtilities&) = delete;
~FakeSystemUtilities() override;
// SystemUtilities overrides:
int Uname(struct utsname* buf) override;
// Sets the response to any Uname() calls. If specified, |machine| will be
// used to populate the Uname() call's |buf|.machine output parameter. The
// other fields of |buf| will be left empty.
void SetUnameResponse(int ret_code,
const base::Optional<std::string>& machine);
// Used as the return value for any Uname() calls received. Defaults to
// success.
int uname_ret_code_ = 0;
// When |uname_ret_code_| is set to success, any received Uname() calls will
// set the |buf|.machine output parameter to this value.
std::string uname_machine_ = kUnameMachineX86_64;
} // namespace diagnostics