Work around bug in AIX 7.1 awk in report card tool
[dejagnu.git] / baseboards / androideabi.exp
blob8f3fb1ddbfa23b10e84bd5389ba91138e3ed38ac
1 # Copyright (C) 2013-2016, 2019 Free Software Foundation, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # DejaGnu is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu.  If not, see <http://www.gnu.org/licenses/>.
18 process_multilib_options ""
20 load_generic_config "adb"
22 # We need this for find_gcc and *_include_flags/*_link_flags.
23 load_base_board_description "adb"
25 # We may need -mandroid.
26 set_board_info cflags  "-mandroid"
27 set_board_info ldflags  "-mandroid"
30 # load PROG to DEST and run it with ARGS using adb
32 proc adb_load { dest prog args } {
33     # Default directory uses tmpfs, so it is the best place to run
34     # tests to avoid excessive wear of flash.
35     global android_tmp_dir
36     if { $android_tmp_dir ne "" } {
37         verbose -log "android temporary directory is set to $android_tmp_dir" 3
38     } else {
39         set android_tmp_dir "/mnt/sdcard/.android_secure"
40         verbose -log "android temporary directory will be used by default $android_tmp_dir" 3
41     }
43     if { [llength $args] > 0 } {
44         set pargs [lindex $args 0]
45     } else {
46         set pargs ""
47     }
49     if { [llength $args] > 1 } {
50         set inp "[lindex $args 1]"
51     } else {
52         set inp ""
53     }
55     if {![file exists $prog]} then {
56         # We call both here because this should never happen.
57         perror "$prog does not exist in standard_load."
58         verbose -log "$prog does not exist." 3
59         return "untested"
60     }
62     if {[isremote $dest]} {
63         set localfile "./[file tail $prog].[pid]"
64         set remotefile "$android_tmp_dir/[file tail $prog].[pid]"
65         set remotefile [remote_download $dest $prog $remotefile]
66         if { $remotefile eq "" } {
67             verbose -log "Download of $prog to [board_info $dest name] failed." 3
68             return "unresolved"
69         }
70         set retval [remote_exec $dest "test -x $remotefile"]
71         if { $retval ne "0 {}" } {
72             # Android doesn't support symbolic input for chmod, therefore set executable permission by number
73             set retval [remote_exec $dest "chmod 755 $remotefile"]
74             if { $retval ne "0 {}" } {
75                 verbose -log "Setting executable permissions of $prog on [board_info $dest name] failed." 3
76                 return "unresolved"
77             }
78         }
79         if {[board_info $dest exists remote_link]} {
80             if {[[board_info $dest remote_link] $remotefile]} {
81                 verbose -log "Couldn't do remote link"
82                 # Can't use remote_file delete since /system/bin/rm does not
83                 # support -f on Android.
84                 remote_exec $dest rm $remotefile
85                 return "unresolved"
86             }
87         }
88         set status [remote_exec $dest $localfile $pargs $inp]
89         remote_exec $dest rm $remotefile
90     } else {
91         set status [remote_exec $dest $prog $pargs $inp]
92     }
93     if { [lindex $status 0] < 0 } {
94         verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
95         return "unresolved"
96     }
97     set output [lindex $status 1]
98     set status [lindex $status 0]
100     verbose -log "Executed $prog, status $status" 2
101     if {$output ne ""} {
102         verbose -log -- $output 2
103     }
104     if { $status == 0 } {
105         return [list "pass" $output]
106     } else {
107         return [list "fail" $output]
108     }