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

script_run: base serial buffer size on command length #2429

Merged
merged 1 commit into from
Jan 13, 2024
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
2 changes: 1 addition & 1 deletion distribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ sub script_run ($self, $cmd, @args) {
my $marker = "; echo $str-\$?-" . ($args{output} ? "Comment: $args{output}" : '');
if (testapi::is_serial_terminal) {
testapi::type_string($marker);
testapi::wait_serial($cmd . $marker, no_regex => 1, quiet => $args{quiet});
testapi::wait_serial($cmd . $marker, no_regex => 1, quiet => $args{quiet}, buffer_size => length($cmd) + 128);
testapi::type_string("\n");
}
else {
Expand Down
26 changes: 26 additions & 0 deletions t/05-distribution.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use Test::Warnings qw(:all :report_warnings);
use Test::Fatal;
use Test::MockModule;

my @wait_serial_calls;

subtest 'script_run' => sub {
require distribution;
my $d = distribution->new;
Expand All @@ -33,6 +35,30 @@ subtest 'script_run' => sub {
lives_ok sub { $d->script_run('foo\&') }, 'escaped terminator is accepted';
lives_ok sub { $d->script_run('foo && bar') }, 'AND operator is accepted';
lives_ok sub { $d->script_run('foo "x&"') }, 'quoted & is accepted';
$mock_testapi->redefine(wait_serial => sub {
my $regexp = shift;
push @wait_serial_calls, {
regexp => $regexp,
timeout => 90,
expect_not_found => 0,
quiet => undef,
no_regex => 0,
buffer_size => undef,
record_output => undef,
@_
};
});
$mock_testapi->redefine(is_serial_terminal => 1);
$d->script_run('short_command');
# script_run calls wait_serial three times when on a serial
# console, the call we want to check - which actually types the
# command - is the second
my $cmdcall = $wait_serial_calls[1];
is $cmdcall->{buffer_size}, 141, 'appropriate buffer size used for short command';
@wait_serial_calls = ();
$d->script_run('long_command' x 512);
$cmdcall = $wait_serial_calls[1];
is $cmdcall->{buffer_size}, 6272, 'appropriate buffer size used for long command';
};

done_testing;
Expand Down