@@ -43,35 +43,15 @@ enum Error {
4343const GIMLET_ROOT_NODE_NAME : & str = "Oxide,Gimlet" ;
4444
4545/// Return true if the host system is an Oxide Gimlet.
46- #[ cfg( not( test) ) ]
4746pub fn is_gimlet ( ) -> anyhow:: Result < bool > {
48- let mut device_info = DevInfo :: new_force_load ( ) ?;
47+ let mut device_info = DevInfo :: new ( ) ?;
4948 let mut node_walker = device_info. walk_node ( ) ;
5049 let Some ( root) = node_walker. next ( ) . transpose ( ) ? else {
5150 anyhow:: bail!( "No nodes in device tree" ) ;
5251 } ;
5352 Ok ( root. node_name ( ) == GIMLET_ROOT_NODE_NAME )
5453}
5554
56- /// Return true if the host system is an Oxide Gimlet.
57- //
58- // TODO-testing: This assumes we never test on real Gimlets. That's likely to be
59- // a bad assumption in the long-term. For now, however, we catch permissions
60- // errors and return `Ok(false)`, on the assumption that (1) either you're not a
61- // Gimlet, so that's the correct answer or (2) if you are on a Gimlet, you are
62- // root or have configured the right permissions anyway.
63- #[ cfg( test) ]
64- pub fn is_gimlet ( ) -> anyhow:: Result < bool > {
65- let Ok ( mut device_info) = DevInfo :: new_force_load ( ) else {
66- return Ok ( false ) ;
67- } ;
68- let mut node_walker = device_info. walk_node ( ) ;
69- let Ok ( Some ( root) ) = node_walker. next ( ) . transpose ( ) else {
70- return Ok ( false ) ;
71- } ;
72- Ok ( root. node_name ( ) == GIMLET_ROOT_NODE_NAME )
73- }
74-
7555// A snapshot of information about the underlying Tofino device
7656#[ derive( Copy , Clone ) ]
7757struct TofinoSnapshot {
0 commit comments