|
|
@ -17,7 +17,6 @@ my $inside_test = 0;
|
|
|
|
|
|
|
|
|
|
|
|
my $test_class = 'GeneratedKTest';
|
|
|
|
my $test_class = 'GeneratedKTest';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetOptions(
|
|
|
|
GetOptions(
|
|
|
|
"cxx=s" => \$cxx_filename, # string
|
|
|
|
"cxx=s" => \$cxx_filename, # string
|
|
|
|
"ktest=s" => \$text_filename,
|
|
|
|
"ktest=s" => \$text_filename,
|
|
|
@ -42,9 +41,6 @@ close ($outfile);
|
|
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub load_from_text {
|
|
|
|
sub load_from_text {
|
|
|
|
my @content = ();
|
|
|
|
my @content = ();
|
|
|
|
open( my $text_fh, "<", $text_filename ) or die "Can't open file $!";
|
|
|
|
open( my $text_fh, "<", $text_filename ) or die "Can't open file $!";
|
|
|
@ -104,7 +100,8 @@ sub load_from_text {
|
|
|
|
press => sub {
|
|
|
|
press => sub {
|
|
|
|
my $content = shift;
|
|
|
|
my $content = shift;
|
|
|
|
unless ( defined $named_switches->{$content} ) {
|
|
|
|
unless ( defined $named_switches->{$content} ) {
|
|
|
|
die "Attempt to press undefined switch $content on line $line_num";
|
|
|
|
die
|
|
|
|
|
|
|
|
"Attempt to press undefined switch $content on line $line_num";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return { switch => $content };
|
|
|
|
return { switch => $content };
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -121,7 +118,8 @@ sub load_from_text {
|
|
|
|
if ( $content =~ /^no keyboard-report/ ) {
|
|
|
|
if ( $content =~ /^no keyboard-report/ ) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
report_type => 'keyboard',
|
|
|
|
report_type => 'keyboard',
|
|
|
|
count => 0 };
|
|
|
|
count => 0
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $content =~ /^keyboard-report\s+(.*)$/ ) {
|
|
|
|
if ( $content =~ /^keyboard-report\s+(.*)$/ ) {
|
|
|
|
my $report_data = $1;
|
|
|
|
my $report_data = $1;
|
|
|
@ -150,9 +148,15 @@ sub load_from_text {
|
|
|
|
elsif ( $unit =~ /milli|ms/ ) {
|
|
|
|
elsif ( $unit =~ /milli|ms/ ) {
|
|
|
|
return { millis => $count };
|
|
|
|
return { millis => $count };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { die "Line $line_num: failed to parse a 'run' clause: $content"; }
|
|
|
|
else {
|
|
|
|
|
|
|
|
die
|
|
|
|
|
|
|
|
"Line $line_num: failed to parse a 'run' clause: $content";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
die
|
|
|
|
|
|
|
|
"Line $line_num: failed to parse a 'run' clause: $content";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { die "Line $line_num: failed to parse a 'run' clause: $content"; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -161,6 +165,7 @@ sub load_from_text {
|
|
|
|
my $data;
|
|
|
|
my $data;
|
|
|
|
if ( $type && exists $dispatcher->{$type} ) {
|
|
|
|
if ( $type && exists $dispatcher->{$type} ) {
|
|
|
|
$data = $dispatcher->{$type}->($content);
|
|
|
|
$data = $dispatcher->{$type}->($content);
|
|
|
|
|
|
|
|
|
|
|
|
# an empty return means "don't put it in the script
|
|
|
|
# an empty return means "don't put it in the script
|
|
|
|
if ( !$data ) {
|
|
|
|
if ( !$data ) {
|
|
|
|
next;
|
|
|
|
next;
|
|
|
@ -182,13 +187,11 @@ sub load_from_text {
|
|
|
|
@script_lines = @content;
|
|
|
|
@script_lines = @content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub generate_test_file {
|
|
|
|
sub generate_test_file {
|
|
|
|
|
|
|
|
|
|
|
|
generate_preface();
|
|
|
|
generate_preface();
|
|
|
|
generate_key_addrs();
|
|
|
|
generate_key_addrs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generate_script();
|
|
|
|
generate_script();
|
|
|
|
|
|
|
|
|
|
|
|
generate_postscript();
|
|
|
|
generate_postscript();
|
|
|
@ -210,6 +213,7 @@ sub generate_key_addrs {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub generate_start_new_test {
|
|
|
|
sub generate_start_new_test {
|
|
|
|
my $name = shift;
|
|
|
|
my $name = shift;
|
|
|
|
if ($inside_test) {
|
|
|
|
if ($inside_test) {
|
|
|
@ -220,6 +224,7 @@ sub generate_start_new_test {
|
|
|
|
indent();
|
|
|
|
indent();
|
|
|
|
cxx("ClearState(); // Clear any state from previous tests");
|
|
|
|
cxx("ClearState(); // Clear any state from previous tests");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub generate_end_test {
|
|
|
|
sub generate_end_test {
|
|
|
|
generate_check_expected_reports();
|
|
|
|
generate_check_expected_reports();
|
|
|
|
outdent();
|
|
|
|
outdent();
|
|
|
@ -240,7 +245,9 @@ sub generate_script {
|
|
|
|
cxx('#define GTEST_COUT std::cerr << "[ INFO ] "');
|
|
|
|
cxx('#define GTEST_COUT std::cerr << "[ INFO ] "');
|
|
|
|
|
|
|
|
|
|
|
|
generate_start_new_test('KtestSourceFilename');
|
|
|
|
generate_start_new_test('KtestSourceFilename');
|
|
|
|
cxx("GTEST_COUT << \"test: @{[File::Spec->rel2abs( $text_filename ) ]}\" << std::endl;");
|
|
|
|
cxx(
|
|
|
|
|
|
|
|
"GTEST_COUT << \"test: @{[File::Spec->rel2abs( $text_filename ) ]}\" << std::endl;"
|
|
|
|
|
|
|
|
);
|
|
|
|
generate_end_test('');
|
|
|
|
generate_end_test('');
|
|
|
|
|
|
|
|
|
|
|
|
$reports_expected = 0;
|
|
|
|
$reports_expected = 0;
|
|
|
@ -251,9 +258,13 @@ sub generate_script {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ( my $action = $entry->{action} ) {
|
|
|
|
elsif ( my $action = $entry->{action} ) {
|
|
|
|
|
|
|
|
|
|
|
|
if ( $action eq 'name' ) { generate_start_new_test($entry->{data}->{test_name}) }
|
|
|
|
if ( $action eq 'name' ) {
|
|
|
|
|
|
|
|
generate_start_new_test( $entry->{data}->{test_name} );
|
|
|
|
|
|
|
|
}
|
|
|
|
elsif ( !$inside_test && defined $action ) {
|
|
|
|
elsif ( !$inside_test && defined $action ) {
|
|
|
|
die "Attempting to run an action '$action' when not inside a test section on line " . $entry->{line_num} . "\n";
|
|
|
|
die
|
|
|
|
|
|
|
|
"Attempting to run an action '$action' when not inside a test section on line "
|
|
|
|
|
|
|
|
. $entry->{line_num} . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ( $action eq 'press' ) { generate_press($entry) }
|
|
|
|
elsif ( $action eq 'press' ) { generate_press($entry) }
|
|
|
|
elsif ( $action eq 'release' ) { generate_release($entry); }
|
|
|
|
elsif ( $action eq 'release' ) { generate_release($entry); }
|
|
|
@ -300,15 +311,21 @@ sub generate_release {
|
|
|
|
|
|
|
|
|
|
|
|
sub generate_expect_report {
|
|
|
|
sub generate_expect_report {
|
|
|
|
my $report = shift;
|
|
|
|
my $report = shift;
|
|
|
|
if (! $report->{data}->{report_type} || $report->{data}->{report_type} ne 'keyboard') {
|
|
|
|
if ( !$report->{data}->{report_type}
|
|
|
|
die "Don't know how to work with expectaions of reports other than 'keyboard' reports at line #".$report->{line_num}."\n";
|
|
|
|
|| $report->{data}->{report_type} ne 'keyboard' )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
die
|
|
|
|
|
|
|
|
"Don't know how to work with expectaions of reports other than 'keyboard' reports at line #"
|
|
|
|
|
|
|
|
. $report->{line_num} . "\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$reports_expected++;
|
|
|
|
$reports_expected++;
|
|
|
|
|
|
|
|
|
|
|
|
if ( $report->{data}->{count} == 0 ) {
|
|
|
|
if ( $report->{data}->{count} == 0 ) {
|
|
|
|
cxx_comment( $report->{comment} );
|
|
|
|
cxx_comment( $report->{comment} );
|
|
|
|
cxx_comment("We don't expect any report here, and have told the tests to check that");
|
|
|
|
cxx_comment(
|
|
|
|
|
|
|
|
"We don't expect any report here, and have told the tests to check that"
|
|
|
|
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -358,6 +375,7 @@ for my $line (split/\n/,$preface) {
|
|
|
|
cxx($line);
|
|
|
|
cxx($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub generate_postscript {
|
|
|
|
sub generate_postscript {
|
|
|
|
|
|
|
|
|
|
|
|
my $postscript = <<EOF;
|
|
|
|
my $postscript = <<EOF;
|
|
|
|