Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed preset unit-test issues #8297

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions unit-tests/func/presets/presets-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using namespace rs2;

const librealsense::firmware_version MIN_GET_DEFAULT_FW_VERSION( "1.5.3.0" );
const librealsense::firmware_version MIN_GET_DEFAULT_FW_VERSION( "1.5.4.0" );

typedef std::pair< rs2_l500_visual_preset, rs2_sensor_mode > preset_mode_pair;

Expand Down Expand Up @@ -368,27 +368,34 @@ void check_preset_values( const rs2::sensor & sens,
compare_to_actual( sens, expected_values, expected_defaults );
}

void check_presets_values( const rs2::sensor & sens,
void check_presets_values( std::vector< rs2_l500_visual_preset > presets_to_check,
const rs2::sensor & sens,
preset_values_map & preset_to_expected_values,
preset_values_map & preset_to_expected_defaults,
std::function< void( preset_mode_pair ) > do_before_check = nullptr,
std::function< void( preset_mode_pair ) > do_after_check = nullptr )
{
REQUIRE( sens.supports( RS2_OPTION_VISUAL_PRESET ) );

for_each_preset_mode_combination( [&]( preset_mode_pair preset_mode ) {
if( do_before_check )
do_before_check( preset_mode );

check_preset_values( sens,
preset_mode.first,
preset_mode.second,
preset_to_expected_values[preset_mode],
preset_to_expected_defaults[preset_mode] );

if( do_after_check )
do_after_check( preset_mode );
} );
for (auto& preset : presets_to_check)
{
for (int sensor_mode = RS2_SENSOR_MODE_VGA; sensor_mode < RS2_SENSOR_MODE_QVGA;
sensor_mode++)
{
preset_mode_pair preset_mode = { preset, (rs2_sensor_mode)sensor_mode };
if (do_before_check)
do_before_check(preset_mode);

check_preset_values(sens,
preset_mode.first,
preset_mode.second,
preset_to_expected_values[preset_mode],
preset_to_expected_defaults[preset_mode]);

if (do_after_check)
do_after_check(preset_mode);
}
}
}

void start_depth_ir_confidence( const rs2::sensor & sens,
Expand All @@ -399,7 +406,12 @@ void start_depth_ir_confidence( const rs2::sensor & sens,
auto confidence = find_profile( sens, RS2_STREAM_CONFIDENCE, mode );

REQUIRE_NOTHROW( sens.open( { depth, ir, confidence } ) );
REQUIRE_NOTHROW( sens.start( [&]( rs2::frame f ) {} ) );

// Wait for the first frame to arrive: until this time, the FW is in an "undefined"
// streaming state, and we may get weird behavior.
frame_queue q;
REQUIRE_NOTHROW(sens.start(q));
q.wait_for_frame();
}

void stop_depth( const rs2::sensor & sens )
Expand All @@ -416,6 +428,7 @@ void set_mode_preset( const rs2::sensor & sens, preset_mode_pair preset_mode)
}

void check_presets_values_while_streaming(
std::vector<rs2_l500_visual_preset> presets_to_check,
const rs2::sensor & sens,
preset_values_map & preset_to_expected_values,
preset_values_map & preset_to_expected_defaults,
Expand All @@ -425,6 +438,7 @@ void check_presets_values_while_streaming(
REQUIRE( sens.supports( RS2_OPTION_VISUAL_PRESET ) );

check_presets_values(
presets_to_check,
sens,
preset_to_expected_values,
preset_to_expected_defaults,
Expand Down Expand Up @@ -465,4 +479,4 @@ void build_new_device_and_do( std::function< void( rs2::depth_sensor & depth_sen
auto depth_sens = dev.first< rs2::depth_sensor >();

action( depth_sens );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ TEST_CASE( "presets sanity while streaming", "[l500][live]" )

// set preset and mode before stream start
check_presets_values_while_streaming(
{ RS2_L500_VISUAL_PRESET_NO_AMBIENT, RS2_L500_VISUAL_PRESET_LOW_AMBIENT },
depth_sens,
expected_values,
expected_defs,
[&]( preset_mode_pair preset_mode ) { set_mode_preset( depth_sens, preset_mode ); } );

// set preset and mode after stream start
check_presets_values_while_streaming(
{ RS2_L500_VISUAL_PRESET_MAX_RANGE, RS2_L500_VISUAL_PRESET_SHORT_RANGE },
depth_sens,
expected_values,
expected_defs,
Expand Down
4 changes: 4 additions & 0 deletions unit-tests/func/presets/test-presets-sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ TEST_CASE( "presets sanity", "[l500][live]" )
//print_presets_to_csv( depth_sens, preset_to_expected_defaults_map);

check_presets_values(
{ RS2_L500_VISUAL_PRESET_NO_AMBIENT,
RS2_L500_VISUAL_PRESET_LOW_AMBIENT,
RS2_L500_VISUAL_PRESET_MAX_RANGE,
RS2_L500_VISUAL_PRESET_SHORT_RANGE },
depth_sens,
expected_values,
expected_defs,
Expand Down
7 changes: 4 additions & 3 deletions unit-tests/func/send-hw-monitor-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#include "../test.h"
#include "librealsense2/rs.hpp"
#include "hw-monitor.h"
#include <librealsense2/rs.hpp>
#include <hw-monitor.h>

#pragma once
using namespace rs2;

struct hw_monitor_command
Expand All @@ -26,7 +27,7 @@ struct hw_monitor_command
int p4;
};

std::vector< uint8_t > send_command_and_check( rs2::debug_protocol dp,
inline std::vector< uint8_t > send_command_and_check( rs2::debug_protocol dp,
hw_monitor_command command,
uint32_t expected_size_return = 0 )
{
Expand Down