Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: runtests.sh

Issue 6849042: Introduce crossystem wrapper in SAFT. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/saft.git@master
Patch Set: Do not cache crossystem output. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # A simple script to run SAFT unit tests and possibly start the SAFT. 6 # A simple script to run SAFT unit tests and possibly start the SAFT.
7 # 7 #
8 # The only expected optional command line parameter is the name of the file 8 # The only expected optional command line parameter is the name of the file
9 # containing the firmware image to test. If the parameter is not provided, 9 # containing the firmware image to test. If the parameter is not provided,
10 # SAFT is not started, just the unit tests get to run. 10 # SAFT is not started, just the unit tests get to run.
(...skipping 13 matching lines...) Expand all
24 24
25 # This hack has been borrowed from src/scripts/common.sh 25 # This hack has been borrowed from src/scripts/common.sh
26 enable_rw_mount() { 26 enable_rw_mount() {
27 local rootfs="$1" 27 local rootfs="$1"
28 local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte 28 local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte
29 printf '\000' | 29 printf '\000' |
30 sudo dd of="$rootfs" seek=${ro_compat_offset} \ 30 sudo dd of="$rootfs" seek=${ro_compat_offset} \
31 conv=notrunc count=1 bs=1 31 conv=notrunc count=1 bs=1
32 } 32 }
33 33
34 target_hosted () {
35 local vers_sig='/proc/version_signature'
36 if [ -f "${vers_sig}" ]; then
37 if egrep -iq 'chrom.*os' "${vers_sig}"; then
38 echo '1'
39 return
40 fi
41 fi
42 echo '0'
43 }
44
34 on_removable_device() { 45 on_removable_device() {
35 # Check if the code is running off a removable device or not. 46 # Check if the code is running off a removable device or not.
36 # Print '1' or '0' respectively on the console. 47 # Print '1' or '0' respectively on the console.
37 rootd=$(df "${this_prog}" | grep '^/dev' | awk '{ print $1 }') 48 rootd=$(df "${this_prog}" | grep '^/dev' | awk '{ print $1 }')
38 if [ "${rootd}" == '/dev/root' ]; then 49 if [ "${rootd}" == '/dev/root' ]; then
39 rootd=$(rootdev -s) 50 rootd=$(rootdev -s)
40 fi 51 fi
41 blockd=$(echo "${rootd}" | sed 's|.*/\([^/0-9]\+\)[0-9]\+|\1|') 52 blockd=$(echo "${rootd}" | sed 's|.*/\([^/0-9]\+\)[0-9]\+|\1|')
42 removable=$(cat /sys/block/"${blockd}"/removable) 53 removable="/sys/block/"${blockd}"/removable"
43 echo "${removable}" 54 if [ -f "${removable}" ]; then
55 cat "${removable}"
56 else
57 echo '0'
58 fi
44 } 59 }
45 60
46 move_to_removable_device() { 61 move_to_removable_device() {
47 # Move ourselves to the removable device and run off it. 62 # Move ourselves to the removable device and run off it.
48 63
49 # For simplicity, hardcode the removable device to be /dev/sdb 64 # For simplicity, hardcode the removable device to be /dev/sdb
50 flash_device="${DEFAULT_FLASH_DEVICE}" 65 flash_device="${DEFAULT_FLASH_DEVICE}"
51 fname="/sys/block/${flash_device}/removable" 66 fname="/sys/block/${flash_device}/removable"
52 67
53 # Confirm SDB exists and is indeed removable. 68 # Confirm SDB exists and is indeed removable.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 108 }
94 109
95 configure_gpt_settings() { 110 configure_gpt_settings() {
96 # Let's keep it simple for now, partition 2 is the one to boot. 111 # Let's keep it simple for now, partition 2 is the one to boot.
97 cgpt add -i 2 -T 5 -P 9 -S 1 /dev/sda 112 cgpt add -i 2 -T 5 -P 9 -S 1 /dev/sda
98 cgpt add -i 4 -T 5 -P 5 -S 1 /dev/sda 113 cgpt add -i 4 -T 5 -P 5 -S 1 /dev/sda
99 } 114 }
100 115
101 run_tests() { 116 run_tests() {
102 ./test_chromeos_interface.py 117 ./test_chromeos_interface.py
118 if [ "$(target_hosted)" == "0" ]; then
119 return
120 fi
103 ./test_flashrom_handler.py "${new_firmware}" 121 ./test_flashrom_handler.py "${new_firmware}"
104 ./test_saft_utility.py 122 ./test_saft_utility.py
105 ./test_kernel_handler.py 123 ./test_kernel_handler.py
106 ./test_cgpt_handler.py 124 ./test_cgpt_handler.py
107 ./test_tpm_handler.py 125 ./test_tpm_handler.py
108 ./test_cgpt_state.py 126 ./test_cgpt_state.py
109 127
110 if [ -n "${new_firmware}" ]; then 128 if [ -n "${new_firmware}" ]; then
111 configure_gpt_settings 129 configure_gpt_settings
112 ./saft_utility.py --ima="${new_firmware}" 130 ./saft_utility.py --ima="${new_firmware}"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 s/dm="[^"]\+" //' > "${new_cmd_line_file}" 166 s/dm="[^"]\+" //' > "${new_cmd_line_file}"
149 vbutil_kernel --repack "${other_kern_file}.new" \ 167 vbutil_kernel --repack "${other_kern_file}.new" \
150 --config "${new_cmd_line_file}" \ 168 --config "${new_cmd_line_file}" \
151 --signprivate recovery_kernel_data_key.vbprivk \ 169 --signprivate recovery_kernel_data_key.vbprivk \
152 --oldblob "${other_kern_file}" 170 --oldblob "${other_kern_file}"
153 dd if="${other_kern_file}.new" of="${flash_kernel_dev}" bs=4M 171 dd if="${other_kern_file}.new" of="${flash_kernel_dev}" bs=4M
154 fi 172 fi
155 } 173 }
156 174
157 cd $(dirname ${this_prog}) 175 cd $(dirname ${this_prog})
158 if [ "$(on_removable_device)" == "0" ]; then 176 if [ "$(on_removable_device)" == "0" -a "$(target_hosted)" == "1" ]; then
159 check_and_set_saft_environment 177 check_and_set_saft_environment
160 move_to_removable_device 178 move_to_removable_device
161 exit 0 179 exit 0
162 fi 180 fi
163 181
164 run_tests 182 run_tests
OLDNEW
« chromeos_interface.py ('K') | « chromeos_interface.py ('k') | test_chromeos_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698