Skip to content
Snippets Groups Projects
Commit b7c21a22 authored by Adam Barth's avatar Adam Barth Committed by CQ bot account: commit-bot@chromium.org
Browse files

[recovery] Start on simulator tests

In this CL, we package up QEMU and the test validates that the test is
able to access the QEMU tarball. The next still will be to untar QEMU
and execute it.

Change-Id: Ifb01b55c101d02da837f69ed2b7c15b212d535b0
parent e3cc590c
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ group("tests") {
testonly = true
deps = [
"integration:tests",
"simulator:tests",
"system:tests",
]
}
# Copyright 2019 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.
import("//build/go/go_library.gni")
import("//build/go/go_test.gni")
group("tests") {
testonly = true
deps = []
if (host_os == "linux") {
deps += [ ":recovery_simulator_tests($host_toolchain)" ]
}
}
if (is_linux) {
go_library("lib") {
name = "fuchsia.googlesource.com/recovery/simulator"
deps = [
"//src/testing/qemu",
]
}
go_test("recovery_simulator_tests") {
gopackage = "fuchsia.googlesource.com/recovery/simulator"
deps = [
":lib",
]
}
}
// Copyright 2019 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 simulator
import (
"testing"
"fuchsia.googlesource.com/testing/qemu"
)
// TestUnpack checks that we can unpack qemu.
func TestUnpack(t *testing.T) {
err := qemu.Unpack()
if err != nil {
t.Fatal(err)
}
}
# Copyright 2019 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.
import("//build/go/go_library.gni")
# Currently, we ony support working with the QEMU simulator on Linux.
if (is_linux) {
# The infrastructure does not provide a way for host tests to access
# qemu, so we need to archive our own copy of qemu from the source
# tree.
action("archive") {
visibility = [ ":*" ]
archive_path = "$root_out_dir/test_data/qemu/qemu.tar.gz"
outputs = [
archive_path,
]
depfile = "${archive_path}.d"
script = "archive.py"
args = [
"--src",
rebase_path("//buildtools/linux-x64/qemu"),
"--dst",
rebase_path(archive_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
metadata = {
test_runtime_deps = [ archive_path ]
}
}
go_library("qemu") {
name = "fuchsia.googlesource.com/testing/qemu"
non_go_deps = [ ":archive" ]
}
}
abarth@google.com
joshuaseaton@google.com
#!/usr/bin/env python
# Copyright 2019 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.
import argparse
import sys
import tarfile
import os
def main():
parser = argparse.ArgumentParser('Archives a directory')
parser.add_argument('--src',
help='Path to the directory to archive',
required=True)
parser.add_argument('--dst',
help='Path to the archive',
required=True)
parser.add_argument('--depfile',
help='Path to dependency file',
required=True)
args = parser.parse_args()
deps = []
with tarfile.open(args.dst, "w:gz") as tar:
for (dirpath, dirnames, filenames) in os.walk(args.src):
for filename in filenames:
path = os.path.join(dirpath, filename)
deps.append(os.path.relpath(path))
tar.add(path, arcname=os.path.relpath(path, args.src))
with open(args.depfile, 'w') as depfile:
depfile.write('%s: %s\n' % (args.dst, ' '.join(sorted(deps))))
return 0
if __name__ == "__main__":
sys.exit(main())
// Copyright 2019 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 qemu
import (
"os"
"path/filepath"
)
// Unpack the QEMU instance.
func Unpack() error {
ex, err := os.Executable()
if err != nil {
return err
}
exPath := filepath.Dir(ex)
archivePath := filepath.Join(exPath, "test_data/qemu/qemu.tar.gz")
_, err = os.Stat(archivePath)
return err
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment