Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mirrors/fuchsia
  • liang47009/fuchsia
  • panjingkui/fuchsia
  • DIFAN/fuchsia
  • duchen/fuchsia
  • killeder/fuchsia
  • godsayyourick/fuchsia
  • hacrwang/fuchsia
  • jilan1990/fuchsia
9 results
Show changes
Commits on Source (39)
  • Allan MacKinnon's avatar
    [graphics][compute] Properly export C functions for use in C++ (/color,/ts) · b510ca67
    Allan MacKinnon authored
    Tracked by SPN-19.
    
    Testability: not yet part of build.
    Change-Id: I04c73606b03191d2c6e4f2048f329af848c8f5fb
    b510ca67
  • Allan MacKinnon's avatar
    [graphics][compute] Add Spinel libs to compute build. · 2e8e8f5a
    Allan MacKinnon authored
    Tracked by SPN-22 and SPN-19.
    
    Blocks tests SPN-17, SPN-18.
    
    Change-Id: I4bd95681b26b81e3521c518b4d0894730e5c23ce
    2e8e8f5a
  • Allan MacKinnon's avatar
    [graphics][compute] Properly export C functions for use in C++ (HotSort) · 3fd0d3b7
    Allan MacKinnon authored
    Tracked by SPN-19.
    
    Testability: HotSort library and test compile and run.
    Change-Id: I6a80c97057493c3f967cc4eef30691e82d18ad16
    3fd0d3b7
  • James Robinson's avatar
    [zircon] Guard general __TA_xx macros behind _LIBCPP check · 8cd5884f
    James Robinson authored
    We use the __TA_xxx macros to annotate code for clang's thread safety
    analysis features.  The thread safety analysis feature works by
    comparing the annotations on types with the annotations on code using
    those types and generating a warning if the code is identified that is
    inconsistent with the annotations or the defined semantics of the
    annotations.  We frequently use these annotations to describe the
    relationship between code and types from the C++ standard library, such
    as std::mutex.  These types are annotated in the libc++ standard library
    implementation if the preprocessor define
    _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS is set.
    
    In the Fuchsia build, we always set -Wthread-safety and -D_LIBCPP_...
    compiler flags together so the annotations are consistent internally.
    Some SDK customers use the fuchsia SDK and -Wthread-safety flag without
    setting the preprocessor define as they use other libraries which use
    the C++ standard library types in ways incompatible with thread safety
    analysis.  This causes issues when compiling code that uses the
    __TA_xxx macros with types like std::mutex.
    
    This updates the __TA_xxx macros to only enable annotations if we can
    tell that C++ standard library types are annotated (using the
    _LIBCPP_... macro) or if we're in kernel code that we always control.
    
    This also updates zircon/kernel code to use the non-public macros
    defined in zircon/system/private so that they are enabled even when
    libc++ is not involved.
    
    ZX-4091 #done
    
    Change-Id: I74910f6963d79bd2a53cf5d89a183252c5b58e7e
    8cd5884f
  • Aaron Green's avatar
    [fuzzing] Run scripts/fuzzing/test/* as host test. · a5c16227
    Aaron Green authored
    This CL extends the host test for host fuzzers to also run the python
    unit tests for 'fx fuzz'.
    
    Bugs: SEC-170
    Test: fx set core.x64 --with //src/fuzzing:tests
          fx run-host-test fuzzing_host_test
    Change-Id: Ic2568e5603b34d35a94ebe85161f476f7854c330
    a5c16227
  • Roland McGrath's avatar
    [build][fidl] Fix //zircon/public/fidl metadata · 04e0ff45
    Roland McGrath authored
    Step #1's local testing was misconfigured and failed to test the
    step #2 integration build properly as the bots do, so a trivial
    bug slipped through.
    
    Bug: ZX-3365
    Change-Id: I331b3b989125c5982632d310daa8b7d512a49faf
    04e0ff45
  • Ross Wang's avatar
    [e2e][sl4f][dart] Update image byte order to BGRA · e43cb691
    Ross Wang authored
    This changed from RGBA in
    https://github.com/brendan-duncan/image/commit/f3d07a74d17d0004d88fc1043042df9111eb3b6f
    
    Also added a test for this regression.
    
    Issue: https://github.com/brendan-duncan/image/issues/92
    Test: fx run-host-tests sl4f_client_tests
          end-to-end test
    Change-Id: If8c82f9d5479d16e7c41845eb001d6ac8068ea27
    e43cb691
  • Francois Rousseau's avatar
    [crash][feedback] switch to RunLoopUntil() in unit tests · 9db32157
    Francois Rousseau authored
    * apparently RunLoopWithTimeoutUntil() is bad because the default timeout
    isn't guaranteed to be enough on some bots so instead we rely on the
    infra timeout they give to each test
    * we don't check the return value RunLoopUntil() in anticipation of https://fuchsia-review.googlesource.com/c/fuchsia/+/280471
    
    TESTED=`fx run-test feedback_agent_tests`
    TESTED=`fx run-test crashpad_agent_tests`
    
    Change-Id: I491252ef6a3e3f51f418ef5e57d3f426411e54f6
    9db32157
  • Andres Oportus's avatar
    [debugger] Fix typos · 9b2c0057
    Andres Oportus authored
    Change-Id: If6d9f751f9beadf51bddd584eb3f8cb7d5511ef7
    9b2c0057
  • Garratt Gallagher's avatar
    [ISP] Changing fidl file to be not .test · 05c6062d
    Garratt Gallagher authored
    This updates the ISP test fidl interface to comply with abarth's
    fidl rules.
    
    TEST: No functionality change.
    Change-Id: I6660a9bf47e66ba7337c95245f9e7ade5f9dfb3d
    05c6062d
  • Marty Faltesek's avatar
    [zircon][unittest] Rename stack-test.c to stack-test.cpp · c50b1949
    Marty Faltesek authored
    ZX-3736
    
    Test: stack-test
    Change-Id: Ib7a55021bf5790352a451a34a5cad1e74fda780b
    c50b1949
  • Sean Klein's avatar
    [test][hid-parser] Relocate unit tests to exist alongside source · 7ee94191
    Sean Klein authored
    Change-Id: I0a6b422086d82e61c3761d9abc3a0b2e147da3df
    7ee94191
  • John Sheu's avatar
    [banjo] Remove newline stripping from test output · 9c5c8f1d
    John Sheu authored
    This makes it much easier to compare failing test output against the
    reference, as well as to derive new reference outputs from the test log
    when tests are updated.
    
    Change-Id: I7af722007b39bf08ff602636ed6a3562c617aa03
    9c5c8f1d
  • docs-roller's avatar
    [gndoc] Update GN build arguments documentation · a86026a2
    docs-roller authored
    Test: CQ
    
    Change-Id: I0b8a33851af712c41c0bcf84d05a150a29e99730
    a86026a2
  • Manali Bhutiyani's avatar
    [minfs] disk-inspector Part 3: CmdLine/Uapp application to consume the disk-interface · 0e405ecb
    Manali Bhutiyani authored
    This change implements a very simple command line tool/uapp application to consume the
    disk objects for minfs and recursively iterate over all of them.
    Please note that this is not interactive at the time being, but is implemented
    as a first implementation of the disk-inspector tool. It is a good way to
    test the different apis of the disk-inpector library.
    
    Testing: The application itself is pretty dumb and doesn't need unit tests.
              The unit tests for minfs backend are already added as part of the change:
              https://fuchsia-review.googlesource.com/c/fuchsia/+/277175
    Change-Id: Icd211c30bdb2c82c9f242447d8fddc5d7620c323
    0e405ecb
  • John Sheu's avatar
    [banjo] Support more types as union fields · 15405db5
    John Sheu authored
    This causes union fields to be generated using the same logic as struct
    fields, so that arrays and strings are properly handled. Note for now
    that vector fields are excluded from unions, as they actually generate
    two fields (a pointer and a count) which does not interact well with
    unions.
    
    Change-Id: I69a36903390740d5443f5e3ff0d00d3e49e423f8
    15405db5
  • Ben Keller's avatar
    [third-party][rust] Expose arrayvec · 9672aa3c
    Ben Keller authored
    Change-Id: I7e3915b69d321fb2f2b2d2598259ee6dc2eed9b4
    9672aa3c
  • Aaron Wood's avatar
    [omaha client] Implement single request state machine · 9a82fb01
    Aaron Wood authored
    This is the start of the central state machine which makes requests to
    omaha.  This is the initial skeleton if the async flow of performing a
    single update check (and subsequent update if one is returned by Omaha).
    
    Bug: PKG-465
    Test: fx run-test omaha_client_lib_tests
    Test: ran prototype client (not in this CL) with Omaha service
    
    Change-Id: Ic6e07f76bd30f903ee232f61a20ca1f595adeb74
    9a82fb01
  • Jody Sankey's avatar
    [identity] Move integration tests to //src/identity. · 26276537
    Jody Sankey authored
    This are the final things in /garnet/bin/auth so we also delete it
    (yey!).
    
    AUTH-196 #comment
    
    Change-Id: I0d73f3c20d4195de70799f28ce1183395baac4a6
    26276537
  • Nick Cook's avatar
    [docs] Document how to run the examples in //examples. · f1a8516c
    Nick Cook authored
    Add information about running the examples using fx commands.
    
    PiperOrigin-RevId: 246914905
    Change-Id: I6489354d5941671f6f04682e548d32d0bee28fef
    f1a8516c
  • Alex Legg's avatar
    [devfs][test] Fix incorrect assumption in test · fe25b61f
    Alex Legg authored
    We can't assume that there will always be a block device. For now, we
    can assume that there will always be a platform-bus driver bound.
    
    It would be better if we created a fake devfs for these tests but since
    device discovery is going to signficantly change in the near future this
    should be good enough for now.
    
    ZX-4090 #done
    
    Change-Id: I668e6a13ec273f83d13654ba692ea92763fc41b8
    fe25b61f
  • Petr Hosek's avatar
    [zircon][gn] Use AS_NEEDED for libc++.so · a3684085
    Petr Hosek authored
    This avoids the extra DT_NEEDED entry even in cases where libc++.so
    isn't needed. This is also consistent with Clang driver implementation
    which uses --as-needed around libc++.so.
    
    Bug: ZX-4099
    Change-Id: I76475896b7ea2c825a97f28b7b09e53228b468c6
    a3684085
  • Roland McGrath's avatar
    [build] Force a fidl_library() with .test.fidl sources to be testonly · f9a0d908
    Roland McGrath authored
    FIDL source files must be named `*.fidl` and if source files are
    named `*.test.fidl` then the library using it can only be used in
    test code.  So the fidl_library() template automatically sets
    `testonly=true` if its sources list include any `*.test.fidl`.
    It's not allowed to override this with explicit `testonly=false`.
    
    Change-Id: I7bb79327be678efbfd293b9fa2baaad55832c9df
    f9a0d908
  • Ed Coyne's avatar
    [fx] update run-host-tests -z to use build. · fbea4c97
    Ed Coyne authored
    "fx run-host-tests -z" used the removed command "build-zircon" before
    running tests. Update it to use the normal "build" which now builds
    zircon too.
    
    Change-Id: Iaaccb01f9155e3989c68c55612cedf0d92ee1224
    fbea4c97
  • Gianfranco Valentino's avatar
    [zircon][fvm] Integration test cleanup start. · 47e21273
    Gianfranco Valentino authored
    Move the resize tests into their own translation unit ant test target.
    Use zxtest instead of unittest in the new tests.
    Create set of utils for common tasks in the resize tests.
    
    Utils treats devices as objects(Using RAII mechanics to close handles
    and perform cleanup). This reduces the boilerplate of manually creating
    the requests for fvm_* and such free functions, and makes the test more
    readable in terms of what actually matters.
    
    New test target is named fvm-integration-test.
    
    TEST=fvm-test,fvm-integration-test
    
    Change-Id: Ie88fb94c61affe188492e1de2991079cffe91d3d
    47e21273
  • David Stevens's avatar
    [kstress] Fix build file after refactor · 11c8f05f
    David Stevens authored
    Change-Id: Iec766864267074711f7dcc298a037a4288ac7489
    11c8f05f
  • Doug Evans's avatar
    [ktrace_provider] Add test harness · a78a870d
    Doug Evans authored
    ... and context-switch tests
    
    PT-158 #done
    
    Change-Id: I5023f7cfbb073ae7999fcdcd59d2d9370be75963
    a78a870d
  • Aaron Green's avatar
    [build][fuzzing] Rename fuzz_target to fuzzers · e5de6c1f
    Aaron Green authored
    This CL renames the `fuzz_target` GN template to `fuzzers`.  This is
    closer to both Zircon and libFuzzer's terminology.
    
    Test: fx set core.x64 --with //bundles:tests --fuzz-with asan
    Bug: BLD-430
    Change-Id: I79540e844f01d6abe2cee154544b1a480d8ea670
    e5de6c1f
  • Theodore Dubois's avatar
    [libc] Delete ftw/nftw header files and implementation · b4be0a80
    Theodore Dubois authored
    The implementations weren't being compiled in, so why have the headers.
    
    Change-Id: I58f8980e943aad253e65514998bac42c6c64058a
    b4be0a80
  • Gary Bressler's avatar
    [componentmgr] Rename "URI" to "URL" · 7ca1fd5c
    Gary Bressler authored
    "URL" is the new universal terminology.
    
    CF-742 #done
    
    Change-Id: Ib73850b2023b1fb05efdb0c51b2e6f6d0cb6d89d
    7ca1fd5c
  • Ricardo Vargas's avatar
    [zircon/blobfs] Convert unit tests to zxtest. · da780082
    Ricardo Vargas authored
    Change-Id: Ie50a79bc98d6df42c4a52cdaa1abe1d389ff4b15
    da780082
  • Roland McGrath's avatar
    [device-enumeration-test] Fix buffer overrun · e8d17557
    Roland McGrath authored
    The FIDL bindings don't deliver NUL-terminated strings.
    
    Bug: BLD-464
    Change-Id: I68b7e3e9ceb9c44de5a89cf0f3b88bc4bf6d929e
    e8d17557
  • Roland McGrath's avatar
    [zircon][gn] Remove noop-test.fuzzer from build-tests · db779c4a
    Roland McGrath authored
    The compiler doesn't actually support -fsanitize=fuzzer builds
    that supply their own main function instead of getting it from
    libfuzzer.  This was not noticed because build-tests isn't getting
    run on bots.
    
    Bug: BLD-481 #done
    Change-Id: I2575cf987ff083843b22edebb28bd7bcf2525ae3
    db779c4a
  • Allan MacKinnon's avatar
    [tools] fx format-code skips .c files · 2bda6016
    Allan MacKinnon authored
    Tracked by: TC-485
    
    Change-Id: I38c6acf8fda78d167277cc13e6760d5db4f110b2
    2bda6016
  • Ben Keller's avatar
    [package] Produce canonical meta/package json · 50fe9b36
    Ben Keller authored
    Sort keys, no whitespace
    
    Change-Id: Iacf53e608092f3ce6b40bed14a63329ea5f590f3
    50fe9b36
  • Miguel Flores Ruiz de Eguino's avatar
    [discovermgr] Scaffold for discovermgr with DiscoverManager implementation and ModuleOuput skeleton · 095f09bc
    Miguel Flores Ruiz de Eguino authored
    MI4-2367 #comment Scaffold for discovermgr with DiscoverManager
    implementation and ModuleOuput skeleton
    
    TESTED=fx run-test discovermgr_tests
    
    Change-Id: If2948bc83eeec070d1f976bd76a2a514c8c86dd8
    095f09bc
  • Mukesh Agrawal's avatar
    [benchmarks] reduce setup time for RandomMemcpy benchmark · 93f42e98
    Mukesh Agrawal authored
    Allocating the memory buffer for RandomMemcpy can be very slow. In
    some manual testing on Eve, the buffer allocation appeared to take 4-8
    seconds.
    
    This is with a debug build which uses -O0, and the std::vector
    constructor will produce code that does a function call for every byte
    in the 128MB buffer.  (In release builds, the compiler will optimise
    that to a memcpy().  When unoptimised, it's very slow.)
    
    Optimize the buffer allocation, by using a primitive array, rather
    than a std::vector. We fill the array before reading from it, to
    ensure that we do not cause any reads of unitialized memory.
    
    The net result of the optimization is that the time to run the
    benchmarks in "unit-test-mode", on my Eve, drops from ~2 minutes to
    ~30 seconds.
    
    Bug: FLK-124 #done
    Test: /pkgfs/packages/zircon_benchmarks/0/test/zircon_benchmarks (on eve)
    Test: /pkgfs/packages/zircon_benchmarks/0/test/zircon_benchmarks -p (on eve)
    Change-Id: I449a304a60ccee6a137e9371ca4455b8840fedde
    93f42e98
  • Miguel Flores Ruiz de Eguino's avatar
    [discovermgr] Add ContextStore · 56a0f396
    Miguel Flores Ruiz de Eguino authored
    MI4-2413 #done
    
    TESTED=fx run-test discovermgr_tests
    
    Change-Id: Id230a9b1a4b80335fe36b2fa492e3033ac181598
    56a0f396
  • Dragoș Tiselice's avatar
    [build] Fix Rust static library dependecies · 04012f0a
    Dragoș Tiselice authored
    Depending on a static_library from Rust fails because the correct
    link directory path is not passed to build_rustc_target.py. This
    fix adds link paths from every one of the dependecies found in
    non_rust_deps.
    
    This is not ideal since it doesn't work with source_set or any
    shared library that has transitive dependencies.
    
    TEST=Build, CQ, and Rust crate that tests scenario.
         fx run-test static_library_tests
    
    Change-Id: I42c2d07e68d5f7a3d76c0edacbcd0d81f50c4993
    04012f0a
Showing
with 1888 additions and 1530 deletions
......@@ -8,9 +8,9 @@ import("//build/package.gni")
# TODO(aarongreen): SEC-224. Add tests to catch fuzzer building/packaging
# regressions.
# Defines a fuzz target component
# Defines a fuzzer binary.
#
# The fuzz_target template is used to create components containing binaries
# The fuzzer template is used to create components containing binaries
# which leverage LLVM's libFuzzer to perform fuzz testing.
#
# Parameters
......@@ -21,7 +21,7 @@ import("//build/package.gni")
#
# binary (optional)
# [path] The path to the primary binary for the component. This can be
# used to indicate a fuzz_target binary built in a different phase of the
# used to indicate a fuzzer binary built in a different phase of the
# build, e.g. in zircon.
#
# NOTE: Exactly one of sources or binary must be set.
......@@ -35,16 +35,16 @@ import("//build/package.gni")
# [file] If specified, a file containing inputs, one per line, that the
# fuzzer will use to generate new mutations.
#
template("fuzz_target") {
template("fuzzer") {
assert(
(defined(invoker.binary) && !defined(invoker.sources)) ||
(!defined(invoker.binary) || defined(invoker.sources)),
"Exactly one of `binary` or `sources` must be defined for $target_name")
fuzz_target_name = target_name
fuzzer_name = target_name
# If not specified, generate the component binary
if (!defined(invoker.binary)) {
executable(fuzz_target_name) {
executable(fuzzer_name) {
# Explicitly forward visibility, implicitly forward everything else.
# See comment in //build/config/BUILDCONFIG.gn for details on this pattern.
forward_variables_from(invoker, [ "visibility" ])
......@@ -61,11 +61,11 @@ template("fuzz_target") {
}
# Generate the component manifest
fuzz_target_cmx = "${target_gen_dir}/${fuzz_target_name}.cmx"
action("${fuzz_target_name}_cmx") {
fuzzer_cmx = "${target_gen_dir}/${fuzzer_name}.cmx"
action("${fuzzer_name}_cmx") {
script = "//build/fuzzing/gen_fuzzer_manifest.py"
outputs = [
fuzz_target_cmx,
fuzzer_cmx,
]
args = [
"--out",
......@@ -75,7 +75,7 @@ template("fuzz_target") {
if (defined(invoker.binary)) {
args += [ invoker.binary ]
} else {
args += [ fuzz_target_name ]
args += [ fuzzer_name ]
}
if (defined(invoker.cmx)) {
args += [
......@@ -86,9 +86,9 @@ template("fuzz_target") {
}
# Generate data files needed at runtime
output_dictionary = "${target_gen_dir}/${fuzz_target_name}/dictionary"
output_dictionary = "${target_gen_dir}/${fuzzer_name}/dictionary"
if (defined(invoker.dictionary)) {
copy("${fuzz_target_name}_dictionary") {
copy("${fuzzer_name}_dictionary") {
sources = [
invoker.dictionary,
]
......@@ -97,47 +97,47 @@ template("fuzz_target") {
]
}
} else {
generated_file("${fuzz_target_name}_dictionary") {
generated_file("${fuzzer_name}_dictionary") {
contents = []
outputs = [
output_dictionary,
]
}
}
generated_file("${fuzz_target_name}_options") {
generated_file("${fuzzer_name}_options") {
contents = []
if (defined(invoker.options)) {
contents = invoker.options
}
outputs = [
"${target_gen_dir}/${fuzz_target_name}/options",
"${target_gen_dir}/${fuzzer_name}/options",
]
}
# Create the fuzz_target component
deprecated_fuchsia_component("${fuzz_target_name}_component") {
# Create the fuzzer component
deprecated_fuchsia_component("${fuzzer_name}_component") {
testonly = true
manifest = fuzz_target_cmx
manifest = fuzzer_cmx
if (defined(invoker.binary)) {
binary = invoker.binary
} else {
binary = "${fuzz_target_name}"
binary = "${fuzzer_name}"
}
resources = [
{
path = "${target_gen_dir}/${fuzz_target_name}/dictionary"
dest = "${fuzz_target_name}/dictionary"
path = "${target_gen_dir}/${fuzzer_name}/dictionary"
dest = "${fuzzer_name}/dictionary"
},
{
path = "${target_gen_dir}/${fuzz_target_name}/options"
dest = "${fuzz_target_name}/options"
path = "${target_gen_dir}/${fuzzer_name}/options"
dest = "${fuzzer_name}/options"
},
]
deps = []
forward_variables_from(invoker, [ "visibility" ])
if (!defined(invoker.binary)) {
# deps, public_deps, and data_deps are forwarded to ${fuzz_target_name}
deps += [ ":${fuzz_target_name}" ]
# deps, public_deps, and data_deps are forwarded to ${fuzzer_name}
deps += [ ":${fuzzer_name}" ]
} else {
forward_variables_from(invoker,
[
......@@ -147,31 +147,31 @@ template("fuzz_target") {
])
}
deps += [
":${fuzz_target_name}_cmx",
":${fuzz_target_name}_dictionary",
":${fuzz_target_name}_options",
":${fuzzer_name}_cmx",
":${fuzzer_name}_dictionary",
":${fuzzer_name}_options",
]
}
}
set_defaults("fuzz_target") {
set_defaults("fuzzer") {
configs = default_executable_configs +
[ "//build/fuzzing:fuzzing_build_mode_unsafe_for_production" ]
}
# Defines a package of fuzz target components
# Defines a package of fuzzers
#
# The fuzz_package template is used to bundle several fuzz_targets and their
# The fuzzers_package template is used to bundle several fuzzers and their
# associated data into a single Fuchsia package.
#
# Parameters
#
# targets (required)
# [list of labels] The fuzz_target() targets to include in this package.
# fuzzers (required)
# [list of labels] The fuzzer() labels to include in this package.
#
# sanitizers (optional)
# [list of variants] A set of sanitizer variants. The resulting package
# will contain binaries for each sanitizer/target combination. Defaults to
# will contain binaries for each sanitizer/fuzzer combination. Defaults to
# [ "asan", "ubsan" ]
#
# fuzz_host (optional)
......@@ -193,8 +193,8 @@ set_defaults("fuzz_target") {
# data_deps (optional)
# testonly (optional)
# Usual GN meanings.
template("fuzz_package") {
assert(defined(invoker.targets), "targets must be defined for $target_name}")
template("fuzzers_package") {
assert(defined(invoker.fuzzers), "fuzzers must be defined for $target_name}")
if (defined(invoker.sanitizers)) {
sanitizers = invoker.sanitizers
......@@ -211,38 +211,38 @@ template("fuzz_package") {
fuzz_host = false
}
# Collect the selected fuzz targets listed in this package based on the
# variants selected in args.gn and filtered by the package's list of
# supported sanitizers.
# Collect the selected fuzzers listed in this package based on the variants
# selected in args.gn and filtered by the package's list of supported
# sanitizers.
selected = false
selected_targets = []
foreach(fuzz_target, invoker.targets) {
selected_fuzzers = []
foreach(fuzzer, invoker.fuzzers) {
selected = false
foreach(sanitizer, sanitizers) {
foreach(selector, select_variant_canonical) {
if (!selected && selector.variant == "${sanitizer}-fuzzer" &&
((defined(selector.target_type) &&
selector.target_type == [ "fuzzed_executable" ]) ||
(defined(selector.name) && selector.name == [ fuzz_target ]) ||
(defined(selector.name) && selector.name == [ fuzzer ]) ||
(defined(selector.output_name) &&
selector.output_name == [ fuzz_target ]))) {
selector.output_name == [ fuzzer ]))) {
selected = true
selected_targets += [ fuzz_target ]
selected_fuzzers += [ fuzzer ]
}
}
}
}
# Assemble the Fuchsia package
if (selected_targets != []) {
if (selected_fuzzers != []) {
package(target_name) {
metadata = {
fuzz_spec = [
{
fuzz_package = target_name
fuzz_targets = []
foreach(selected_target, selected_targets) {
fuzz_targets += [ get_label_info(selected_target, "name") ]
fuzzers_package = target_name
fuzzers = []
foreach(selected_target, selected_fuzzers) {
fuzzers += [ get_label_info(selected_target, "name") ]
}
fuzz_host = fuzz_host
},
......@@ -257,13 +257,13 @@ template("fuzz_package") {
forward_variables_from(invoker,
"*",
[
"targets",
"fuzzers",
"sanitizers",
"visibility",
"fuzz_host",
])
testonly = true
foreach(selected_target, selected_targets) {
foreach(selected_target, selected_fuzzers) {
components += [ "${selected_target}_component" ]
}
if (fuzz_host) {
......@@ -277,9 +277,9 @@ template("fuzz_package") {
if (fuzz_host) {
install_host_tools("host_${target_name}") {
testonly = true
deps = selected_targets
deps = selected_fuzzers
outputs = []
foreach(target, selected_targets) {
foreach(target, selected_fuzzers) {
outputs += [ get_label_info(target, "name") ]
}
}
......@@ -295,3 +295,22 @@ template("fuzz_package") {
])
}
}
# TODO(aarongreen): Complete soft transition and remove.
# These templates are the old names for `fuzzer` and `fuzzers_package`. They
# are included to allow third_party projects to transition softly.
template("fuzz_target") {
source_set(target_name) {
}
not_needed(invoker, "*")
}
set_defaults("fuzz_target") {
configs = []
}
template("fuzz_package") {
group(target_name) {
}
not_needed(invoker, "*")
}
......@@ -16,7 +16,11 @@ def main():
args = parser.parse_args()
with open(args.path, 'w') as f:
json.dump({'name': args.name, 'version': args.version}, f)
json.dump(
{'name': args.name, 'version': args.version},
f,
separators=(',', ':'),
sort_keys=True)
return 0
......
......@@ -448,6 +448,15 @@ template("rustc_artifact") {
args += [ "--with-unit-tests" ]
}
if (defined(invoker.non_rust_deps)) {
foreach(dep, invoker.non_rust_deps) {
args += [
"--lib-dir",
rebase_path(get_label_info(dep, "target_out_dir")),
]
}
}
args += dep_info_paths
outputs = [
output_file,
......
This diff is collapsed.
# Run the examples
While exploring the source code, you may have noticed the `examples` directory.
This guide will show you how to build Fuchsia to include these examples and then
run them on the device.
## Explore the GN file
Go ahead and open the `BUILD.gn` file in the `examples` directory.
If you aren't familiar with GN, take a look at the
[introductory presentation](https://docs.google.com/presentation/d/15Zwb53JcncHfEwHpnG_PoIbbzQ3GQi_cpujYwbpcbZo/view#slide=id.g119d702868_0_12)
or [docs](https://gn.googlesource.com/gn/+/master/docs/). In short, GN is a meta
build system. Its output files serve as inputs to
[Ninja](https://ninja-build.org/), the actual build system.
In this file, you can see that the examples are designated as a named group.
This group names three targets as dependencies:
```gn
group("examples") {
testonly = true
deps = [
"cowsay",
"fortune",
"hello_world",
]
}
```
You can find a directory for each of these dependencies. Each directory has its
own `BUILD.gn` file that defines a package for the specific example.
Note: You can look at the `build/package.gni` file to learn more about how
Fuchsia packages are defined by GN.
Let's take a look at each example.
### Cowsay
This sample takes a word and repeats it back from an ASCII-art cow.
To access a shell on the device, use the `fx shell` command:
```
fx shell
```
Now run the binary directly:
```
cowsay hi
```
```uglyprint
_____
| hi |
-----
\ ^__^
\ (oo)\_____
(__)\ )\/\
||----w |
|| ||
```
You may notice that you can run this program without any changes to the build
you already served to the device. Why? This example is pulled in as part of the
command line utilities in `garnet/packages/prod/BUILD.gn`. But this isn't
typically how you run a Fuchsia package; you will see that soon.
### Fortune
This sample prints a pithy observation. Let's try to run it using the extended
format for `fx shell` that accepts command arguments:
```
fx shell fortune # won't work, no package in build
```
This won't work since this package wasn't pulled into the last build. You can
confirm it isn't in the build by listing the contents of the `bin` directory:
```
fx shell ls bin
```
`cowsay` is there, but not `fortune`. Don't worry, you will add it soon.
### Hello world
This sample outputs `Hello, world!` and is written in both C++ and Rust. You may
notice something different about this sample: each language-dependent directory
also contains a `meta` subdirectory with `.cmx` files.
This type of file is known as a
[component manifest](glossary.md#component-manifest) and describes how to run
the application on Fuchsia as a [component](glossary.md#component). This is
the proper way to create a Fuchsia package.
You run a Fuchsia component by referencing its
[Fuchsia package URI](glossary.md#fuchsia_pkg-uri).
## Set the build to include examples
You can include the examples in the build, but you need to determine where they
will be included:
* Base: Packages that are included in paving images produced by the build.
They are included in over-the-air updates and are always updated as a
single unit.
* Cache: Packages that are included in paving images, but are not included in
over-the-air system updates. These packages can be updated at any time that
updates are available.
* Universe: Packages that are additional optional packages that can be
fetched and run on-demand, but are not pre-baked into any paving images.
(For more information, see [fx workflows](development/workflows/fx.md).)
To include this package in Universe so it can be fetched on-demand, use the
`--with` flag when setting the product and board:
```
fx set ... --with //examples
fx build
```
You now have a build that includes the examples. Now you need to serve this new
build to the device. You probably already have `fx serve` running, but if not,
go ahead and start it:
```
fx serve
```
## Try the examples
Open a shell on the device to try the examples:
```
fx shell
```
### Cowsay
This should work the same as before. It is still pulled into the base image.
### Fortune
Try to run the fortune example again:
```
fortune
```
It should now return a pithy quote.
### Hello world
You can't run this sample as the other two (try to run `hello_world_cpp` or
`hello_world_rust`). To run a Fuchsia component, you need to run it's Fuchsia
package URI. Lucily, there are some built-in conveniences to help you find this.
You can use the `run` command:
```
run fuchsia-pkg://fuchsia.com/hello_world_cpp#meta/hello_world_cpp.cmx
```
And it should output the following:
```uglyprint
Hello, World!
```
Important: You must have `fx serve` running in order to serve components from
your repository to the device. If it is not running, you may get an error from
the device (for example,
`fuchsia-pkg://fuchsia.com/hello_world_cpp#meta/hello_world_cpp.cmx: not
found`).
The `run` command can expand a string to a URI if the string only matches one
component in your product configuration:
```
run hello_world_cpp
```
If there are multiple matches, the command will list them for you to choose
from:
```
run hello
```
```uglyprint
fuchsia-pkg://fuchsia.com/hello_world_cpp#meta/hello_world_cpp.cmx
fuchsia-pkg://fuchsia.com/hello_world_rust#meta/hello_world_rust.cmx
Error: "hello" matched multiple components.
```
You can explore what components are in your product configuration using the
`locate` command.
* Find your favorite component.
```
locate hello_world_cpp
```
* Find all runnable components in your universe.
```
locate --list cmx
```
* Find multiple test components.
```
locate --list test
```
......@@ -17,5 +17,6 @@ group("tests") {
testonly = true
deps = [
"hello_world:tests",
"rust_static_linking:static_linking_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/package.gni")
import("//build/rust/rustc_library.gni")
rustc_library("static_linking") {
name = "static_linking"
with_unit_tests = true
version = "0.1.0"
edition = "2018"
non_rust_deps = [
":static",
]
}
static_library("static") {
sources = [
"static.c",
]
}
package("static_linking_tests") {
testonly = true
deps = [
":static_linking",
]
tests = [
{
name = "static_linking_lib_test"
},
]
}
......@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <unittest/unittest.h>
#include <zxtest/c/zxtest.h>
#[link(name = "static", kind = "static")]
extern "C" {
pub fn returns_two() -> u32;
}
int main(int argc, char** argv) {
const bool success = unittest_run_all_tests(argc, argv);
if (!success) {
return EXIT_FAILURE;
}
#[cfg(test)]
mod tests {
use super::returns_two;
const bool zxtest_success = RUN_ALL_TESTS(argc, argv) == 0;
if (!zxtest_success) {
return EXIT_FAILURE;
#[test]
fn linking_works() {
assert_eq!(unsafe { returns_two() }, 2);
}
return EXIT_SUCCESS;
}
// 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.
#include <stdint.h>
uint32_t returns_two() {
return 2;
}
jsankey@google.com
ukode@google.com
*
`/bin/auth` contains component binaries related to user identity and
authentication. Please refer to the more detailed README.md file in each
package for more information.
......@@ -29,11 +29,11 @@
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
},
],
"facets": {
......
......@@ -56,7 +56,7 @@ pub struct To {
#[derive(Deserialize, Debug)]
pub struct Child {
pub name: String,
pub uri: String,
pub url: String,
pub startup: Option<String>,
}
......
......@@ -154,7 +154,7 @@ fn translate_children(children_in: &Vec<cml::Child>) -> Result<Vec<cm::Child>, E
return Err(Error::internal(format!("invalid startup")));
}
};
out_children.push(cm::Child { name: child.name.clone(), uri: child.uri.clone(), startup });
out_children.push(cm::Child { name: child.name.clone(), url: child.url.clone(), startup });
}
Ok(out_children)
}
......@@ -328,7 +328,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
},
]
}),
......@@ -358,7 +358,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
}
]
......@@ -386,15 +386,15 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
},
{
"name": "echo_server",
"uri": "fuchsia-pkg://fuchsia.com/echo_server/stable#meta/echo_server.cm"
"url": "fuchsia-pkg://fuchsia.com/echo_server/stable#meta/echo_server.cm"
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm"
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm"
}
]
}),
......@@ -438,17 +438,17 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
},
{
"name": "echo_server",
"uri": "fuchsia-pkg://fuchsia.com/echo_server/stable#meta/echo_server.cm",
"url": "fuchsia-pkg://fuchsia.com/echo_server/stable#meta/echo_server.cm",
"startup": "lazy"
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"startup": "lazy"
}
]
......@@ -459,16 +459,16 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
{
"name": "gmail",
"uri": "https://www.google.com/gmail",
"url": "https://www.google.com/gmail",
"startup": "eager",
},
{
"name": "echo",
"uri": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"startup": "lazy",
},
]
......@@ -477,17 +477,17 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
},
{
"name": "gmail",
"uri": "https://www.google.com/gmail",
"url": "https://www.google.com/gmail",
"startup": "eager"
},
{
"name": "echo",
"uri": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"startup": "lazy"
}
]
......@@ -541,11 +541,11 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm"
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm"
}
],
"facets": {
......@@ -597,12 +597,12 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"startup": "lazy"
}
],
......
......@@ -692,12 +692,12 @@ mod tests {
"children": [
{
"name": "system-logger2",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
},
{
"name": "abc123_-",
"uri": "https://www.google.com/gmail",
"url": "https://www.google.com/gmail",
"startup": "eager"
}
]
......@@ -708,14 +708,14 @@ mod tests {
input = json!({
"children": [ {} ]
}),
result = Err(Error::validate_schema(CM_SCHEMA, "This property is required at /children/0/name, This property is required at /children/0/startup, This property is required at /children/0/uri")),
result = Err(Error::validate_schema(CM_SCHEMA, "This property is required at /children/0/name, This property is required at /children/0/startup, This property is required at /children/0/url")),
},
test_cm_children_bad_name => {
input = json!({
"children": [
{
"name": "bad^",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
}
]
......@@ -827,7 +827,7 @@ mod tests {
"children": [
{
"name": "abcdefghijklmnopqrstuvwxyz0123456789_-.",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
}
]
......@@ -839,7 +839,7 @@ mod tests {
"children": [
{
"name": "#bad",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
}
]
......@@ -851,48 +851,48 @@ mod tests {
"children": [
{
"name": "a".repeat(101),
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
}
]
}),
result = Err(Error::validate_schema(CM_SCHEMA, "MaxLength condition is not met at /children/0/name")),
},
test_cm_uri => {
test_cm_url => {
input = json!({
"children": [
{
"name": "logger",
"uri": "my+awesome-scheme.2://abc123!@#$%.com",
"url": "my+awesome-scheme.2://abc123!@#$%.com",
"startup": "lazy"
}
]
}),
result = Ok(()),
},
test_cm_uri_invalid => {
test_cm_url_invalid => {
input = json!({
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://",
"url": "fuchsia-pkg://",
"startup": "lazy"
}
]
}),
result = Err(Error::validate_schema(CM_SCHEMA, "Pattern condition is not met at /children/0/uri")),
result = Err(Error::validate_schema(CM_SCHEMA, "Pattern condition is not met at /children/0/url")),
},
test_cm_uri_too_long => {
test_cm_url_too_long => {
input = json!({
"children": [
{
"name": "logger",
"uri": &format!("fuchsia-pkg://{}", "a".repeat(4083)),
"url": &format!("fuchsia-pkg://{}", "a".repeat(4083)),
"startup": "lazy"
}
]
}),
result = Err(Error::validate_schema(CM_SCHEMA, "MaxLength condition is not met at /children/0/uri")),
result = Err(Error::validate_schema(CM_SCHEMA, "MaxLength condition is not met at /children/0/url")),
},
}
......@@ -907,7 +907,7 @@ mod tests {
"children": [
{
'name': 'logger',
'uri': 'fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm',
'url': 'fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm',
},
],
}"##;
......@@ -960,7 +960,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
}
]
}),
......@@ -974,7 +974,7 @@ mod tests {
"children": [
{
"name": "abcdefghijklmnopqrstuvwxyz0123456789_-.",
"uri": "https://www.google.com/gmail"
"url": "https://www.google.com/gmail"
}
]
}),
......@@ -1004,7 +1004,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
}
]
}),
......@@ -1049,15 +1049,15 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
},
{
"name": "scenic",
"uri": "fuchsia-pkg://fuchsia.com/scenic/stable#meta/scenic.cm"
"url": "fuchsia-pkg://fuchsia.com/scenic/stable#meta/scenic.cm"
},
{
"name": "echo_server",
"uri": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm"
"url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm"
}
]
}),
......@@ -1079,11 +1079,11 @@ mod tests {
"children": [
{
"name": "abcdefghijklmnopqrstuvwxyz0123456789_-from",
"uri": "https://www.google.com/gmail"
"url": "https://www.google.com/gmail"
},
{
"name": "abcdefghijklmnopqrstuvwxyz0123456789_-to",
"uri": "https://www.google.com/gmail"
"url": "https://www.google.com/gmail"
},
]
}),
......@@ -1152,7 +1152,7 @@ mod tests {
} ],
"children": [ {
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
} ]
}),
result = Err(Error::validate("\"#missing\" is an \"offer\" target but it does not appear in \"children\"")),
......@@ -1179,7 +1179,7 @@ mod tests {
],
} ],
"children": [ {
"name": "logger", "uri": "fuchsia-pkg://fuchsia.com/logger#meta/logger.cm",
"name": "logger", "url": "fuchsia-pkg://fuchsia.com/logger#meta/logger.cm",
} ],
}),
result = Err(Error::validate("Offer target \"#logger\" is same as source")),
......@@ -1206,11 +1206,11 @@ mod tests {
"children": [
{
"name": "scenic",
"uri": "fuchsia-pkg://fuchsia.com/scenic/stable#meta/scenic.cm"
"url": "fuchsia-pkg://fuchsia.com/scenic/stable#meta/scenic.cm"
},
{
"name": "echo_server",
"uri": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm"
"url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm"
}
]
}),
......@@ -1223,16 +1223,16 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
{
"name": "gmail",
"uri": "https://www.google.com/gmail",
"url": "https://www.google.com/gmail",
"startup": "eager",
},
{
"name": "echo",
"uri": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo.cm",
"startup": "lazy",
},
]
......@@ -1243,18 +1243,18 @@ mod tests {
input = json!({
"children": [ {} ]
}),
result = Err(Error::validate_schema(CML_SCHEMA, "This property is required at /children/0/name, This property is required at /children/0/uri")),
result = Err(Error::validate_schema(CML_SCHEMA, "This property is required at /children/0/name, This property is required at /children/0/url")),
},
test_cml_children_duplicate_names => {
input = json!({
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm"
},
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/beta#meta/logger.cm"
"url": "fuchsia-pkg://fuchsia.com/logger/beta#meta/logger.cm"
}
]
}),
......@@ -1265,7 +1265,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "zzz",
},
],
......@@ -1353,7 +1353,7 @@ mod tests {
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
]
}),
......@@ -1364,7 +1364,7 @@ mod tests {
"children": [
{
"name": "abcdefghijklmnopqrstuvwxyz0123456789_-.",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
]
}),
......@@ -1375,7 +1375,7 @@ mod tests {
"children": [
{
"name": "#bad",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
},
]
}),
......@@ -1386,44 +1386,44 @@ mod tests {
"children": [
{
"name": "a".repeat(101),
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
}
]
}),
result = Err(Error::validate_schema(CML_SCHEMA, "MaxLength condition is not met at /children/0/name")),
},
test_cml_uri => {
test_cml_url => {
input = json!({
"children": [
{
"name": "logger",
"uri": "my+awesome-scheme.2://abc123!@#$%.com",
"url": "my+awesome-scheme.2://abc123!@#$%.com",
},
]
}),
result = Ok(()),
},
test_cml_uri_invalid => {
test_cml_url_invalid => {
input = json!({
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://",
"url": "fuchsia-pkg://",
},
]
}),
result = Err(Error::validate_schema(CML_SCHEMA, "Pattern condition is not met at /children/0/uri")),
result = Err(Error::validate_schema(CML_SCHEMA, "Pattern condition is not met at /children/0/url")),
},
test_cml_uri_too_long => {
test_cml_url_too_long => {
input = json!({
"children": [
{
"name": "logger",
"uri": &format!("fuchsia-pkg://{}", "a".repeat(4083)),
"url": &format!("fuchsia-pkg://{}", "a".repeat(4083)),
},
]
}),
result = Err(Error::validate_schema(CML_SCHEMA, "MaxLength condition is not met at /children/0/uri")),
result = Err(Error::validate_schema(CML_SCHEMA, "MaxLength condition is not met at /children/0/url")),
},
}
......
......@@ -42,12 +42,12 @@
"children": [
{
"name": "logger",
"uri": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
"startup": "lazy"
},
{
"name": "netstack",
"uri": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"url": "fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm",
"startup": "lazy"
}
],
......
{"program":{"binary":"bin/example"},"uses":[{"service":{"source_path":"/fonts/CoolFonts","target_path":"/svc/fuchsia.fonts.Provider"}}],"exposes":[{"directory":{"source":{"myself":{}},"source_path":"/volumes/blobfs","target_path":"/volumes/blobfs"}}],"offers":[{"service":{"source":{"child":{"name":"logger"}},"source_path":"/svc/fuchsia.logger.Log","targets":[{"target_path":"/svc/fuchsia.logger.Log","child_name":"netstack"}]}}],"children":[{"name":"logger","uri":"fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm","startup":"lazy"},{"name":"netstack","uri":"fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm","startup":"lazy"}],"facets":{"author":"Fuchsia","year":2018}}
\ No newline at end of file
{"program":{"binary":"bin/example"},"uses":[{"service":{"source_path":"/fonts/CoolFonts","target_path":"/svc/fuchsia.fonts.Provider"}}],"exposes":[{"directory":{"source":{"myself":{}},"source_path":"/volumes/blobfs","target_path":"/volumes/blobfs"}}],"offers":[{"service":{"source":{"child":{"name":"logger"}},"source_path":"/svc/fuchsia.logger.Log","targets":[{"target_path":"/svc/fuchsia.logger.Log","child_name":"netstack"}]}}],"children":[{"name":"logger","url":"fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm","startup":"lazy"},{"name":"netstack","url":"fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm","startup":"lazy"}],"facets":{"author":"Fuchsia","year":2018}}
\ No newline at end of file
......@@ -42,12 +42,12 @@ fn main() {
let children = vec![
ChildDecl {
name: Some("logger".to_string()),
uri: Some("fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm".to_string()),
url: Some("fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm".to_string()),
startup: Some(StartupMode::Lazy),
},
ChildDecl {
name: Some("netstack".to_string()),
uri: Some("fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm".to_string()),
url: Some("fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm".to_string()),
startup: Some(StartupMode::Lazy),
},
];
......
......@@ -3,6 +3,25 @@
# found in the LICENSE file.
import("//build/package.gni")
import("//build/test/test_package.gni")
source_set("importer") {
sources = [
"importer.cc",
"importer.h",
"reader.cc",
"reader.h",
"tags.cc",
"tags.h",
]
public_deps = [
"//src/lib/fxl",
"//zircon/public/lib/fbl",
"//zircon/public/lib/trace-engine",
"//zircon/public/lib/zircon-internal",
]
}
executable("bin") {
output_name = "ktrace_provider"
......@@ -10,18 +29,15 @@ executable("bin") {
sources = [
"app.cc",
"app.h",
"importer.cc",
"importer.h",
"device_reader.cc",
"device_reader.h",
"log_importer.cc",
"log_importer.h",
"main.cc",
"reader.cc",
"reader.h",
"tags.cc",
"tags.h",
]
deps = [
":importer",
"//sdk/lib/sys/cpp",
"//src/lib/fxl",
"//zircon/public/fidl/fuchsia-tracing-kernel:fuchsia-tracing-kernel_c",
......@@ -47,3 +63,36 @@ package("ktrace_provider") {
},
]
}
executable("importer_test_app") {
testonly = true
output_name = "importer_tests"
sources = [
"importer_unittest.cc",
"test_reader.cc",
"test_reader.h",
]
deps = [
":importer",
"//src/lib/fxl",
"//third_party/googletest:gtest",
"//zircon/public/lib/fbl",
"//zircon/public/lib/trace-engine",
"//zircon/public/lib/trace-test-utils",
]
}
test_package("ktrace_provider_tests") {
deps = [
":importer_test_app"
]
tests = [
{
name = "importer_tests"
environments = basic_envs
},
]
}
......@@ -5,21 +5,22 @@
#include "garnet/bin/ktrace_provider/app.h"
#include <fcntl.h>
#include <unistd.h>
#include <fuchsia/tracing/kernel/c/fidl.h>
#include <lib/async/default.h>
#include <lib/fdio/fdio.h>
#include <lib/zx/channel.h>
#include <src/lib/fxl/arraysize.h>
#include <src/lib/fxl/logging.h>
#include <trace-engine/instrumentation.h>
#include <trace-provider/provider.h>
#include <unistd.h>
#include <zircon/device/ktrace.h>
#include <zircon/status.h>
#include <zircon/syscalls/log.h>
#include "garnet/bin/ktrace_provider/device_reader.h"
#include "garnet/bin/ktrace_provider/importer.h"
#include "garnet/bin/ktrace_provider/reader.h"
#include "src/lib/fxl/arraysize.h"
#include "src/lib/fxl/logging.h"
namespace ktrace_provider {
namespace {
......@@ -191,7 +192,7 @@ void App::StopKTrace() {
// Acquire a context for writing to the trace buffer.
auto buffer_context = trace_acquire_context();
Reader reader;
DeviceReader reader;
Importer importer(buffer_context);
if (!importer.Import(reader)) {
FXL_LOG(ERROR) << "Errors encountered while importing ktrace data";
......