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, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19 process_multilib_options ""
21 load_generic_config "adb"
23 # We need this for find_gcc and *_include_flags/*_link_flags.
24 load_base_board_description "adb"
26 # We may need -mandroid.
27 set_board_info cflags "-mandroid"
28 set_board_info ldflags "-mandroid"
31 # load PROG to DEST and run it with ARGS using adb
33 proc adb_load { dest prog args } {
34 # Default directory uses tmpfs, so it is the best place to run
35 # tests to avoid excessive wear of flash.
36 global android_tmp_dir
37 if { $android_tmp_dir ne "" } {
38 verbose -log "android temporary directory is set to $android_tmp_dir" 3
40 set android_tmp_dir "/mnt/sdcard/.android_secure"
41 verbose -log "android temporary directory will be used by default $android_tmp_dir" 3
44 if { [llength $args] > 0 } {
45 set pargs [lindex $args 0]
50 if { [llength $args] > 1 } {
51 set inp "[lindex $args 1]"
56 if {![file exists $prog]} then {
57 # We call both here because this should never happen.
58 perror "$prog does not exist in standard_load."
59 verbose -log "$prog does not exist." 3
63 if {[isremote $dest]} {
64 set localfile "./[file tail $prog].[pid]"
65 set remotefile "$android_tmp_dir/[file tail $prog].[pid]"
66 set remotefile [remote_download $dest $prog $remotefile]
67 if { $remotefile eq "" } {
68 verbose -log "Download of $prog to [board_info $dest name] failed." 3
71 set retval [remote_exec $dest "test -x $remotefile"]
72 if { $retval ne "0 {}" } {
73 # Android doesn't support symbolic input for chmod, therefore set executable permission by number
74 set retval [remote_exec $dest "chmod 755 $remotefile"]
75 if { $retval ne "0 {}" } {
76 verbose -log "Setting executable permissions of $prog on [board_info $dest name] failed." 3
80 if {[board_info $dest exists remote_link]} {
81 if {[[board_info $dest remote_link] $remotefile]} {
82 verbose -log "Couldn't do remote link"
83 # Can't use remote_file delete since /system/bin/rm does not
84 # support -f on Android.
85 remote_exec $dest rm $remotefile
89 set status [remote_exec $dest $localfile $pargs $inp]
90 remote_exec $dest rm $remotefile
92 set status [remote_exec $dest $prog $pargs $inp]
94 if { [lindex $status 0] < 0 } {
95 verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
98 set output [lindex $status 1]
99 set status [lindex $status 0]
101 verbose -log "Executed $prog, status $status" 2
103 verbose -log -- $output 2
105 if { $status == 0 } {
106 return [list "pass" $output]
108 return [list "fail" $output]