| # Copyright 2022 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/components.gni") | |
| import("//build/rust/rustc_library.gni") | |
| import("//src/virtualization/lib/qcow/qcow_test_image.gni") | |
| group("tests") { | |
| testonly = true | |
| deps = [ ":qcow_unittests" ] | |
| } | |
| rustc_library("qcow") { | |
| edition = "2021" | |
| with_unit_tests = true | |
| sources = [ | |
| "src/lib.rs", | |
| "src/wire.rs", | |
| ] | |
| deps = [ | |
| "//third_party/rust_crates:anyhow", | |
| "//third_party/rust_crates:zerocopy", | |
| ] | |
| } | |
| # A completely empty image. | |
| qcow_test_image("empty_1gb") { | |
| disk_size = "1G" | |
| } | |
| # A disk image with data written to multiple locations in the file. | |
| qcow_test_image("sparse") { | |
| disk_size = "1G" | |
| writes = [ | |
| # First and third 1k bytes are populated (but not bytes 1025->2048). | |
| "0+1k=0xaa", | |
| "2k+1k=0xab", | |
| # Last 1024 bytes | |
| "1048575k+1k=0xbb", | |
| # Something in the middle | |
| "512M+1k=0xcc", | |
| ] | |
| } | |
| group("test_images") { | |
| deps = [ | |
| ":empty_1gb", | |
| ":sparse", | |
| ] | |
| } | |
| fuchsia_unittest_package("qcow_unittests") { | |
| deps = [ | |
| ":qcow_test", | |
| ":test_images", | |
| ] | |
| } |