aboutsummaryrefslogtreecommitdiff
path: root/dejagnu/boards/android-adb.exp
blob: 2efd50091874696c668f23106476a1cb328ee6de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
load_generic_config "adb"

# We need this for find_gcc and *_include_flags/*_link_flags.
load_base_board_description "adb"

set_board_info compiler  "[find_gcc]"

# We need -mandroid.
set_board_info cflags  "-mandroid"

# Currently the dynamic linker does not support weak-references in
# shared libraries.  So we need to workaround using -static
set_board_info ldflags  "-mandroid -static"

#
# load PROG to DEST and run it with ARGS using adb
#
proc adb_load { dest prog args } {
    # /sqlite_stmt_journals uses tmpfs.  So it is the default place to run
    # tests to avoid excessive wear of flash.
    set android_tmp_dir "/sqlite_stmt_journals"

    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 ![file exists $prog] then {
	# We call both here because this should never happen.
	perror "$prog does not exist in standard_load."
	verbose -log "$prog does not exist." 3
	return "untested"
    }

    if [is_remote $dest] {
	set remotefile "$android_tmp_dir/[file tail $prog].[pid]"
	set remotefile [remote_download $dest $prog $remotefile]
	if { $remotefile == "" } {
	    verbose -log "Download of $prog to [board_info $dest name] failed." 3
	    return "unresolved"
	}
	if [board_info $dest exists remote_link] {
	    if [[board_info $dest remote_link] $remotefile] {
		verbose -log "Couldn't do remote link"
		# Can't use remote_file delete since /system/bin/rm does not
		# support -f on Android.
		remote_exec $dest rm $remotefile
		return "unresolved"
	    }
	}
	set status [remote_exec $dest $remotefile $pargs $inp]
	remote_exec $dest rm $remotefile
    } else {
	set status [remote_exec $dest $prog $pargs $inp]
    }
    if { [lindex $status 0] < 0 } {
	verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
	return "unresolved"
    }
    set output [lindex $status 1]
    set status [lindex $status 0]

    verbose -log "Executed $prog, status $status" 2
    if ![string match "" $output] {
	verbose -log -- "$output" 2
    }
    if { $status == 0 } {
	return [list "pass" $output]
    } else {
	return [list "fail" $output]
    }
}