blob: d37f48352ce47907a41bf498a20680c64dfa3746 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package fuzz
import (
"fmt"
"io"
)
type mockLauncher struct {
running bool
shouldFailToStart bool
shouldFailToConnect bool
}
func (l *mockLauncher) Prepare() error {
return nil
}
func (l *mockLauncher) Start() (Connector, error) {
if l.running {
return nil, fmt.Errorf("Start called on already-running Launcher")
}
if l.shouldFailToStart {
return nil, fmt.Errorf("Intentionally broken Launcher")
}
l.Prepare()
l.running = true
return &mockConnector{shouldFailToConnect: l.shouldFailToConnect}, nil
}
func (l *mockLauncher) IsRunning() (bool, error) {
return l.running, nil
}
func (l *mockLauncher) Kill() error {
if !l.running {
return fmt.Errorf("Kill called on stopped Launcher")
}
l.running = false
return nil
}
func (l *mockLauncher) GetLogs(out io.Writer) error {
io.WriteString(out, "system log\n")
return nil
}