Skip to content

Commit

Permalink
PR #8788 from Matan: find_first_device_or_exit (cpp/py) exit with err…
Browse files Browse the repository at this point in the history
…or with no device
  • Loading branch information
maloel authored Apr 28, 2021
2 parents bddae60 + 808a9a7 commit 8cfef06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 6 additions & 6 deletions unit-tests/func/func-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ inline rs2::device find_first_device_or_exit()
rs2::device_list devices_list = ctx.query_devices();
if( devices_list.size() == 0 )
{
std::cout << "No device was found; skipping test" << std::endl;
exit( 0 );
std::cout << "No device was found" << std::endl;
exit( 1 );
}
return devices_list[0];
}
Expand All @@ -27,9 +27,9 @@ inline rs2::device_list find_devices_by_product_line_or_exit( int product )
rs2::device_list devices_list = ctx.query_devices( product );
if( devices_list.size() == 0 )
{
std::cout << "No device of the " << product << " product line was found; skipping test"
std::cout << "No device of the " << product << " product line was found"
<< std::endl;
exit( 0 );
exit( 1 );
}

return devices_list;
Expand Down Expand Up @@ -68,8 +68,8 @@ inline rs2::device find_first_device_by_name_or_exit( const std::string & dev_na
return *dev_iter;
}

std::cout << "No " << dev_name << " device was found; skipping test" << std::endl;
exit( 0 );
std::cout << "No " << dev_name << " device was found" << std::endl;
exit( 1 );
}

// Return the first device that supports the input option or exits.
Expand Down
6 changes: 2 additions & 4 deletions unit-tests/py/rspy/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def find_first_device_or_exit():
import pyrealsense2 as rs
c = rs.context()
if not c.devices.size(): # if no device is connected we skip the test
print("No device found, skipping test")
sys.exit( 0 )
log.f("No device found")
dev = c.devices[0]
log.d( 'found', dev )
return dev
Expand All @@ -89,8 +88,7 @@ def find_devices_by_product_line_or_exit( product_line ):
c = rs.context()
devices_list = c.query_devices(product_line)
if devices_list.size() == 0:
print( "No device of the", product_line, "product line was found; skipping test" )
sys.exit( 0 )
log.f( "No device of the", product_line, "product line was found" )
log.d( 'found', devices_list.size(), product_line, 'devices:', [dev for dev in devices_list] )
return devices_list

Expand Down

0 comments on commit 8cfef06

Please sign in to comment.