diff options
author | Tiancong Wang <tcwang@google.com> | 2020-02-13 21:08:49 +0000 |
---|---|---|
committer | Tiancong Wang <tcwang@google.com> | 2020-02-13 21:08:49 +0000 |
commit | b75f321fc8978b92ce3db6886ccb966768f0c7a8 (patch) | |
tree | 35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /deprecated/dejagnu/chromeos.exp.in | |
parent | cddd960b0ba2eb62c372c0d3176c75f0bd05d5e8 (diff) | |
parent | e617e3393dd24003aa976ece5050bb291070041c (diff) | |
download | toolchain-utils-android11-mainline-media-swcodec-release.tar.gz |
Merging 18 commit(s) from Chromium's toolchain-utils am: 0ae38c8498 am: 2a19d36a82 am: e617e3393dr_aml_301500702android-mainline-12.0.0_r55android-mainline-11.0.0_r9android-mainline-11.0.0_r8android-mainline-11.0.0_r7android-mainline-11.0.0_r6android-mainline-11.0.0_r5android-mainline-11.0.0_r45android-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r4android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r33android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r3android-mainline-11.0.0_r29android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r2android-mainline-11.0.0_r19android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12android-mainline-11.0.0_r10android-mainline-11.0.0_r1android-11.0.0_r48android-11.0.0_r47android-11.0.0_r46android-11.0.0_r45android-11.0.0_r44android-11.0.0_r43android-11.0.0_r42android-11.0.0_r41android-11.0.0_r40android-11.0.0_r39android-11.0.0_r38android-11.0.0_r37android-11.0.0_r36android-11.0.0_r35android-11.0.0_r34android-11.0.0_r33android-11.0.0_r32android-11.0.0_r31android-11.0.0_r30android-11.0.0_r29android-11.0.0_r28android-11.0.0_r27android-11.0.0_r26android-11.0.0_r24android-11.0.0_r23android-11.0.0_r22android-11.0.0_r21android-11.0.0_r20android-11.0.0_r19android-11.0.0_r18android-11.0.0_r16android11-qpr3-s1-releaseandroid11-qpr3-releaseandroid11-qpr2-releaseandroid11-qpr1-s2-releaseandroid11-qpr1-s1-releaseandroid11-qpr1-releaseandroid11-qpr1-d-s1-releaseandroid11-qpr1-d-releaseandroid11-qpr1-c-releaseandroid11-mainline-tethering-releaseandroid11-mainline-sparse-2021-jan-releaseandroid11-mainline-sparse-2020-dec-releaseandroid11-mainline-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-releaseandroid11-devandroid11-d2-releaseandroid11-d1-b-release
Change-Id: I3f25c7ee034b2e20e37ed941b8eae24eec7043eb
Diffstat (limited to 'deprecated/dejagnu/chromeos.exp.in')
-rw-r--r-- | deprecated/dejagnu/chromeos.exp.in | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/deprecated/dejagnu/chromeos.exp.in b/deprecated/dejagnu/chromeos.exp.in new file mode 100644 index 00000000..02fc3af2 --- /dev/null +++ b/deprecated/dejagnu/chromeos.exp.in @@ -0,0 +1,175 @@ +# +# Initialize the board. The function is executed before any test. +# +proc __boardname___init { board } { + set hostname [board_info $board hostname] + set timeout [board_info $board timeout] + set ssh_options [board_info $board ssh,options] + set runtimes [board_info $board runtimes] + set tmpdir [board_info $board tmpdir] + verbose -log "Opening persistent connection ..." 1 + eval "exec ssh -N -f $ssh_options root@$hostname &" + local_exec "ssh -n $ssh_options root@$hostname sh -c 'mkdir -p $tmpdir'" \ + {} {} $timeout +} + +# +# Remove test run by-products. The function is executed at DejaGNU exit. +# +proc __boardname___exit {} { + set board "__boardname__" + set hostname [board_info $board hostname] + set ssh_options [board_info $board ssh,options] + set tmpdir [board_info $board tmpdir] + verbose -log "Closing persistent connection ..." 1 + local_exec "ssh $ssh_options -O exit root@$hostname" {} {} 10 + verbose -log "Cleaning up - executing on board 'rm -fr $tmpdir' ..." 1 + local_exec "ssh -n $ssh_options root@$hostname sh -c 'rm -fr $tmpdir'" \ + {} {} 10 +} + +# +# Upload a file to the board. Uses scp over persistent SSH connection. +# +proc __boardname___download { board file args } { + set hostname [board_info $board hostname] + set tmpdir [board_info $board tmpdir] + set timeout [board_info $board timeout] + set ssh_options [board_info $board ssh,options] + set destfile [lindex [file split $file] end] + verbose -log "scp -q $ssh_options $file root@$hostname:$tmpdir/" + set result [local_exec "scp -q $ssh_options $file root@$hostname:$tmpdir/" \ + {} {} $timeout] + if { [lindex $result 0] != 0 } { + verbose -log "failed to upload \'$file\' to \'$tmpdir/$destfile\'" + } else { + verbose -log "uploaded \"$file\' to remote board@\'$tmpdir/$destfile\'" + return "$tmpdir/$destfile" + } +} + +# +# Download a file to the host machine. Uses scp over persistent SSH connection. +# +proc __boardname___upload { board file args } { + set hostname [board_info $board hostname] + set tmpdir [board_info $board tmpdir] + set timeout [board_info $board timeout] + set ssh_options [board_info $board ssh,options] + set filen [file tail $file] + verbose -log "scp -q $ssh_options \"root@$hostname:$tmpdir/$filen\" ." + set result [local_exec \ + "scp -q $ssh_options \"root@$hostname:$tmpdir/$filen\" ." \ + {} {} $timeout] + if { [lindex $result 0] != 0 } { + verbose -log \ + "failed to transfer \"root@$hostname:$tmpdir/$filen\" to \".\"" + } else { + verbose -log "transferred \"root@$hostname:$tmpdir/$filen\" to \".\"" + # In case of success, always return the original file. + return "$file" + } +} + +# +# Cache program output within different invoking of __boardname___exec. +# For example, the following command sequence will be executed +# > cd /tmp/dejagnu_xxxx/ && ./xxx.x0 +# <output1 here> +# return [0, <output1>] (a) +# > rm /tmp/dejagnu_xxxx/xxxx.x0 +# <output2 here> +# return [0, <output2>] (b) +# We need <output1>, not <output2>. What we do here is to keep <output1> in +# $program_output and in (b) we return [0, <output1>]. +# +set program_output "" + +# +# Execute a test on remote machine. Log into the target machine using +# persistent SSH connection and run a command in modified environment. +# +proc __boardname___exec { board program args } { + global program_output + if { [llength $args] > 0 } { + set pargs [lindex $args 0] + } else { + set pargs "" + } + + if { [llength $args] > 1 } { + set inp "[lindex $args 1]" + } else { + set inp "" + } + + if { [llength $args] > 2 } { + set outp "[lindex $args 2]" + } else { + set outp "" + } + + if { [llength $args] > 3 } { + set timeout "[lindex $args 3]" + } else { + set timeout [board_info $board timeout] + } + + set hostname [board_info $board hostname] + set tmpdir [board_info $board tmpdir] + set other_file "" + + # Check if a file to be executed was copied from host machine. If so, we + # need to run it in copied runtimes. + set is_program "0" + if { [string match "$tmpdir/*" $program] } { + set path [file dirname $program] + # "$program" would usually be like "/x/y/z.out", set command to be "z.out". + set command [file tail $program] + set rootname [file rootname $command] + # TODO(shenhan): using rsync to copy all test case relatd stuff to host + # machine in case ".o" files are different from the exe files. + set other_file [file join $path "${rootname}.*"] + # Change directory to "/x/y", then execute "./z.out" - we want the working + # directory to be "/x/y". Setting GCOV_PREFIX_STRIP and GCOV_PREFIX is to + # force generating ".gcda" file under "/x/y" instead of some host path. + set program "cd $path && GCOV_PREFIX_STRIP=999 GCOV_PREFIX=$tmpdir/ \ + [file join "." $command]" + set is_program "1" + } + verbose -log "Exec: $program" + set ssh_options [board_info $board ssh,options] + set retv [local_exec \ + "ssh -n $ssh_options root@$hostname sh -c '$program $pargs'" \ + $inp $outp $timeout] + set status [lindex $retv 0] + if { $is_program == "1" } { + set program_output [lindex $retv 1] + } + + # Before returning the execution status, we try to transfer the ".gcda" + # (and/or other files that have the same base name as the program) file to + # host, though for every program that runs, there is no corresponding "other" + # file. We have no idea when such an other file will be generated for the + # program, so every time, we assume there is an "other" file and try to do the + # transfer. + if { $status == 0 && $other_file != "" } { + set upv [${board}_upload $board $other_file ""] + if { $upv == "" } { + verbose -log "Safely ignored - \"$other_file\" does not exist." + } + } + + return [list $status $program_output] +} + +load_generic_config "unix" +load_base_board_description "linux-libremote" + +set_board_info hostname "__board_hostname__" +set_board_info tmpdir "__tmp_dir__" + +set_board_info isremote 1 +set_board_info timeout 60 +set_board_info ssh,options "-i __tmp_testing_rsa__ -o ControlMaster=auto \ +-o ControlPath=__tmp_dir__/%r@%h:%p -o StrictHostKeyChecking=no " |