[cmc] Remove support for compiling path-based capabilities
Bug: 56604
Change-Id: I90ed141a161c9af1329c038e70ef7c6cf44350a2
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/442095
Commit-Queue: Gary Bressler <geb@google.com>
Reviewed-by: Derek Gonyeo <dgonyeo@google.com>
Reviewed-by: Miguel Flores <miguelfrde@google.com>
Testability-Review: Derek Gonyeo <dgonyeo@google.com>
Testability-Review: Miguel Flores <miguelfrde@google.com>
diff --git a/src/diagnostics/archivist/meta/archivist.cml b/src/diagnostics/archivist/meta/archivist.cml
index 4430f31..c7b6f69 100644
--- a/src/diagnostics/archivist/meta/archivist.cml
+++ b/src/diagnostics/archivist/meta/archivist.cml
@@ -60,7 +60,7 @@
},
{
event_stream: [ "capability_requested" ],
- as: "/svc/fuchsia.sys2.EventStream",
+ path: "/svc/fuchsia.sys2.EventStream",
},
{
directory: "config-data",
diff --git a/src/sys/component_manager/tests/events/components/static_event_stream/meta/trigger_server.cml b/src/sys/component_manager/tests/events/components/static_event_stream/meta/trigger_server.cml
index 878c706..0a80533 100644
--- a/src/sys/component_manager/tests/events/components/static_event_stream/meta/trigger_server.cml
+++ b/src/sys/component_manager/tests/events/components/static_event_stream/meta/trigger_server.cml
@@ -41,11 +41,11 @@
},
{
event_stream: [ "capability_requested" ],
- as: "/svc/fuchsia.sys2.EventStream",
+ path: "/svc/fuchsia.sys2.EventStream",
},
{
event_stream: [ "capability_requested" ],
- as: "/svc/second_stream",
+ path: "/svc/second_stream",
},
],
expose: [
diff --git a/src/sys/component_manager/tests/rights/meta/invalid_intermediate_offer_dir_rights.cml b/src/sys/component_manager/tests/rights/meta/invalid_intermediate_offer_dir_rights.cml
index 1be0621..c37ddbb 100644
--- a/src/sys/component_manager/tests/rights/meta/invalid_intermediate_offer_dir_rights.cml
+++ b/src/sys/component_manager/tests/rights/meta/invalid_intermediate_offer_dir_rights.cml
@@ -21,7 +21,7 @@
{
directory: "read_write",
from: "parent",
- as: "/read_write_dup",
+ as: "read_write_dup",
to: [ "#use_dir_rights" ],
},
diff --git a/src/sys/component_manager/tests/rights/meta/root_invalid_offer_dir_rights.cml b/src/sys/component_manager/tests/rights/meta/root_invalid_offer_dir_rights.cml
index 8079946..ad86372 100644
--- a/src/sys/component_manager/tests/rights/meta/root_invalid_offer_dir_rights.cml
+++ b/src/sys/component_manager/tests/rights/meta/root_invalid_offer_dir_rights.cml
@@ -29,7 +29,7 @@
{
directory: "read_write",
from: "#expose_dir_rights",
- as: "/read_write_dup",
+ as: "read_write_dup",
to: [ "#use_dir_rights" ],
},
{
diff --git a/src/sys/core/meta/core.cml b/src/sys/core/meta/core.cml
index 5dc5de5..1d415e9 100644
--- a/src/sys/core/meta/core.cml
+++ b/src/sys/core/meta/core.cml
@@ -40,7 +40,7 @@
storage: "data",
from: "parent",
subdir: "persistent",
- backing_dir: "/minfs",
+ backing_dir: "minfs",
},
{ protocol: "fuchsia.appmgr.Startup" },
],
diff --git a/tools/cmc/meta/example.cml b/tools/cmc/meta/example.cml
index 058ad0e..f720912 100644
--- a/tools/cmc/meta/example.cml
+++ b/tools/cmc/meta/example.cml
@@ -34,7 +34,7 @@
{
storage: "minfs",
from: "parent",
- backing_dir: "/data",
+ backing_dir: "data",
},
{
runner: "dart_runner",
@@ -77,7 +77,7 @@
"destroyed",
"diagnostics_ready",
],
- as: "/svc/my_stream",
+ path: "/svc/my_stream",
},
],
offer: [
diff --git a/tools/cmc/src/compile.rs b/tools/cmc/src/compile.rs
index 066ef63..54bdeea 100644
--- a/tools/cmc/src/compile.rs
+++ b/tools/cmc/src/compile.rs
@@ -192,7 +192,7 @@
.ok_or_else(|| Error::internal("no capability"))?;
let source_ids = p.to_vec();
for (source_id, target_id) in source_ids.into_iter().zip(target_ids.into_iter()) {
- let target_path = cml::NameOrPath::Path(target_id.extract_path()?);
+ let target_path = target_id.extract_path()?;
out_uses.push(fsys::UseDecl::Protocol(fsys::UseProtocolDecl {
source: Some(clone_fsys_ref(&source)?),
source_path: Some(source_id.clone().into()),
@@ -201,10 +201,8 @@
}
} else if let Some(p) = use_.directory() {
let source = extract_use_source(use_)?;
- let target_path = cml::NameOrPath::Path(
- one_target_capability_id(use_, use_, cml::RoutingClauseType::Use)?
- .extract_path()?,
- );
+ let target_path = one_target_capability_id(use_, use_, cml::RoutingClauseType::Use)?
+ .extract_path()?;
let rights = translate::extract_required_rights(use_, "use")?;
let subdir = extract_use_subdir(use_);
out_uses.push(fsys::UseDecl::Directory(fsys::UseDirectoryDecl {
@@ -215,10 +213,8 @@
subdir: subdir.map(|s| s.into()),
}));
} else if let Some(s) = use_.storage() {
- let target_path = cml::NameOrPath::Path(
- one_target_capability_id(use_, use_, cml::RoutingClauseType::Use)?
- .extract_path()?,
- );
+ let target_path = one_target_capability_id(use_, use_, cml::RoutingClauseType::Use)?
+ .extract_path()?;
out_uses.push(fsys::UseDecl::Storage(fsys::UseStorageDecl {
source_name: Some(s.to_string()),
target_path: Some(target_path.into()),
@@ -377,8 +373,11 @@
// TODO: This logic could be simplified to use iter::zip() if
// extract_all_targets_for_each_child returned separate vectors for targets and
// target_ids instead of the cross product of them.
- let source_id =
- if source_ids.len() == 1 { source_ids[0].clone() } else { target_id.clone() };
+ let source_id = if source_ids.len() == 1 {
+ source_ids[0].clone()
+ } else {
+ target_id.extract_name_borrowed()?.clone()
+ };
out_offers.push(fsys::OfferDecl::Protocol(fsys::OfferProtocolDecl {
source: Some(clone_fsys_ref(&source)?),
source_path: Some(source_id.clone().into()),
@@ -779,7 +778,7 @@
{
if let Some(as_) = to_obj.r#as() {
// We've already validated that when `as` is specified, only 1 source id exists.
- Some(OneOrMany::One(as_.clone()))
+ Some(OneOrMany::One(cml::NameOrPath::Name(as_.clone())))
} else {
if let Some(n) = in_obj.service() {
if let cml::RoutingClauseType::Use = clause_type {
@@ -795,9 +794,7 @@
}
} else if let Some(p) = in_obj.protocol() {
Some(match p {
- OneOrMany::One(cml::NameOrPath::Name(n))
- if clause_type == cml::RoutingClauseType::Use =>
- {
+ OneOrMany::One(n) if clause_type == cml::RoutingClauseType::Use => {
if let Some(path) = to_obj.path() {
OneOrMany::One(cml::NameOrPath::Path(path.clone()))
} else {
@@ -806,24 +803,16 @@
))
}
}
- OneOrMany::One(cml::NameOrPath::Name(n))
- if clause_type == cml::RoutingClauseType::Use =>
- {
- OneOrMany::One(cml::NameOrPath::Name(n.clone()))
- }
- OneOrMany::One(path) => OneOrMany::One(path.clone()),
+ OneOrMany::One(n) => OneOrMany::One(cml::NameOrPath::Name(n)),
OneOrMany::Many(v) => {
let many = v
.iter()
- .map(|p| match p {
- cml::NameOrPath::Name(n) => {
- if let cml::RoutingClauseType::Use = clause_type {
- cml::NameOrPath::Path(format!("/svc/{}", n).parse().unwrap())
- } else {
- cml::NameOrPath::Name(n.clone())
- }
+ .map(|n| {
+ if let cml::RoutingClauseType::Use = clause_type {
+ cml::NameOrPath::Path(format!("/svc/{}", n).parse().unwrap())
+ } else {
+ cml::NameOrPath::Name(n.clone())
}
- path => path.clone(),
})
.collect();
OneOrMany::Many(many)
@@ -831,12 +820,11 @@
})
} else if let Some(d) = in_obj.directory() {
Some(match d {
- cml::NameOrPath::Name(_) if clause_type == cml::RoutingClauseType::Use => {
+ _ if clause_type == cml::RoutingClauseType::Use => {
let path = to_obj.path().expect("no path on use directory");
OneOrMany::One(cml::NameOrPath::Path(path.clone()))
}
- cml::NameOrPath::Name(n) => OneOrMany::One(cml::NameOrPath::Name(n.clone())),
- path => OneOrMany::One(path.clone()),
+ n => OneOrMany::One(cml::NameOrPath::Name(n.clone())),
})
} else if let Some(n) = in_obj.storage() {
if clause_type == cml::RoutingClauseType::Use {
@@ -853,6 +841,10 @@
Some(OneOrMany::One(cml::NameOrPath::Name(event.clone())))
} else if let Some(OneOrMany::Many(events)) = in_obj.event() {
Some(OneOrMany::Many(events.iter().map(|e| cml::NameOrPath::Name(e.clone())).collect()))
+ } else if let Some(_) = in_obj.event_stream() {
+ Some(OneOrMany::One(cml::NameOrPath::Path(
+ to_obj.path().expect("no path on event stream").clone(),
+ )))
} else {
None
}
@@ -1021,11 +1013,8 @@
{ "service": "CoolFonts", "path": "/svc/fuchsia.fonts.Provider" },
{ "service": "fuchsia.sys2.Realm", "from": "framework" },
{ "protocol": "LegacyCoolFonts", "path": "/svc/fuchsia.fonts.LegacyProvider" },
- { "protocol": "/fonts/LegacyCoolFonts", "as": "/svc/fuchsia.fonts.LegacyProvider2" },
{ "protocol": "fuchsia.sys2.LegacyRealm", "from": "framework" },
- { "protocol": "/svc/fuchsia.sys2.LegacyRealm2", "from": "framework" },
{ "directory": "assets", "rights" : ["read_bytes"], "path": "/data/assets" },
- { "directory": "/data/assets2", "rights" : ["read_bytes"]},
{
"directory": "config",
"path": "/data/config",
@@ -1033,12 +1022,6 @@
"rights": ["read_bytes"],
"subdir": "fonts",
},
- {
- "directory": "/data/config2",
- "from": "parent",
- "rights": ["read_bytes"],
- "subdir": "fonts",
- },
{ "storage": "hippos", "path": "/hippos" },
{ "storage": "cache", "path": "/tmp" },
{ "runner": "elf" },
@@ -1078,25 +1061,11 @@
),
fsys::UseDecl::Protocol (
fsys::UseProtocolDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/fonts/LegacyCoolFonts".to_string()),
- target_path: Some("/svc/fuchsia.fonts.LegacyProvider2".to_string()),
- }
- ),
- fsys::UseDecl::Protocol (
- fsys::UseProtocolDecl {
source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
source_path: Some("fuchsia.sys2.LegacyRealm".to_string()),
target_path: Some("/svc/fuchsia.sys2.LegacyRealm".to_string()),
}
),
- fsys::UseDecl::Protocol (
- fsys::UseProtocolDecl {
- source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
- source_path: Some("/svc/fuchsia.sys2.LegacyRealm2".to_string()),
- target_path: Some("/svc/fuchsia.sys2.LegacyRealm2".to_string()),
- }
- ),
fsys::UseDecl::Directory (
fsys::UseDirectoryDecl {
source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
@@ -1109,30 +1078,12 @@
fsys::UseDecl::Directory (
fsys::UseDirectoryDecl {
source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/data/assets2".to_string()),
- target_path: Some("/data/assets2".to_string()),
- rights: Some(fio2::Operations::ReadBytes),
- subdir: None,
- }
- ),
- fsys::UseDecl::Directory (
- fsys::UseDirectoryDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
source_path: Some("config".to_string()),
target_path: Some("/data/config".to_string()),
rights: Some(fio2::Operations::ReadBytes),
subdir: Some("fonts".to_string()),
}
),
- fsys::UseDecl::Directory (
- fsys::UseDirectoryDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/data/config2".to_string()),
- target_path: Some("/data/config2".to_string()),
- rights: Some(fio2::Operations::ReadBytes),
- subdir: Some("fonts".to_string()),
- }
- ),
fsys::UseDecl::Storage (
fsys::UseStorageDecl {
source_name: Some("hippos".to_string()),
@@ -1218,35 +1169,17 @@
"to": "parent"
},
{
- "protocol": "/loggers/fuchsia.logger.LegacyLog",
- "from": "#logger",
- "as": "/svc/fuchsia.logger.LegacyLog2",
- "to": "parent"
- },
- {
"protocol": [ "A", "B" ],
"from": "self",
"to": "parent"
},
{
- "protocol": [ "/A", "/B" ],
- "from": "self",
- "to": "parent"
- },
- {
"directory": "blob",
"from": "self",
"to": "framework",
"rights": ["r*"],
},
- {
- "directory": "/volumes/blobfs/blob",
- "from": "self",
- "to": "framework",
- "rights": ["r*"],
- },
{ "directory": "hub", "from": "framework" },
- { "directory": "/hub", "from": "framework" },
{ "runner": "web", "from": "self" },
{ "runner": "web", "from": "#logger", "to": "parent", "as": "web-rename" },
{ "resolver": "my_resolver", "from": "#logger", "to": "parent", "as": "pkg_resolver" }
@@ -1318,17 +1251,6 @@
),
fsys::ExposeDecl::Protocol (
fsys::ExposeProtocolDecl {
- source: Some(fsys::Ref::Child(fsys::ChildRef {
- name: "logger".to_string(),
- collection: None,
- })),
- source_path: Some("/loggers/fuchsia.logger.LegacyLog".to_string()),
- target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- target_path: Some("/svc/fuchsia.logger.LegacyLog2".to_string()),
- }
- ),
- fsys::ExposeDecl::Protocol (
- fsys::ExposeProtocolDecl {
source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
source_path: Some("A".to_string()),
target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
@@ -1343,22 +1265,6 @@
target_path: Some("B".to_string()),
}
),
- fsys::ExposeDecl::Protocol (
- fsys::ExposeProtocolDecl {
- source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
- source_path: Some("/A".to_string()),
- target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- target_path: Some("/A".to_string()),
- }
- ),
- fsys::ExposeDecl::Protocol (
- fsys::ExposeProtocolDecl {
- source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
- source_path: Some("/B".to_string()),
- target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- target_path: Some("/B".to_string()),
- }
- ),
fsys::ExposeDecl::Directory (
fsys::ExposeDirectoryDecl {
source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
@@ -1375,20 +1281,6 @@
),
fsys::ExposeDecl::Directory (
fsys::ExposeDirectoryDecl {
- source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
- source_path: Some("/volumes/blobfs/blob".to_string()),
- target: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
- target_path: Some("/volumes/blobfs/blob".to_string()),
- rights: Some(
- fio2::Operations::Connect | fio2::Operations::Enumerate |
- fio2::Operations::Traverse | fio2::Operations::ReadBytes |
- fio2::Operations::GetAttributes
- ),
- subdir: None,
- }
- ),
- fsys::ExposeDecl::Directory (
- fsys::ExposeDirectoryDecl {
source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
source_path: Some("hub".to_string()),
target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
@@ -1397,16 +1289,6 @@
subdir: None,
}
),
- fsys::ExposeDecl::Directory (
- fsys::ExposeDirectoryDecl {
- source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
- source_path: Some("/hub".to_string()),
- target: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- target_path: Some("/hub".to_string()),
- rights: None,
- subdir: None,
- }
- ),
fsys::ExposeDecl::Runner (
fsys::ExposeRunnerDecl {
source: Some(fsys::Ref::Self_(fsys::SelfRef {})),
@@ -1514,12 +1396,6 @@
"dependency": "weak_for_migration"
},
{
- "protocol": "/svc/fuchsia.logger.LegacyLog",
- "from": "#logger",
- "to": [ "#netstack" ],
- "dependency": "weak_for_migration"
- },
- {
"protocol": "fuchsia.logger.LegacyLog",
"from": "#logger",
"to": [ "#modular" ],
@@ -1527,13 +1403,6 @@
"dependency": "strong"
},
{
- "protocol": "/svc/fuchsia.logger.LegacyLog",
- "from": "#logger",
- "to": [ "#modular" ],
- "as": "/svc/fuchsia.logger.LegacySysLog",
- "dependency": "strong"
- },
- {
"protocol": [
"fuchsia.setui.SetUiService",
"fuchsia.wlan.service.Wlan"
@@ -1542,26 +1411,12 @@
"to": [ "#modular" ]
},
{
- "protocol": [
- "/svc/fuchsia.setui.SetUiService",
- "/svc/fuchsia.wlan.service.Wlan"
- ],
- "from": "parent",
- "to": [ "#modular" ]
- },
- {
"directory": "assets",
"from": "parent",
"to": [ "#netstack" ],
"dependency": "weak_for_migration"
},
{
- "directory": "/data/assets",
- "from": "parent",
- "to": [ "#netstack" ],
- "dependency": "weak_for_migration"
- },
- {
"directory": "data",
"from": "parent",
"to": [ "#modular" ],
@@ -1570,26 +1425,12 @@
"dependency": "strong"
},
{
- "directory": "/data/assets",
- "from": "parent",
- "to": [ "#modular" ],
- "as": "/data",
- "subdir": "index/file",
- "dependency": "strong"
- },
- {
"directory": "hub",
"from": "framework",
"to": [ "#modular" ],
"as": "hub",
},
{
- "directory": "/hub",
- "from": "framework",
- "to": [ "#modular" ],
- "as": "/hub",
- },
- {
"storage": "data",
"from": "self",
"to": [
@@ -1658,7 +1499,7 @@
{ "service": "my.service.Service" },
{
"storage": "data",
- "backing_dir": "/minfs",
+ "backing_dir": "minfs",
"from": "#logger",
},
],
@@ -1738,21 +1579,6 @@
name: "logger".to_string(),
collection: None,
})),
- source_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()),
- target: Some(fsys::Ref::Child(fsys::ChildRef {
- name: "netstack".to_string(),
- collection: None,
- })),
- target_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()),
- dependency_type: Some(fsys::DependencyType::WeakForMigration),
- }
- ),
- fsys::OfferDecl::Protocol (
- fsys::OfferProtocolDecl {
- source: Some(fsys::Ref::Child(fsys::ChildRef {
- name: "logger".to_string(),
- collection: None,
- })),
source_path: Some("fuchsia.logger.LegacyLog".to_string()),
target: Some(fsys::Ref::Collection(fsys::CollectionRef {
name: "modular".to_string(),
@@ -1763,20 +1589,6 @@
),
fsys::OfferDecl::Protocol (
fsys::OfferProtocolDecl {
- source: Some(fsys::Ref::Child(fsys::ChildRef {
- name: "logger".to_string(),
- collection: None,
- })),
- source_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()),
- target: Some(fsys::Ref::Collection(fsys::CollectionRef {
- name: "modular".to_string(),
- })),
- target_path: Some("/svc/fuchsia.logger.LegacySysLog".to_string()),
- dependency_type: Some(fsys::DependencyType::Strong),
- }
- ),
- fsys::OfferDecl::Protocol (
- fsys::OfferProtocolDecl {
source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
source_path: Some("fuchsia.setui.SetUiService".to_string()),
target: Some(fsys::Ref::Collection(fsys::CollectionRef {
@@ -1797,28 +1609,6 @@
dependency_type: Some(fsys::DependencyType::Strong),
}
),
- fsys::OfferDecl::Protocol (
- fsys::OfferProtocolDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/svc/fuchsia.setui.SetUiService".to_string()),
- target: Some(fsys::Ref::Collection(fsys::CollectionRef {
- name: "modular".to_string(),
- })),
- target_path: Some("/svc/fuchsia.setui.SetUiService".to_string()),
- dependency_type: Some(fsys::DependencyType::Strong),
- }
- ),
- fsys::OfferDecl::Protocol (
- fsys::OfferProtocolDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/svc/fuchsia.wlan.service.Wlan".to_string()),
- target: Some(fsys::Ref::Collection(fsys::CollectionRef {
- name: "modular".to_string(),
- })),
- target_path: Some("/svc/fuchsia.wlan.service.Wlan".to_string()),
- dependency_type: Some(fsys::DependencyType::Strong),
- }
- ),
fsys::OfferDecl::Directory (
fsys::OfferDirectoryDecl {
source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
@@ -1836,20 +1626,6 @@
fsys::OfferDecl::Directory (
fsys::OfferDirectoryDecl {
source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/data/assets".to_string()),
- target: Some(fsys::Ref::Child(fsys::ChildRef {
- name: "netstack".to_string(),
- collection: None,
- })),
- target_path: Some("/data/assets".to_string()),
- rights: None,
- subdir: None,
- dependency_type: Some(fsys::DependencyType::WeakForMigration),
- }
- ),
- fsys::OfferDecl::Directory (
- fsys::OfferDirectoryDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
source_path: Some("data".to_string()),
target: Some(fsys::Ref::Collection(fsys::CollectionRef {
name: "modular".to_string(),
@@ -1862,19 +1638,6 @@
),
fsys::OfferDecl::Directory (
fsys::OfferDirectoryDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/data/assets".to_string()),
- target: Some(fsys::Ref::Collection(fsys::CollectionRef {
- name: "modular".to_string(),
- })),
- target_path: Some("/data".to_string()),
- rights: None,
- subdir: Some("index/file".to_string()),
- dependency_type: Some(fsys::DependencyType::Strong),
- }
- ),
- fsys::OfferDecl::Directory (
- fsys::OfferDirectoryDecl {
source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
source_path: Some("hub".to_string()),
target: Some(fsys::Ref::Collection(fsys::CollectionRef {
@@ -1886,19 +1649,6 @@
dependency_type: Some(fsys::DependencyType::Strong),
}
),
- fsys::OfferDecl::Directory (
- fsys::OfferDirectoryDecl {
- source: Some(fsys::Ref::Framework(fsys::FrameworkRef {})),
- source_path: Some("/hub".to_string()),
- target: Some(fsys::Ref::Collection(fsys::CollectionRef {
- name: "modular".to_string(),
- })),
- target_path: Some("/hub".to_string()),
- rights: None,
- subdir: None,
- dependency_type: Some(fsys::DependencyType::Strong),
- }
- ),
fsys::OfferDecl::Storage (
fsys::OfferStorageDecl {
source_name: Some("data".to_string()),
@@ -2020,7 +1770,7 @@
name: "logger".to_string(),
collection: None,
})),
- source_path: Some("/minfs".to_string()),
+ source_path: Some("minfs".to_string()),
subdir: None,
}
)
@@ -2188,7 +1938,7 @@
},
{
"storage": "mystorage2",
- "backing_dir": "/storage2",
+ "backing_dir": "storage2",
"from": "#minfs",
},
{
@@ -2271,7 +2021,7 @@
name: "minfs".to_string(),
collection: None,
})),
- source_path: Some("/storage2".to_string()),
+ source_path: Some("storage2".to_string()),
subdir: None,
}
),
@@ -2721,40 +2471,6 @@
}
#[test]
- fn test_compile_compact() {
- let input = json!({
- "use": [
- { "service": "CoolFonts", "path": "/svc/fuchsia.fonts.Provider" },
- { "protocol": "/fonts/LegacyCoolFonts", "as": "/svc/fuchsia.fonts.LegacyProvider" },
- { "directory": "/data/assets", "rights": ["read_bytes"] }
- ]
- });
- let output = fsys::ComponentDecl {
- uses: Some(vec![
- fsys::UseDecl::Service(fsys::UseServiceDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_name: Some("CoolFonts".to_string()),
- target_path: Some("/svc/fuchsia.fonts.Provider".to_string()),
- }),
- fsys::UseDecl::Protocol(fsys::UseProtocolDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/fonts/LegacyCoolFonts".to_string()),
- target_path: Some("/svc/fuchsia.fonts.LegacyProvider".to_string()),
- }),
- fsys::UseDecl::Directory(fsys::UseDirectoryDecl {
- source: Some(fsys::Ref::Parent(fsys::ParentRef {})),
- source_path: Some("/data/assets".to_string()),
- target_path: Some("/data/assets".to_string()),
- rights: Some(fio2::Operations::ReadBytes),
- subdir: None,
- }),
- ]),
- ..default_component_decl()
- };
- compile_test(input, output);
- }
-
- #[test]
fn test_invalid_json() {
let tmp_dir = TempDir::new().unwrap();
let tmp_in_path = tmp_dir.path().join("test.cml");
@@ -2762,7 +2478,7 @@
let input = json!({
"expose": [
- { "directory": "/volumes/blobfs", "from": "parent" }
+ { "directory": "blobfs", "from": "parent" }
]
});
File::create(&tmp_in_path).unwrap().write_all(format!("{}", input).as_bytes()).unwrap();
diff --git a/tools/cmc/src/validate.rs b/tools/cmc/src/validate.rs
index 775d60a..bc8db91 100644
--- a/tools/cmc/src/validate.rs
+++ b/tools/cmc/src/validate.rs
@@ -380,17 +380,11 @@
if use_.service.is_some() && use_.r#as.is_some() {
return Err(Error::validate("\"as\" field cannot be used with \"service\""));
}
- if let Some(protocol) = use_.protocol.as_ref() {
- for protocol in protocol.iter() {
- if protocol.is_name() && use_.r#as.is_some() {
- return Err(Error::validate("\"as\" field cannot be used with \"protocol\""));
- }
- }
+ if use_.protocol.is_some() && use_.r#as.is_some() {
+ return Err(Error::validate("\"as\" field cannot be used with \"protocol\""));
}
if use_.directory.is_some() && use_.r#as.is_some() {
- if use_.directory.as_ref().unwrap().is_name() {
- return Err(Error::validate("\"as\" field cannot be used with \"directory\""));
- }
+ return Err(Error::validate("\"as\" field cannot be used with \"directory\""));
}
if use_.runner.is_some() && use_.r#as.is_some() {
return Err(Error::validate("\"as\" field cannot be used with \"runner\""));
@@ -409,6 +403,9 @@
}
if let Some(event_stream) = use_.event_stream.as_ref() {
+ if use_.path.is_none() {
+ return Err(Error::validate("\"path\" should be present with \"event_stream\""));
+ }
let events = event_stream.to_vec();
for event in events {
if !self.all_event_names.contains(event) {
@@ -522,13 +519,11 @@
if let Some(protocol) = expose.protocol.as_ref() {
for protocol in protocol {
if expose.from.iter().any(|r| *r == cml::ExposeFromRef::Self_) {
- if let cml::NameOrPath::Name(protocol) = protocol {
- if !self.all_protocols.contains(protocol) {
- return Err(Error::validate(format!(
+ if !self.all_protocols.contains(protocol) {
+ return Err(Error::validate(format!(
"Protocol \"{}\" is exposed from self, so it must be declared as a \"protocol\" in \"capabilities\"",
protocol
)));
- }
}
}
}
@@ -537,32 +532,23 @@
// Ensure that directories exposed from self are defined in `capabilities`.
if let Some(directory) = &expose.directory {
if expose.from.iter().any(|r| *r == cml::ExposeFromRef::Self_) {
- if let cml::NameOrPath::Name(directory) = directory {
- if !self.all_directories.contains(directory) {
- return Err(Error::validate(format!(
+ if !self.all_directories.contains(directory) {
+ return Err(Error::validate(format!(
"Directory \"{}\" is exposed from self, so it must be declared as a \"directory\" in \"capabilities\"",
directory
)));
- }
}
}
}
- // Ensure directory rights are specified if exposing from self.
- if let Some(directory) = expose.directory.as_ref() {
+ // Ensure directory rights are valid.
+ if let Some(_) = expose.directory.as_ref() {
if expose.from.iter().any(|r| *r == cml::ExposeFromRef::Self_)
|| expose.rights.is_some()
{
- match &expose.rights {
- Some(rights) => self.validate_directory_rights(&rights)?,
- None => {
- if directory.is_path() {
- return Err(Error::validate(
- "Rights required for this expose statement as it is exposing from self.",
- ));
- }
- }
- };
+ if let Some(rights) = expose.rights.as_ref() {
+ self.validate_directory_rights(&rights)?;
+ }
}
// Exposing a subdirectory makes sense for routing but when exposing to framework,
@@ -644,13 +630,11 @@
if let Some(protocol) = offer.protocol.as_ref() {
for protocol in protocol.iter() {
if offer.from.iter().any(|r| *r == cml::OfferFromRef::Self_) {
- if let cml::NameOrPath::Name(protocol) = protocol {
- if !self.all_protocols.contains(protocol) {
- return Err(Error::validate(format!(
+ if !self.all_protocols.contains(protocol) {
+ return Err(Error::validate(format!(
"Protocol \"{}\" is offered from self, so it must be declared as a \"protocol\" in \"capabilities\"",
protocol
)));
- }
}
}
}
@@ -659,30 +643,21 @@
// Ensure that directories offered from self are defined in `capabilities`.
if let Some(directory) = &offer.directory {
if offer.from.iter().any(|r| *r == cml::OfferFromRef::Self_) {
- if let cml::NameOrPath::Name(directory) = directory {
- if !self.all_directories.contains(directory) {
- return Err(Error::validate(format!(
+ if !self.all_directories.contains(directory) {
+ return Err(Error::validate(format!(
"Directory \"{}\" is offered from self, so it must be declared as a \"directory\" in \"capabilities\"",
directory
)));
- }
}
}
}
- // Ensure directory rights are specified if offering from self.
- if let Some(directory) = offer.directory.as_ref() {
+ // Ensure directory rights are valid.
+ if let Some(_) = offer.directory.as_ref() {
if offer.from.iter().any(|r| *r == cml::OfferFromRef::Self_) || offer.rights.is_some() {
- match &offer.rights {
- Some(rights) => self.validate_directory_rights(&rights)?,
- None => {
- if directory.is_path() {
- return Err(Error::validate(
- "Rights required for this offer as it is offering from self.",
- ));
- }
- }
- };
+ if let Some(rights) = offer.rights.as_ref() {
+ self.validate_directory_rights(&rights)?;
+ }
}
}
@@ -1148,11 +1123,11 @@
"expose": [
// Here are some services to expose.
{ "service": "fuchsia.logger.Log", "from": "#logger", },
- { "directory": "/volumes/blobfs", "from": "self", "rights": ["rw*"]},
+ { "directory": "blobfs", "from": "#logger", "rights": ["rw*"]},
],
"children": [
{
- 'name': 'logger',
+ name: 'logger',
'url': 'fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm',
},
],
@@ -1166,7 +1141,7 @@
let input = r##"{
"use": [
{
- "protocol": "/svc/fuchsia.logger.Log",
+ "protocol": "fuchsia.logger.Log",
"from": "self",
},
],
@@ -1217,11 +1192,8 @@
{ "service": "CoolFonts", "path": "/svc/fuchsia.fonts.Provider" },
{ "service": "fuchsia.sys2.Realm", "from": "framework" },
{ "protocol": "CoolFonts", "path": "/svc/MyFonts" },
- { "protocol": "/fonts/CoolFonts", "as": "/svc/MyFonts2" },
{ "protocol": "fuchsia.test.hub.HubReport", "from": "framework" },
- { "protocol": "/svc/fuchsia.test.hub.HubReport2", "from": "framework" },
{ "protocol": ["fuchsia.ui.scenic.Scenic", "fuchsia.logger.LogSink"] },
- { "protocol": ["/svc/fuchsia.ui.scenic.Scenic2", "/svc/fuchsia.logger.LogSink2"] },
{
"directory": "assets",
"path": "/data/assets",
@@ -1234,16 +1206,6 @@
"rights": ["rx*"],
"subdir": "fonts/all",
},
- {
- "directory": "/data/assets2",
- "rights": ["rw*"],
- },
- {
- "directory": "/data/config2",
- "from": "parent",
- "rights": ["rx*"],
- "subdir": "fonts/all",
- },
{ "storage": "data", "path": "/example" },
{ "storage": "cache", "path": "/tmp" },
{ "storage": "meta" },
@@ -1262,11 +1224,8 @@
}
},
{
- "event_stream": [ "started", "stopped", "launched" ]
- },
- {
"event_stream": [ "started", "stopped", "launched" ],
- "as": "/svc/my_stream"
+ "path": "/svc/my_stream"
},
]
}),
@@ -1282,7 +1241,7 @@
),
test_cml_use_missing_props(
json!({
- "use": [ { "as": "/svc/fuchsia.logger.Log" } ]
+ "use": [ { "path": "/svc/fuchsia.logger.Log" } ]
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "`use` declaration is missing a capability keyword, one of: \"service\", \"protocol\", \"directory\", \"storage\", \"runner\", \"event\", \"event_stream\""
),
@@ -1325,23 +1284,23 @@
test_cml_use_invalid_from(
json!({
"use": [
- { "service": "/fonts/CoolFonts", "from": "self" }
+ { "service": "CoolFonts", "from": "self" }
]
}),
Err(Error::Parse { err, .. }) if &err == "invalid value: string \"self\", expected \"parent\", \"framework\", or none"
),
- test_cml_use_bad_as(
+ test_cml_use_bad_path(
json!({
"use": [
{
- "protocol": ["/fonts/CoolFonts", "/fonts/FunkyFonts"],
- "as": "/fonts/MyFonts"
+ "protocol": ["CoolFonts", "FunkyFonts"],
+ "path": "/MyFonts"
}
]
}),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"as\" field can only be specified when one `protocol` is supplied."
+ Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"path\" field can only be specified when one `protocol` is supplied."
),
- test_cml_use_bad_duplicate_target_paths(
+ test_cml_use_bad_duplicate_target_names(
json!({
"use": [
{ "protocol": "fuchsia.sys2.Realm" },
@@ -1358,13 +1317,14 @@
},
],
}),
- Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or path or nonempty array of names or paths, with unique elements"
+ Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or nonempty array of names, with unique elements"
),
test_cml_use_bad_subdir(
json!({
"use": [
{
- "directory": "/data/config",
+ "directory": "config",
+ "path": "/config",
"from": "parent",
"rights": [ "r*" ],
"subdir": "/",
@@ -1387,8 +1347,8 @@
test_cml_use_disallows_nested_dirs(
json!({
"use": [
- { "directory": "/foo/bar", "rights": [ "r*" ] },
- { "directory": "/foo/bar/baz", "rights": [ "r*" ] },
+ { "directory": "foobar", "path": "/foo/bar", "rights": [ "r*" ] },
+ { "directory": "foobarbaz", "path": "/foo/bar/baz", "rights": [ "r*" ] },
],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "directory \"/foo/bar/baz\" is a prefix of \"use\" target directory \"/foo/bar\""
@@ -1406,7 +1366,7 @@
json!({
"use": [
{ "directory": "foobar", "path": "/foo/bar", "rights": [ "r*" ] },
- { "protocol": "/foo/bar/fuchsia.2" },
+ { "protocol": "fuchsia", "path": "/foo/bar/fuchsia.2" },
],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "protocol \"/foo/bar/fuchsia.2\" is a prefix of \"use\" target directory \"/foo/bar\""
@@ -1414,7 +1374,7 @@
test_cml_use_disallows_filter_on_non_events(
json!({
"use": [
- { "directory": "/foo/bar", "rights": [ "r*" ], "filter": {"path": "/diagnostics"} },
+ { "directory": "foobar", "path": "/foo/bar", "rights": [ "r*" ], "filter": {"path": "/diagnostics"} },
],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"filter\" can only be used with \"event\""
@@ -1451,11 +1411,26 @@
"use": [
{
"event_stream": ["destroyed"],
+ "path": "/svc/stream",
},
]
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "Event \"destroyed\" in event stream not found in any \"use\" declaration."
),
+ test_cml_use_event_stream_missing_path(
+ json!({
+ "use": [
+ {
+ "event": [ "destroyed" ],
+ "from": "parent",
+ },
+ {
+ "event_stream": [ "destroyed" ],
+ },
+ ]
+ }),
+ Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"path\" should be present with \"event_stream\""
+ ),
test_cml_use_bad_filter_in_event(
json!({
"use": [
@@ -1500,26 +1475,27 @@
"from": "self",
},
{
- "protocol": "/svc/A",
+ "protocol": ["B", "C"],
"from": "self",
},
{
- "protocol": ["/svc/B", "/svc/C"],
- "from": "self",
- },
- {
- "directory": "/volumes/blobfs",
+ "directory": "blobfs",
"from": "self",
"rights": ["r*"],
"subdir": "blob",
},
- { "directory": "/hub", "from": "framework" },
+ { "directory": "hub", "from": "framework" },
{ "runner": "elf", "from": "#logger", },
{ "resolver": "pkg_resolver", "from": "#logger" },
],
"capabilities": [
{ "service": "fuchsia.fonts.Provider" },
- { "protocol": "A" },
+ { "protocol": ["A", "B", "C"] },
+ {
+ "directory": "blobfs",
+ "path": "/blobfs",
+ "rights": ["rw*"],
+ },
],
"children": [
{
@@ -1583,43 +1559,33 @@
),
test_cml_expose_duplicate_target_names(
json!({
- "expose": [
- { "service": "logger", "from": "#logger", "as": "thing" },
- { "protocol": "thing", "from": "self" },
- ],
"capabilities": [
- { "protocol": "thing" },
+ { "protocol": "logger" },
+ ],
+ "expose": [
+ { "protocol": "logger", "from": "self", "as": "thing" },
+ { "directory": "thing", "from": "#child" , "rights": ["rx*"] },
],
"children": [
{
- "name": "logger",
- "url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
+ "name": "child",
+ "url": "fuchsia-pkg://",
},
],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"thing\" is a duplicate \"expose\" target capability for \"parent\""
),
- test_cml_expose_duplicate_target_paths(
- json!({
- "expose": [
- { "protocol": "/svc/logger", "from": "#logger", "as": "/thing" },
- { "directory": "/thing", "from": "self" , "rights": ["rx*"] },
- ],
- "children": [
- {
- "name": "logger",
- "url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
- },
- ],
- }),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"/thing\" is a duplicate \"expose\" target capability for \"parent\""
- ),
test_cml_expose_invalid_multiple_from(
json!({
- "expose": [ {
- "protocol": "/svc/fuchsia.logger.Log",
- "from": [ "self", "#logger" ],
- } ],
+ "capabilities": [
+ { "protocol": "fuchsia.logger.Log" },
+ ],
+ "expose": [
+ {
+ "protocol": "fuchsia.logger.Log",
+ "from": [ "self", "#logger" ],
+ },
+ ],
"children": [
{
"name": "logger",
@@ -1632,7 +1598,7 @@
test_cml_expose_bad_from(
json!({
"expose": [ {
- "service": "/loggers/fuchsia.logger.Log", "from": "parent"
+ "service": "fuchsia.logger.Log", "from": "parent"
} ]
}),
Err(Error::Parse { err, .. }) if &err == "invalid value: string \"parent\", expected one or an array of \"framework\", \"self\", or \"#<child-name>\""
@@ -1642,9 +1608,9 @@
json!({
"expose": [
{
- "protocol": ["/svc/A", "/svc/B"],
- "from": "self",
- "as": "/thing"
+ "protocol": ["A", "B"],
+ "from": "#echo_server",
+ "as": "thing"
},
],
"children": [
@@ -1661,18 +1627,24 @@
"expose": [
{
"protocol": [],
- "from": "self",
- "as": "/thing"
- }
+ "from": "#child",
+ "as": "thing"
+ },
+ ],
+ "children": [
+ {
+ "name": "child",
+ "url": "fuchsia-pkg://",
+ },
],
}),
- Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or path or nonempty array of names or paths, with unique elements"
+ Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or nonempty array of names, with unique elements"
),
test_cml_expose_bad_subdir(
json!({
"expose": [
{
- "directory": "/volumes/blobfs",
+ "directory": "blobfs",
"from": "self",
"rights": ["r*"],
"subdir": "/",
@@ -1683,15 +1655,27 @@
),
test_cml_expose_invalid_subdir_to_framework(
json!({
+ "capabilities": [
+ {
+ "directory": "foo",
+ "rights": ["r*"],
+ "path": "/foo",
+ },
+ ],
"expose": [
{
- "directory": "/volumes/blobfs",
+ "directory": "foo",
"from": "self",
"to": "framework",
- "rights": ["r*"],
"subdir": "blob",
},
- ]
+ ],
+ "children": [
+ {
+ "name": "child",
+ "url": "fuchsia-pkg://",
+ },
+ ],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "`subdir` is not supported for expose to framework. Directly expose the subdirectory instead."
),
@@ -1822,14 +1806,26 @@
),
test_cml_expose_to_framework_ok(
json!({
+ "capabilities": [
+ {
+ "directory": "foo",
+ "path": "/foo",
+ "rights": ["r*"],
+ },
+ ],
"expose": [
{
- "directory": "/foo",
+ "directory": "foo",
"from": "self",
- "rights": ["r*"],
"to": "framework"
}
- ]
+ ],
+ "children": [
+ {
+ "name": "child",
+ "url": "fuchsia-pkg://",
+ },
+ ],
}),
Ok(())
),
@@ -1837,7 +1833,7 @@
json!({
"expose": [
{
- "directory": "/foo",
+ "directory": "foo",
"from": "#logger",
"to": "framework"
}
@@ -1879,12 +1875,6 @@
"dependency": "weak_for_migration"
},
{
- "protocol": "/svc/fuchsia.fonts.LegacyProvider",
- "from": "parent",
- "to": [ "#echo_server" ],
- "dependency": "weak_for_migration"
- },
- {
"protocol": [
"fuchsia.settings.Accessibility",
"fuchsia.ui.scenic.Scenic"
@@ -1894,27 +1884,12 @@
"dependency": "strong"
},
{
- "protocol": [
- "/svc/fuchsia.settings.Accessibility",
- "/svc/fuchsia.ui.scenic.Scenic"
- ],
- "from": "parent",
- "to": [ "#echo_server" ],
- "dependency": "strong"
- },
- {
"directory": "assets",
"from": "self",
"to": [ "#echo_server" ],
"rights": ["r*"]
},
{
- "directory": "/data/assets",
- "from": "self",
- "to": [ "#echo_server" ],
- "rights": ["rw*"]
- },
- {
"directory": "index",
"subdir": "files",
"from": "parent",
@@ -1922,17 +1897,10 @@
"dependency": "weak_for_migration"
},
{
- "directory": "/data/index",
- "subdir": "files",
- "from": "parent",
- "to": [ "#modular" ],
- "dependency": "weak_for_migration"
- },
- {
- "directory": "/hub",
+ "directory": "hub",
"from": "framework",
"to": [ "#modular" ],
- "as": "/hub",
+ "as": "hub",
"dependency": "strong"
},
{
@@ -1986,7 +1954,7 @@
{
"storage": "data",
"from": "parent",
- "backing_dir": "/minfs",
+ "backing_dir": "minfs",
},
],
}),
@@ -2037,7 +2005,7 @@
{
"storage": "abcdefghijklmnopqrstuvwxyz0123456789_-storage",
"from": "#abcdefghijklmnopqrstuvwxyz0123456789_-from",
- "backing_dir": "/example"
+ "backing_dir": "example"
}
]
}),
@@ -2101,11 +2069,13 @@
),
test_cml_offer_invalid_multiple_from(
json!({
- "offer": [ {
- "protocol": "/svc/fuchsia.logger.Log",
- "from": [ "self", "#logger" ],
- "to": [ "#echo_server" ],
- } ],
+ "offer": [
+ {
+ "protocol": "fuchsia.logger.Log",
+ "from": [ "parent", "#logger" ],
+ "to": [ "#echo_server" ],
+ },
+ ],
"children": [
{
"name": "logger",
@@ -2121,11 +2091,19 @@
),
test_cml_offer_empty_targets(
json!({
- "offer": [ {
- "service": "fuchsia.logger.Log",
- "from": "#logger",
- "to": []
- } ]
+ "offer": [
+ {
+ "service": "fuchsia.logger.Log",
+ "from": "#child",
+ "to": []
+ },
+ ],
+ "children": [
+ {
+ "name": "child",
+ "url": "fuchsia-pkg://",
+ },
+ ],
}),
Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a nonempty array of offer targets, with unique elements"
),
@@ -2179,13 +2157,13 @@
"offer": [
{
"protocol": [],
- "from": "self",
+ "from": "parent",
"to": [ "#echo_server" ],
- "as": "/thing"
+ "as": "thing"
},
],
}),
- Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or path or nonempty array of names or paths, with unique elements"
+ Err(Error::Parse { err, .. }) if &err == "invalid length 0, expected a name or nonempty array of names, with unique elements"
),
test_cml_offer_target_equals_from(
json!({
@@ -2215,7 +2193,7 @@
"capabilities": [ {
"storage": "minfs",
"from": "#logger",
- "backing_dir": "/minfs",
+ "backing_dir": "minfs-dir",
} ],
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "Storage offer target \"#logger\" is same as source"
@@ -2224,55 +2202,20 @@
json!({
"offer": [
{
- "service": "logger",
- "from": "#logger",
+ "protocol": "logger",
+ "from": "parent",
"to": [ "#echo_server" ],
"as": "thing"
},
{
- "directory": "thing",
- "from": "self",
- "to": [ "#echo_server" ],
- },
- ],
- "capabilities": [
- {
- "directory": "thing",
- "path": "/thing",
- "rights": [ "r*" ],
- },
- ],
- "children": [
- {
- "name": "logger",
- "url": "fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm",
- },
- {
- "name": "echo_server",
- "url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm",
- },
- ],
- }),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"thing\" is a duplicate \"offer\" target capability for \"#echo_server\""
- ),
- test_cml_offer_duplicate_target_paths(
- json!({
- "offer": [
- {
- "protocol": "/svc/logger",
- "from": "self",
- "to": [ "#echo_server" ],
- "as": "/thing"
- },
- {
- "protocol": "/svc/logger",
- "from": "self",
+ "protocol": "logger",
+ "from": "parent",
"to": [ "#scenic" ],
},
{
- "directory": "/thing",
+ "directory": "thing",
"from": "parent",
- "to": [ "#echo_server" ]
+ "to": [ "#echo_server" ],
}
],
"children": [
@@ -2286,7 +2229,7 @@
},
],
}),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"/thing\" is a duplicate \"offer\" target capability for \"#echo_server\""
+ Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"thing\" is a duplicate \"offer\" target capability for \"#echo_server\""
),
test_cml_offer_duplicate_storage_names(
json!({
@@ -2305,7 +2248,7 @@
"capabilities": [ {
"storage": "cache",
"from": "self",
- "backing_dir": "/minfs"
+ "backing_dir": "minfs"
} ],
"children": [ {
"name": "echo_server",
@@ -2319,10 +2262,10 @@
json!({
"offer": [
{
- "protocol": ["/svc/A", "/svc/B"],
- "from": "self",
+ "protocol": ["A", "B"],
+ "from": "parent",
"to": [ "#echo_server" ],
- "as": "/thing"
+ "as": "thing"
},
],
"children": [
@@ -2338,7 +2281,7 @@
json!({
"offer": [
{
- "directory": "/data/index",
+ "directory": "index",
"subdir": "/",
"from": "parent",
"to": [ "#modular" ],
@@ -2569,13 +2512,13 @@
json!({
"offer": [
{
- "protocol": "/svc/fuchsia.logger.Log",
+ "protocol": "fuchsia.logger.Log",
"from": "#a",
"to": [ "#b" ],
"dependency": "strong"
},
{
- "directory": "/data",
+ "directory": "data",
"from": "#b",
"to": [ "#c" ],
},
@@ -2627,13 +2570,13 @@
json!({
"offer": [
{
- "protocol": "/svc/fuchsia.logger.Log",
+ "protocol": "fuchsia.logger.Log",
"from": "#child_a",
"to": [ "#child_b" ],
"dependency": "weak_for_migration"
},
{
- "directory": "/data",
+ "directory": "data",
"from": "#child_b",
"to": [ "#child_a" ],
},
@@ -2655,9 +2598,9 @@
json!({
"offer": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
"rights": [ "r*" ],
- "from": "self",
+ "from": "parent",
"to": [ "#logger" ],
"filter": {"path": "/diagnostics"}
},
@@ -3019,17 +2962,17 @@
{
"storage": "a",
"from": "#minfs",
- "backing_dir": "/minfs",
+ "backing_dir": "minfs",
},
{
"storage": "b",
"from": "parent",
- "backing_dir": "/data",
+ "backing_dir": "data",
},
{
"storage": "c",
"from": "self",
- "backing_dir": "/storage",
+ "backing_dir": "storage",
},
],
"children": [
@@ -3047,7 +2990,7 @@
{
"storage": "abcdefghijklmnopqrstuvwxyz0123456789_-storage",
"from": "#abcdefghijklmnopqrstuvwxyz0123456789_-from",
- "backing_dir": "/example",
+ "backing_dir": "example",
},
],
"children": [
@@ -3064,7 +3007,7 @@
"capabilities": [ {
"storage": "minfs",
"from": "#missing",
- "backing_dir": "/minfs"
+ "backing_dir": "minfs"
} ]
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "\"capabilities\" source \"#missing\" does not appear in \"children\""
@@ -3524,7 +3467,7 @@
],
"offer": [
{
- "protocol": "/svc/fuchsia.logger.Log",
+ "protocol": "fuchsia.logger.Log",
"from": "#a",
"to": [ "#b" ],
"dependency": "strong"
@@ -3562,7 +3505,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": ["connect", "enumerate", "read_bytes", "write_bytes",
"execute", "update_attributes", "get_attributes", "traverse",
"modify_directory", "admin"],
@@ -3575,7 +3519,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": ["cAnnect", "enumerate"],
},
]
@@ -3586,7 +3531,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": ["connect", "connect"],
},
]
@@ -3597,7 +3543,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": [],
},
]
@@ -3608,8 +3555,9 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
"rights": ["r*"],
+ "path": "/mydir",
},
]
}),
@@ -3619,8 +3567,9 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
"rights": ["w*", "read_bytes"],
+ "path": "/mydir",
},
]
}),
@@ -3630,7 +3579,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": ["r*", "read_bytes"],
},
]
@@ -3641,7 +3591,8 @@
json!({
"use": [
{
- "directory": "/foo/bar",
+ "directory": "mydir",
+ "path": "/mydir",
"rights": ["w*", "x*"],
},
]
@@ -3651,40 +3602,11 @@
test_cml_rights_use_invalid(
json!({
"use": [
- { "directory": "/foo", },
+ { "directory": "mydir", "path": "/mydir" },
]
}),
Err(Error::Validate { schema_name: None, err, .. }) if &err == "Rights required for this use statement."
),
- test_cml_rights_offer_dir_invalid(
- json!({
- "offer": [
- {
- "directory": "/foo",
- "from": "self",
- "to": [ "#echo_server" ],
- },
- ],
- "children": [
- {
- "name": "echo_server",
- "url": "fuchsia-pkg://fuchsia.com/echo/stable#meta/echo_server.cm"
- }
- ],
- }),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "Rights required for this offer as it is offering from self."
- ),
- test_cml_rights_expose_dir_invalid(
- json!({
- "expose": [
- {
- "directory": "/foo/bar",
- "from": "self",
- },
- ]
- }),
- Err(Error::Validate { schema_name: None, err, .. }) if &err == "Rights required for this expose statement as it is exposing from self."
- ),
test_cml_path(
json!({
"capabilities": [
diff --git a/tools/cmc/tests/integration_test.rs b/tools/cmc/tests/integration_test.rs
index d27ab9b..336547c 100644
--- a/tools/cmc/tests/integration_test.rs
+++ b/tools/cmc/tests/integration_test.rs
@@ -151,7 +151,7 @@
CapabilityDecl::Storage(StorageDecl {
name: Some("minfs".to_string()),
source: Some(Ref::Parent(ParentRef {})),
- source_path: Some("/data".to_string()),
+ source_path: Some("data".to_string()),
subdir: None,
}),
CapabilityDecl::Runner(RunnerDecl {
diff --git a/tools/lib/cml/src/lib.rs b/tools/lib/cml/src/lib.rs
index 95a63f6..414c51f 100644
--- a/tools/lib/cml/src/lib.rs
+++ b/tools/lib/cml/src/lib.rs
@@ -40,8 +40,8 @@
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum CapabilityId {
Service(Name),
- Protocol(NameOrPath),
- Directory(NameOrPath),
+ Protocol(Name),
+ Directory(Name),
// A service in a `use` declaration has a target path in the component's namespace.
UsedService(Path),
// A protocol in a `use` declaration has a target path in the component's namespace.
@@ -114,41 +114,32 @@
};
Ok(vec![CapabilityId::UsedService(path)])
}
- _ => Ok(vec![CapabilityId::Service(alias_or_name(alias, n)?)]),
+ _ => Ok(vec![CapabilityId::Service(alias_or_name(alias, n))]),
};
} else if let Some(OneOrMany::One(protocol)) = clause.protocol() {
return match (clause_type, protocol) {
(RoutingClauseType::Capability, protocol) => {
Ok(vec![CapabilityId::Protocol(protocol)])
}
- (RoutingClauseType::Use, NameOrPath::Path(protocol)) => {
- Ok(vec![CapabilityId::UsedProtocol(alias_or_path(alias, &protocol)?)])
- }
- (RoutingClauseType::Use, NameOrPath::Name(protocol)) => {
+ (RoutingClauseType::Use, protocol) => {
let path = match path {
Some(path) => path.clone(),
None => format!("/svc/{}", protocol).parse().unwrap(),
};
Ok(vec![CapabilityId::UsedProtocol(path)])
}
- (_, protocol) => {
- Ok(vec![CapabilityId::Protocol(alias_or_name_or_path(alias, &protocol))])
- }
+ (_, protocol) => Ok(vec![CapabilityId::Protocol(alias_or_name(alias, &protocol))]),
};
} else if let Some(OneOrMany::Many(protocols)) = clause.protocol() {
return match clause_type {
- RoutingClauseType::Use if protocols.len() == 1 => match &protocols[0] {
- NameOrPath::Path(protocol) => {
- Ok(vec![CapabilityId::UsedProtocol(alias_or_path(alias, protocol)?)])
- }
- NameOrPath::Name(protocol) => {
- let path = match path {
- Some(path) => path.clone(),
- None => format!("/svc/{}", protocol).parse().unwrap(),
- };
- Ok(vec![CapabilityId::UsedProtocol(path)])
- }
- },
+ RoutingClauseType::Use if protocols.len() == 1 => {
+ let protocol = &protocols[0];
+ let path = match path {
+ Some(path) => path.clone(),
+ None => format!("/svc/{}", protocol).parse().unwrap(),
+ };
+ Ok(vec![CapabilityId::UsedProtocol(path)])
+ }
RoutingClauseType::Use => {
if alias.is_some() {
return Err(Error::validate(
@@ -162,14 +153,9 @@
}
Ok(protocols
.iter()
- .map(|protocol: &NameOrPath| match protocol {
- NameOrPath::Path(protocol) => {
- CapabilityId::UsedProtocol(protocol.clone())
- }
- NameOrPath::Name(protocol) => {
- let protocol: Path = format!("/svc/{}", protocol).parse().unwrap();
- CapabilityId::UsedProtocol(protocol)
- }
+ .map(|protocol: &Name| {
+ let protocol: Path = format!("/svc/{}", protocol).parse().unwrap();
+ CapabilityId::UsedProtocol(protocol)
})
.collect())
}
@@ -184,11 +170,11 @@
}
Ok(protocols
.iter()
- .map(|protocol: &NameOrPath| CapabilityId::Protocol(protocol.clone()))
+ .map(|protocol: &Name| CapabilityId::Protocol(protocol.clone()))
.collect())
}
_ if protocols.len() == 1 => {
- Ok(vec![CapabilityId::Protocol(alias_or_name_or_path(alias, &protocols[0]))])
+ Ok(vec![CapabilityId::Protocol(alias_or_name(alias, &protocols[0]))])
}
_ => {
if alias.is_some() {
@@ -198,7 +184,7 @@
}
Ok(protocols
.iter()
- .map(|protocol: &NameOrPath| CapabilityId::Protocol(protocol.clone()))
+ .map(|protocol: &Name| CapabilityId::Protocol(protocol.clone()))
.collect())
}
};
@@ -207,10 +193,7 @@
(RoutingClauseType::Capability, directory) => {
Ok(vec![CapabilityId::Directory(directory)])
}
- (RoutingClauseType::Use, NameOrPath::Path(directory)) => {
- Ok(vec![CapabilityId::UsedDirectory(alias_or_path(alias, &directory)?)])
- }
- (RoutingClauseType::Use, NameOrPath::Name(_)) => {
+ (RoutingClauseType::Use, _) => {
if path.is_none() {
return Err(Error::validate(
"\"path\" field should be present for `use directory`.",
@@ -219,22 +202,20 @@
Ok(vec![CapabilityId::UsedDirectory(path.unwrap().clone())])
}
(_, directory) => {
- Ok(vec![CapabilityId::Directory(alias_or_name_or_path(alias, &directory))])
+ Ok(vec![CapabilityId::Directory(alias_or_name(alias, &directory))])
}
};
} else if let Some(n) = clause.storage().as_ref() {
- return Ok(vec![CapabilityId::Storage(alias_or_name(alias, n)?)]);
+ return Ok(vec![CapabilityId::Storage(alias_or_name(alias, n))]);
} else if let Some(n) = clause.runner().as_ref() {
- return Ok(vec![CapabilityId::Runner(alias_or_name(alias, n)?)]);
+ return Ok(vec![CapabilityId::Runner(alias_or_name(alias, n))]);
} else if let Some(n) = clause.resolver().as_ref() {
- return Ok(vec![CapabilityId::Resolver(alias_or_name(alias, n)?)]);
+ return Ok(vec![CapabilityId::Resolver(alias_or_name(alias, n))]);
} else if let Some(OneOrMany::One(n)) = clause.event().as_ref() {
- return Ok(vec![CapabilityId::Event(alias_or_name(alias, n)?)]);
+ return Ok(vec![CapabilityId::Event(alias_or_name(alias, n))]);
} else if let Some(OneOrMany::Many(events)) = clause.event().as_ref() {
return match (alias, clause.filter(), events.len()) {
- (Some(valid_alias), _, 1) => {
- Ok(vec![CapabilityId::Event(valid_alias.extract_name_borrowed()?.clone())])
- }
+ (Some(alias), _, 1) => Ok(vec![CapabilityId::Event(alias.clone())]),
(None, Some(_), 1) => Ok(vec![CapabilityId::Event(events[0].clone())]),
(Some(_), None, _) => Err(Error::validate(
"\"as\" field can only be specified when one `event` is supplied",
@@ -252,9 +233,9 @@
};
} else if let Some(_) = clause.event_stream().as_ref() {
return Ok(vec![CapabilityId::EventStream(alias_or_path(
- alias,
+ path,
&DEFAULT_EVENT_STREAM_PATH,
- )?)]);
+ ))]);
}
// Unknown capability type.
@@ -656,7 +637,7 @@
let alias = use_.r#as();
let events: Vec<_> = event.to_vec();
if events.len() == 1 {
- let event_name = alias_or_name(alias, &events[0])?.clone();
+ let event_name = alias_or_name(alias, &events[0]).clone();
all_events.push(event_name);
} else {
let mut events = events.into_iter().cloned().collect();
@@ -806,7 +787,7 @@
pub from: Option<CapabilityFromRef>,
pub path: Option<Path>,
pub rights: Option<Rights>,
- pub backing_dir: Option<NameOrPath>,
+ pub backing_dir: Option<Name>,
pub subdir: Option<RelativePath>,
}
@@ -814,13 +795,13 @@
#[serde(deny_unknown_fields)]
pub struct Use {
pub service: Option<Name>,
- pub protocol: Option<OneOrMany<NameOrPath>>,
- pub directory: Option<NameOrPath>,
+ pub protocol: Option<OneOrMany<Name>>,
+ pub directory: Option<Name>,
pub storage: Option<Name>,
pub runner: Option<Name>,
pub from: Option<UseFromRef>,
pub path: Option<Path>,
- pub r#as: Option<NameOrPath>,
+ pub r#as: Option<Name>,
pub rights: Option<Rights>,
pub subdir: Option<RelativePath>,
pub event: Option<OneOrMany<Name>>,
@@ -832,12 +813,12 @@
#[serde(deny_unknown_fields)]
pub struct Expose {
pub service: Option<Name>,
- pub protocol: Option<OneOrMany<NameOrPath>>,
- pub directory: Option<NameOrPath>,
+ pub protocol: Option<OneOrMany<Name>>,
+ pub directory: Option<Name>,
pub runner: Option<Name>,
pub resolver: Option<Name>,
pub from: OneOrMany<ExposeFromRef>,
- pub r#as: Option<NameOrPath>,
+ pub r#as: Option<Name>,
pub to: Option<ExposeToRef>,
pub rights: Option<Rights>,
pub subdir: Option<RelativePath>,
@@ -847,15 +828,15 @@
#[serde(deny_unknown_fields)]
pub struct Offer {
pub service: Option<Name>,
- pub protocol: Option<OneOrMany<NameOrPath>>,
- pub directory: Option<NameOrPath>,
+ pub protocol: Option<OneOrMany<Name>>,
+ pub directory: Option<Name>,
pub storage: Option<Name>,
pub runner: Option<Name>,
pub resolver: Option<Name>,
pub event: Option<OneOrMany<Name>>,
pub from: OneOrMany<OfferFromRef>,
pub to: OfferTo,
- pub r#as: Option<NameOrPath>,
+ pub r#as: Option<Name>,
pub rights: Option<Rights>,
pub subdir: Option<RelativePath>,
pub dependency: Option<DependencyType>,
@@ -898,8 +879,8 @@
pub trait CapabilityClause {
fn service(&self) -> &Option<Name>;
- fn protocol(&self) -> Option<OneOrMany<NameOrPath>>;
- fn directory(&self) -> Option<NameOrPath>;
+ fn protocol(&self) -> Option<OneOrMany<Name>>;
+ fn directory(&self) -> Option<Name>;
fn storage(&self) -> &Option<Name>;
fn runner(&self) -> &Option<Name>;
fn resolver(&self) -> &Option<Name>;
@@ -917,7 +898,7 @@
}
pub trait AsClause {
- fn r#as(&self) -> Option<&NameOrPath>;
+ fn r#as(&self) -> Option<&Name>;
}
pub trait PathClause {
@@ -936,16 +917,14 @@
fn service(&self) -> &Option<Name> {
&self.service
}
- fn protocol(&self) -> Option<OneOrMany<NameOrPath>> {
+ fn protocol(&self) -> Option<OneOrMany<Name>> {
self.protocol.as_ref().map(|o| match o {
- OneOrMany::One(n) => OneOrMany::One(NameOrPath::Name(n.clone())),
- OneOrMany::Many(v) => {
- OneOrMany::Many(v.iter().map(|n| NameOrPath::Name(n.clone())).collect())
- }
+ OneOrMany::One(n) => OneOrMany::One(n.clone()),
+ OneOrMany::Many(v) => OneOrMany::Many(v.iter().map(|n| n.clone()).collect()),
})
}
- fn directory(&self) -> Option<NameOrPath> {
- self.directory.as_ref().map(|n| NameOrPath::Name(n.clone()))
+ fn directory(&self) -> Option<Name> {
+ self.directory.as_ref().map(|n| n.clone())
}
fn storage(&self) -> &Option<Name> {
&self.storage
@@ -988,7 +967,7 @@
}
impl AsClause for Capability {
- fn r#as(&self) -> Option<&NameOrPath> {
+ fn r#as(&self) -> Option<&Name> {
None
}
}
@@ -1015,10 +994,10 @@
fn service(&self) -> &Option<Name> {
&self.service
}
- fn protocol(&self) -> Option<OneOrMany<NameOrPath>> {
+ fn protocol(&self) -> Option<OneOrMany<Name>> {
self.protocol.clone()
}
- fn directory(&self) -> Option<NameOrPath> {
+ fn directory(&self) -> Option<Name> {
self.directory.clone()
}
fn storage(&self) -> &Option<Name> {
@@ -1070,7 +1049,7 @@
}
impl AsClause for Use {
- fn r#as(&self) -> Option<&NameOrPath> {
+ fn r#as(&self) -> Option<&Name> {
self.r#as.as_ref()
}
}
@@ -1099,10 +1078,10 @@
}
// TODO(fxbug.dev/340156): Only OneOrMany::One protocol is supported for now. Teach `expose` rules to accept
// `Many` protocols.
- fn protocol(&self) -> Option<OneOrMany<NameOrPath>> {
+ fn protocol(&self) -> Option<OneOrMany<Name>> {
self.protocol.clone()
}
- fn directory(&self) -> Option<NameOrPath> {
+ fn directory(&self) -> Option<Name> {
self.directory.clone()
}
fn storage(&self) -> &Option<Name> {
@@ -1144,7 +1123,7 @@
}
impl AsClause for Expose {
- fn r#as(&self) -> Option<&NameOrPath> {
+ fn r#as(&self) -> Option<&Name> {
self.r#as.as_ref()
}
}
@@ -1177,10 +1156,10 @@
fn service(&self) -> &Option<Name> {
&self.service
}
- fn protocol(&self) -> Option<OneOrMany<NameOrPath>> {
+ fn protocol(&self) -> Option<OneOrMany<Name>> {
self.protocol.clone()
}
- fn directory(&self) -> Option<NameOrPath> {
+ fn directory(&self) -> Option<Name> {
self.directory.clone()
}
fn storage(&self) -> &Option<Name> {
@@ -1226,7 +1205,7 @@
}
impl AsClause for Offer {
- fn r#as(&self) -> Option<&NameOrPath> {
+ fn r#as(&self) -> Option<&Name> {
self.r#as.as_ref()
}
}
@@ -1273,12 +1252,12 @@
r.into()
}
-pub fn alias_or_name(alias: Option<&NameOrPath>, name: &Name) -> Result<Name, Error> {
- Ok(alias.map(|a| a.extract_name_borrowed()).transpose()?.unwrap_or(name).clone())
+pub fn alias_or_name(alias: Option<&Name>, name: &Name) -> Name {
+ alias.unwrap_or(name).clone()
}
-pub fn alias_or_path(alias: Option<&NameOrPath>, path: &Path) -> Result<Path, Error> {
- Ok(alias.map(|a| a.extract_path_borrowed()).transpose()?.unwrap_or(path).clone())
+pub fn alias_or_path(alias: Option<&Path>, path: &Path) -> Path {
+ alias.unwrap_or(path).clone()
}
pub fn alias_or_name_or_path(alias: Option<&NameOrPath>, id: &NameOrPath) -> NameOrPath {
@@ -1540,13 +1519,6 @@
);
assert_eq!(
CapabilityId::from_clause(
- &Offer { protocol: Some(OneOrMany::One("/a".parse().unwrap())), ..empty_offer() },
- RoutingClauseType::Offer
- )?,
- vec![CapabilityId::Protocol("/a".parse().unwrap())]
- );
- assert_eq!(
- CapabilityId::from_clause(
&Offer {
protocol: Some(OneOrMany::Many(vec![
"a".parse().unwrap(),
@@ -1563,22 +1535,6 @@
);
assert_eq!(
CapabilityId::from_clause(
- &Offer {
- protocol: Some(OneOrMany::Many(vec![
- "/a".parse().unwrap(),
- "/b".parse().unwrap()
- ],)),
- ..empty_offer()
- },
- RoutingClauseType::Offer
- )?,
- vec![
- CapabilityId::Protocol("/a".parse().unwrap()),
- CapabilityId::Protocol("/b".parse().unwrap())
- ]
- );
- assert_eq!(
- CapabilityId::from_clause(
&Use { protocol: Some(OneOrMany::One("a".parse().unwrap())), ..empty_use() },
RoutingClauseType::Use
)?,
@@ -1622,13 +1578,6 @@
);
assert_eq!(
CapabilityId::from_clause(
- &Offer { directory: Some("/a".parse().unwrap()), ..empty_offer() },
- RoutingClauseType::Offer
- )?,
- vec![CapabilityId::Directory("/a".parse().unwrap())]
- );
- assert_eq!(
- CapabilityId::from_clause(
&Use {
directory: Some("a".parse().unwrap()),
path: Some("/b".parse().unwrap()),
@@ -1660,17 +1609,6 @@
)?,
vec![CapabilityId::Service("b".parse().unwrap())]
);
- assert_eq!(
- CapabilityId::from_clause(
- &Offer {
- protocol: Some(OneOrMany::One("/a".parse().unwrap())),
- r#as: Some("/b".parse().unwrap()),
- ..empty_offer()
- },
- RoutingClauseType::Offer
- )?,
- vec![CapabilityId::Protocol("/b".parse().unwrap())]
- );
// Error case.
assert_matches!(