mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 00:24:51 +00:00
parent
90709fc4d3
commit
c25fbc010d
1
repos/gems/recipes/pkg/test-depot_query_index/README
Normal file
1
repos/gems/recipes/pkg/test-depot_query_index/README
Normal file
@ -0,0 +1 @@
|
||||
Test for querying index files from a depot
|
4
repos/gems/recipes/pkg/test-depot_query_index/archives
Normal file
4
repos/gems/recipes/pkg/test-depot_query_index/archives
Normal file
@ -0,0 +1,4 @@
|
||||
_/src/init
|
||||
_/src/report_rom
|
||||
_/src/depot_query
|
||||
_/src/vfs
|
1
repos/gems/recipes/pkg/test-depot_query_index/hash
Normal file
1
repos/gems/recipes/pkg/test-depot_query_index/hash
Normal file
@ -0,0 +1 @@
|
||||
2019-02-20 c7c4dffe693619f1906dd0c3398df4e6cf001ea9
|
67
repos/gems/recipes/pkg/test-depot_query_index/runtime
Normal file
67
repos/gems/recipes/pkg/test-depot_query_index/runtime
Normal file
@ -0,0 +1,67 @@
|
||||
<runtime ram="32M" caps="1000" binary="init">
|
||||
|
||||
<events>
|
||||
<timeout meaning="failed" sec="10" />
|
||||
<log meaning="succeeded">
|
||||
[init -> report_rom] report 'depot_query -> index'
|
||||
[init -> report_rom] *<index>
|
||||
[init -> report_rom] <index user="genodelabs" version="19.02">
|
||||
[init -> report_rom] <index name="Demos">
|
||||
[init -> report_rom] <pkg path="nano3d" info="simple software-rendering demo"/>
|
||||
[init -> report_rom] </index>
|
||||
[init -> report_rom] </index>
|
||||
[init -> report_rom] <missing user="genodelabs" version="19.03"/>
|
||||
[init -> report_rom] </index>
|
||||
</log>
|
||||
</events>
|
||||
|
||||
<content>
|
||||
<rom label="ld.lib.so"/>
|
||||
<rom label="report_rom"/>
|
||||
<rom label="vfs.lib.so"/>
|
||||
<rom label="depot_query"/>
|
||||
</content>
|
||||
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="report_rom">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Report"/> <service name="ROM"/> </provides>
|
||||
<config verbose="yes"/>
|
||||
</start>
|
||||
|
||||
<start name="depot_query">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<config arch="x86_64">
|
||||
|
||||
<!-- test queries -->
|
||||
<index user="genodelabs" version="19.02" content="yes"/>
|
||||
<index user="genodelabs" version="19.03"/> <!-- does not exist -->
|
||||
|
||||
<vfs>
|
||||
<dir name="depot"> <dir name="genodelabs"> <dir name="index">
|
||||
<inline name="19.02">
|
||||
<index>
|
||||
<index name="Demos">
|
||||
<pkg path="nano3d" info="simple software-rendering demo"/>
|
||||
</index>
|
||||
</index>
|
||||
</inline>
|
||||
</dir> </dir> </dir>
|
||||
</vfs>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
</runtime>
|
@ -652,6 +652,7 @@ set default_test_pkgs {
|
||||
test-block
|
||||
test-block_cache
|
||||
test-clipboard
|
||||
test-depot_query_index
|
||||
test-ds_ownership
|
||||
test-dynamic_config
|
||||
test-dynamic_config_loader
|
||||
|
@ -170,6 +170,7 @@ struct Depot_query::Main
|
||||
Constructible_reporter _blueprint_reporter { };
|
||||
Constructible_reporter _dependencies_reporter { };
|
||||
Constructible_reporter _user_reporter { };
|
||||
Constructible_reporter _index_reporter { };
|
||||
|
||||
template <typename T, typename... ARGS>
|
||||
static void _construct_if(bool condition, Constructible<T> &obj, ARGS &&... args)
|
||||
@ -226,6 +227,7 @@ struct Depot_query::Main
|
||||
void _collect_source_dependencies(Archive::Path const &, Dependencies &, Recursion_limit);
|
||||
void _collect_binary_dependencies(Archive::Path const &, Dependencies &, Recursion_limit);
|
||||
void _query_user(Archive::User const &, Xml_generator &);
|
||||
void _query_index(Archive::User const &, Archive::Version const &, bool, Xml_generator &);
|
||||
|
||||
void _handle_config()
|
||||
{
|
||||
@ -266,6 +268,9 @@ struct Depot_query::Main
|
||||
_construct_if(query.has_sub_node("user"),
|
||||
_user_reporter, _env, "user", "user");
|
||||
|
||||
_construct_if(query.has_sub_node("index"),
|
||||
_index_reporter, _env, "index", "index");
|
||||
|
||||
_root.apply_config(config.sub_node("vfs"));
|
||||
|
||||
/* ignore incomplete queries that may occur at the startup */
|
||||
@ -324,6 +329,13 @@ struct Depot_query::Main
|
||||
first = false;
|
||||
_query_user(node.attribute_value("name", Archive::User()), xml); });
|
||||
});
|
||||
|
||||
_gen_versioned_report(_index_reporter, version, [&] (Xml_generator &xml) {
|
||||
query.for_each_sub_node("index", [&] (Xml_node node) {
|
||||
_query_index(node.attribute_value("user", Archive::User()),
|
||||
node.attribute_value("version", Archive::Version()),
|
||||
node.attribute_value("content", false),
|
||||
xml); }); });
|
||||
}
|
||||
|
||||
Main(Env &env) : _env(env)
|
||||
@ -589,6 +601,38 @@ void Depot_query::Main::_query_user(Archive::User const &user, Xml_generator &xm
|
||||
}
|
||||
|
||||
|
||||
void Depot_query::Main::_query_index(Archive::User const &user,
|
||||
Archive::Version const &version,
|
||||
bool const content, Xml_generator &xml)
|
||||
{
|
||||
Directory::Path const index_path("depot/", user, "/index/", version);
|
||||
if (!_root.file_exists(index_path)) {
|
||||
xml.node("missing", [&] () {
|
||||
xml.attribute("user", user);
|
||||
xml.attribute("version", version);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
xml.node("index", [&] () {
|
||||
xml.attribute("user", user);
|
||||
xml.attribute("version", version);
|
||||
|
||||
if (content) {
|
||||
try {
|
||||
File_content const
|
||||
file(_heap, _root, index_path, File_content::Limit{16*1024});
|
||||
|
||||
file.xml([&] (Xml_node node) {
|
||||
node.with_raw_content([&] (char const *start, size_t lenght) {
|
||||
xml.append(start, lenght); }); });
|
||||
|
||||
} catch (Directory::Nonexistent_file) { }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
static Depot_query::Main main(env);
|
||||
|
Loading…
x
Reference in New Issue
Block a user