Lines Matching +full:region +full:- +full:testing
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 # Stuff obtained from command-line
52 SCRIPT_LOGFILE="flashrom-test_script_output.txt"
60 # Region modes
73 # Remote testing options
79 SSH_CMD="ssh $REMOTE_PORT_OPTION root@${REMOTE_HOST} command -v"
86 TEST_SCRIPT_PATH="util/testing/test_v2.1.sh"
90 if [ "$(id -u)" -ne "0" ]; then
102 -b, --backup-image <path>
103 Backup image to write unconditionally at end of testing.
104 -h, --help
106 -l, --layout-file <path>
108 -m, --mode <arg>
109 Region access mode (clobber, descriptor, flashmap, layout).
110 -n, --new <path>
112 -o, --old <path>
114 -p, --primary-programmer <parameters>
116 -r, --remote-host <host>
118 -s, --secondary-programmer <parameters>
120 -t, --type <arg>
122 -u, --upload-results
124 -v, --voltage
128 --custom-hooks <filename>
130 --descriptor-region <name>
131 Specify region to use in descriptor mode (default: $DESCRIPTOR_REGION)
132 --flashmap-region <name>
133 Specify region to use in flashmap mode (default: $FLASHMAP_REGION)
134 --layout-region <name>
135 Specify region to use in layout mode (default: $LAYOUT_REGION)
136 --local-flashrom <path>
139 --no-clean
141 --skip-consistency-check
143 --small-region
146 --ssh-port <port>
154 getopt -T
155 if [ $? -ne 4 ]; then
156 printf "GNU-compatible getopt(1) required.\n"
160 LONGOPTS="backup-image:,help,,new:,old:,remote-host:,upload-results:"
161 LONGOPTS="${LONGOPTS},primary-programmer:,secondary-programmer:,local-flashrom:"
162 LONGOPTS="${LONGOPTS},custom-hooks:,mode:,skip-consistency-check,small-region"
164 LONGOPTS="${LONGOPTS},layout-file:,descriptor-region:,flashmap-region:,layout-region:"
165 LONGOPTS="${LONGOPTS},no-clean"
166 LONGOPTS="${LONGOPTS},ssh-port:"
168 ARGS=$(getopt -o b:hl:m:n:o:p:r:s:t:u -l "$LONGOPTS" -n "$0" -- "$@");
170 eval set -- "$ARGS"
174 -b|--backup-image)
178 -h|--help)
182 -l|--layout-file)
186 -m|--mode)
201 -n|--new)
205 -o|--old)
209 -p|--primary_programmer)
211 PRIMARY_OPTS="-p $1"
213 -s|--secondary_programmer)
215 SECONDARY_OPTS="-p $1"
217 -t|--type)
228 -r|--remote-host)
233 -u|--upload-results)
236 -v|--voltage)
242 --custom-hooks)
246 --descriptor-region)
250 --flashmap-region)
254 --layout-region)
258 --local-flashrom)
262 --no-clean)
265 --skip-consistency-check)
268 --small-region)
272 # Remote testing options
273 --ssh-port)
275 REMOTE_PORT_OPTION="-p $1"
279 --)
281 if [ -n "$*" ]; then
282 printf "Non-option parameters detected: '$*'\n"
295 if [ $UPLOAD_RESULTS -eq 1 ]; then
306 . "$(pwd)/util/testing/cmd.sh"
317 LOCAL_TMPDIR=$(mktemp -d --tmpdir flashrom_test.XXXXXXXX)
318 if [ $? -ne 0 ] ; then
324 if [ $DO_REMOTE -eq 1 ]; then
325 REMOTE_TMPDIR=$(ssh root@${REMOTE_HOST} mktemp -d --tmpdir flashrom_test.XXXXXXXX)
326 if [ $? -ne 0 ] ; then
333 if [ $DO_REMOTE -eq 0 ]; then
340 # Test command-line validity.
342 if [ $TEST_TYPE -eq $TEST_TYPE_UNKNOWN ]; then
343 printf "Must specify a test type (-t/--type).\n"
345 elif [ $TEST_TYPE -eq $TEST_TYPE_SINGLE ]; then
346 if [ $REGION_MODE -eq $REGION_MODE_UNKNOWN ]; then
347 printf "Must specify a region access mode (-m/--mode).\n"
349 elif [ $REGION_MODE -eq $REGION_MODE_LAYOUT ]; then
350 if [ -z "$LAYOUT_FILE" ]; then
356 if [ $? -ne 0 ]; then
357 if [ $DO_REMOTE -eq 1 ]; then
366 if [ $DO_REMOTE -eq 1 ]; then
374 if [ -n "$VOLTAGE" ]; then
375 echo "$VOLTAGE" | grep -q '[^0-9]'
376 if [ $? -ne 1 ]; then
382 if [ $DO_REMOTE -eq 1 ]; then
385 if [ $? -ne 0 ]; then
394 if [ $DO_REMOTE -eq 1 ] && [ -n "$SECONDARY_OPTS" ]; then
395 if [ -z "$LOCAL_FLASHROM" ]; then
399 if [ ! -e "$LOCAL_FLASHROM" ]; then
412 if [ ! -e "/dev/urandom" ]; then
417 if [ ! -e "/dev/zero" ]; then
427 if [ ! -e "$TEST_SCRIPT_PATH" ] ; then
432 if [ -z "$OLD_FLASHROM" ]; then
433 if [ $DO_REMOTE -eq 1 ]; then
439 test_cmd $DO_REMOTE "$OLD_FLASHROM --help" $NONFATAL
440 if [ $? -ne 0 ]; then
448 printf "$1" | tee -a "${LOCAL_TMPDIR}/${LOGS}/${SCRIPT_LOGFILE}"
474 local logfile="flashrom-${3}.txt"
477 if [ $1 -eq $REMOTE ]; then
483 scmd $1 "$2 -o ${tmpdir}/${LOGS}/${logfile}"; rc=$?
485 if [ $rc -eq $EXIT_SUCCESS ]; then
486 scmd $1 "rm -f ${tmpdir}/${LOGS}/${logfile}"
489 if [ $1 -eq $REMOTE ]; then
498 if [ -z "$BACKUP_IMAGE" ]; then
500 if [ $DO_REMOTE -eq 1 ]; then
507 flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS -r $BACKUP_IMAGE" "read_backup"
509 if [ $? -ne 0 ]; then
514 if [ $DO_REMOTE -eq 1 ]; then
518 if [ $DO_REMOTE -eq 1 ]; then
526 if [ -z "$NEW_FLASHROM" ] ; then
527 if [ -x "flashrom" ]; then
538 if [ $DO_REMOTE -eq 1 ]; then
549 cmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS --flash-size" "${LOCAL_TMPDIR}/old_chip_size.txt.orig"
550 cmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS --flash-size" "${LOCAL_TMPDIR}/new_chip_size.txt.orig"
552 tail -n 1 "${LOCAL_TMPDIR}/old_chip_size.txt.orig" > "${LOCAL_TMPDIR}/old_chip_size.txt"
553 tail -n 1 "${LOCAL_TMPDIR}/new_chip_size.txt.orig" > "${LOCAL_TMPDIR}/new_chip_size.txt"
558 if [ $CHIP_SIZE -ne $tmp ]; then
574 if [ $NO_CLEAN -eq 1 ]; then
579 rm -rf "$LOCAL_TMPDIR"
580 if [ -n "$REMOTE_HOST" ]; then
581 ssh root@${REMOTE_HOST} rm -rf "$REMOTE_TMPDIR"
598 flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS -w $BACKUP_IMAGE" "write_backup"
599 if [ $? -ne 0 ]; then
604 # Read a region twice and compare results
605 # $1: address of region (in bytes)
606 # $2: length of region (in bytes)
616 printf "%06x:%06x region\n" $1 $(($1 + $2 - 1)) > "${LOCAL_TMPDIR}/${layout}"
617 if [ $DO_REMOTE -eq 1 ]; then copy_to_remote "$layout" ; fi
619 …flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS -l ${TMPDIR}/${layout} -i region -r ${cm…
621 …flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS -l ${TMPDIR}/${layout} -i region -r ${cm…
623 if [ $? -ne 0 ]; then
624 test_fail "Double-read test failed, aborting."
630 # FIXME: Hack due to lack of region-sized file handling.
631 PARTIAL_WRITE_TEST_REGION_BASE_OFFSET=-1
647 …while [ $(($(($pattern_offset_kb + $pattern_size_kb)) * $K)) -lt $PARTIAL_WRITE_TEST_REGION_SIZE ]…
653 # Regional partial write test. Given a region name, this will write patterns
657 # must test for both. For simplicity, we'll assume the region size is
660 # $1: Region name
663 local opts="--noverify-all"
670 # FIXME: Hack due to lack of region-sized file handling.
671 if [ $((PARTIAL_WRITE_TEST_REGION_SIZE)) -eq 0 ]; then
675 if [ $((PARTIAL_WRITE_TEST_REGION_BASE_OFFSET)) -lt 0 ]; then
680 if [ $TEST_TYPE -eq $TEST_TYPE_SINGLE ]; then
681 if [ $REGION_MODE -eq $REGION_MODE_LAYOUT ]; then
682 opts="$opts -l $LAYOUT_FILE"
684 elif [ $REGION_MODE -eq $REGION_MODE_CLOBBER ]; then
685 printf "000000:%06x RW\n" $(($CHIP_SIZE - 1)) > "${LOCAL_TMPDIR}/clobber_mode_layout.txt"
686 if [ $DO_REMOTE -eq 1 ]; then
689 secondary_opts="$opts -l ${LOCAL_TMPDIR}/clobber_mode_layout.txt"
690 opts="$opts -l ${TMPDIR}/clobber_mode_layout.txt"
694 if [ $SMALL_REGION -eq 1 ]; then
702 print_and_log "Doing region-based partial write test on region \"$region_name\"\n"
703 …flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS $opts -i ${region_name} -r ${TMPDIR}/${r…
704 if [ $DO_REMOTE -eq 1 ]; then
708 if [ $(($PARTIAL_WRITE_TEST_REGION_SIZE % $(($PARTIAL_WRITE_TEST_ALIGN_SIZE_KB)))) -ne 0 ]; then
709 print_and_log "Region $region_name is not aligned to $PARTIAL_WRITE_TEST_ALIGN_SIZE_KB\n"
714 # Clobber region with random content first. Then do writes using the
716 # 0-2K : 0x00 (\000) Partial 4KB sector, lower half
717 # 2K-6K : 0x11 (\021) Crossover 4KB sector boundary
718 # 6K-8K : 0x22 (\042) Partial 4KB sector, upper half
719 # 8K-16K : 0x33 (\063) Full 4KB sectors
721 # Repeat the above sequence for 64KB-aligned sizes
722 # 0-32K : 0x44 (\104) Partial 64KB block, lower half
723 # 32K-96K : 0x55 (\125) Crossover 64KB block boundary
724 # 96K-128K : 0x66 (\146) Partial 64KB block, upper half
725 # 128K-256K : 0x77 (\167) Full 64KB blocks
731 # 0-2K : 0x00 (\000) Partial 4KB sector, lower half
736 # 2K-6K : 0x11 (\021) Crossover 4KB sector boundary
740 # 6K-8K : 0x22 (\042) Partial 4KB sector, upper half
744 # 8K-16K : 0x33 (\063) Full 4KB sectors
749 if [ $DO_REMOTE -eq 1 ]; then
753 …flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS $opts -i ${region_name} -w ${TMPDIR}/${f…
754 if [ $? -ne 0 ]; then
758 …flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS $opts -i ${region_name} -v ${TMPDIR}/${f…
759 if [ $? -ne 0 ]; then
763 if [ -n "$SECONDARY_OPTS" ]; then
764 …flashrom_log_scmd $LOCAL "$LOCAL_FLASHROM $SECONDARY_OPTS $secondary_opts -i ${region_name} -v ${L…
765 if [ $? -ne 0 ]; then
770 print_and_log "\tWrote $filename to $region_name region successfully.\n"
773 if [ $SMALL_REGION -eq 1 ]; then
785 # 0-32K : 0x44 (\104) Partial 64KB block, lower half
790 # 32K-96K : 0x55 (\125) Crossover 64KB block boundary
794 # 96K-128K : 0x66 (\146) Partial 64KB block, upper half
798 # 128K-256K : 0x77 (\167) Full 64KB blocks
803 if [ $DO_REMOTE -eq 1 ]; then
807 …flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS $opts -i ${region_name} -w ${TMPDIR}/${f…
808 if [ $? -ne 0 ]; then
812 …flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS $opts -i ${region_name} -v ${TMPDIR}/${f…
813 if [ $? -ne 0 ]; then
817 if [ -n "$SECONDARY_OPTS" ]; then
818 …flashrom_log_scmd $LOCAL "$LOCAL_FLASHROM $SECONDARY_OPTS $secondary_opts -i ${region_name} -v ${L…
819 if [ $? -ne 0 ]; then
824 print_and_log "\tWrote $filename to $region_name region successfully.\n"
833 if [ $? -ne 0 ]; then
838 if [ $SKIP_CONSISTENCY_CHECK -eq 0 ]; then
842 if [ $TEST_TYPE -eq $TEST_TYPE_SINGLE ]; then
843 if [ $REGION_MODE -eq $REGION_MODE_CLOBBER ]; then
848 flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS -w $random_file" "clobber_write"
849 flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS -r $cmp_file" "clobber_verify"
851 if [ $? -ne 0 ]; then
855 elif [ $REGION_MODE -eq $REGION_MODE_DESCRIPTOR ]; then
856 # FIXME: Need region-sized file handling or some way to get region info
857 print_and_log "Currently broken due to lack of region-sized file handling."
859 elif [ $REGION_MODE -eq $REGION_MODE_FLASHMAP ]; then
860 # FIXME: Need region-sized file handling or some way to get region info
861 print_and_log "Currently broken due to lack of region-sized file handling."
863 elif [ $REGION_MODE -eq $REGION_MODE_LAYOUT ]; then
870 # Look for a region name with any amount of leading whitespace
872 rw_layout=$(grep "\s${LAYOUT_REGION}$" "${LOCAL_TMPDIR}/$(basename $LAYOUT_FILE)" | head -n 1)
873 if [ -z "$rw_layout" ]; then
874 print_and_log "No region matching \"${LAYOUT_REGION}\" found layout file \"${LAYOUT_FILE}\"\n"
878 addr="0x$(echo "$rw_layout" | cut -d ' ' -f -1 | awk -F ':' '{ print $1 }')"
879 end="0x$(echo "$rw_layout" | cut -d ' ' -f -1 | awk -F ':' '{ print $2 }')"
880 size="$(($end - $addr + 1))"
883 # FIXME: Hack to make this work without region-sized file handling.
887 print_and_log "\"$LAYOUT_REGION\" region address: ${addr}, size: $size_kb KiB\n"
889 if [ $? -ne 0 ]; then
894 elif [ $TEST_TYPE -eq $TEST_TYPE_ENDURANCE ]; then
900 # i.e. { time $NEW_FLASHROM $PRIMARY_OPTS -w $random_file ; } 2>&1 | grep user | cut -f2
903 while [ $terminate -eq 0 ]
908 …flashrom_log_scmd $DO_REMOTE "$NEW_FLASHROM $PRIMARY_OPTS -w $random_file" "endurance_write_${iter…
909 …flashrom_log_scmd $DO_REMOTE "$OLD_FLASHROM $PRIMARY_OPTS -r $cmp_file" "endurance_verify_${iterat…
911 if [ $? -ne 0 ]; then
914 scmd $DO_REMOTE "rm -f $cmp_file $random_file"
922 # TODO - Print performance metrics?
928 if [ $RC -eq 0 ]; then