f/automatic-build-nightly
Jesse Vincent 4 years ago
parent 15ac6fe9e2
commit b05a8e8c5f
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -17,7 +17,6 @@ my $inside_test = 0;
my $test_class = 'GeneratedKTest';
GetOptions(
"cxx=s" => \$cxx_filename, # string
"ktest=s" => \$text_filename,
@ -42,9 +41,6 @@ close ($outfile);
exit(0);
sub load_from_text {
my @content = ();
open( my $text_fh, "<", $text_filename ) or die "Can't open file $!";
@ -104,7 +100,8 @@ sub load_from_text {
press => sub {
my $content = shift;
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 };
},
@ -121,7 +118,8 @@ sub load_from_text {
if ( $content =~ /^no keyboard-report/ ) {
return {
report_type => 'keyboard',
count => 0 };
count => 0
};
}
if ( $content =~ /^keyboard-report\s+(.*)$/ ) {
my $report_data = $1;
@ -150,9 +148,15 @@ sub load_from_text {
elsif ( $unit =~ /milli|ms/ ) {
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;
if ( $type && exists $dispatcher->{$type} ) {
$data = $dispatcher->{$type}->($content);
# an empty return means "don't put it in the script
if ( !$data ) {
next;
@ -182,13 +187,11 @@ sub load_from_text {
@script_lines = @content;
}
sub generate_test_file {
generate_preface();
generate_key_addrs();
generate_script();
generate_postscript();
@ -210,6 +213,7 @@ sub generate_key_addrs {
}
}
sub generate_start_new_test {
my $name = shift;
if ($inside_test) {
@ -220,6 +224,7 @@ sub generate_start_new_test {
indent();
cxx("ClearState(); // Clear any state from previous tests");
}
sub generate_end_test {
generate_check_expected_reports();
outdent();
@ -240,7 +245,9 @@ sub generate_script {
cxx('#define GTEST_COUT std::cerr << "[ INFO ] "');
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('');
$reports_expected = 0;
@ -251,9 +258,13 @@ sub generate_script {
}
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 ) {
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 'release' ) { generate_release($entry); }
@ -300,15 +311,21 @@ sub generate_release {
sub generate_expect_report {
my $report = shift;
if (! $report->{data}->{report_type} || $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";
if ( !$report->{data}->{report_type}
|| $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++;
if ( $report->{data}->{count} == 0 ) {
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;
}
@ -358,6 +375,7 @@ for my $line (split/\n/,$preface) {
cxx($line);
}
}
sub generate_postscript {
my $postscript = <<EOF;

Loading…
Cancel
Save