1bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson#!/bin/bash -eux
26f3961507e73f90cec665896dece884e86be560aBill Richardson# Copyright 2013 The Chromium OS Authors. All rights reserved.
320807b6158b6a43baf0974bc763890888ba1f841Bill Richardson# Use of this source code is governed by a BSD-style license that can be
420807b6158b6a43baf0974bc763890888ba1f841Bill Richardson# found in the LICENSE file.
520807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
620807b6158b6a43baf0974bc763890888ba1f841Bill Richardsonme=${0##*/}
76f3961507e73f90cec665896dece884e86be560aBill RichardsonTMP="$me.tmp"
820807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
9bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson# Work in scratch directory
10bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsoncd "$OUTDIR"
1120807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
12bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson# Good FMAP
131eae873b6194db25781233d7a4aaee6a34160eecBill Richardson"$FUTILITY" dump_fmap -F "${SCRIPTDIR}/data_fmap.bin"  > "$TMP"
1420807b6158b6a43baf0974bc763890888ba1f841Bill Richardsoncmp "${SCRIPTDIR}/data_fmap_expect_f.txt" "$TMP"
1520807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
1620807b6158b6a43baf0974bc763890888ba1f841Bill Richardson"$FUTILITY" dump_fmap -p "${SCRIPTDIR}/data_fmap.bin"  > "$TMP"
1720807b6158b6a43baf0974bc763890888ba1f841Bill Richardsoncmp "${SCRIPTDIR}/data_fmap_expect_p.txt" "$TMP"
1820807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
1920807b6158b6a43baf0974bc763890888ba1f841Bill Richardson"$FUTILITY" dump_fmap -h "${SCRIPTDIR}/data_fmap.bin"  > "$TMP"
2020807b6158b6a43baf0974bc763890888ba1f841Bill Richardsoncmp "${SCRIPTDIR}/data_fmap_expect_h.txt" "$TMP"
2120807b6158b6a43baf0974bc763890888ba1f841Bill Richardson
226f3961507e73f90cec665896dece884e86be560aBill Richardson
2320807b6158b6a43baf0974bc763890888ba1f841Bill Richardson# This should fail because the input file is truncated and doesn't really
2420807b6158b6a43baf0974bc763890888ba1f841Bill Richardson# contain the stuff that the FMAP claims it does.
256f3961507e73f90cec665896dece884e86be560aBill Richardsonif "$FUTILITY" dump_fmap -x "${SCRIPTDIR}/data_fmap.bin" FMAP; then false; fi
26bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
277ccd9ce48e761b7614d29ff95ef97d0a7dc1d599Bill Richardson# This should fail too
287ccd9ce48e761b7614d29ff95ef97d0a7dc1d599Bill Richardsonif "$FUTILITY" show "${SCRIPTDIR}/data_fmap.bin"; then false; fi
297ccd9ce48e761b7614d29ff95ef97d0a7dc1d599Bill Richardson
30bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson# However, this should work.
31bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson"$FUTILITY" dump_fmap -x "${SCRIPTDIR}/data_fmap.bin" SI_DESC > "$TMP"
32bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsoncmp "${SCRIPTDIR}/data_fmap_expect_x.txt" "$TMP"
33bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
34d5aa5bdb292b64f259f55319fd83bd4a4d548a12Bill Richardson# Redirect dumping to a different place
35d5aa5bdb292b64f259f55319fd83bd4a4d548a12Bill Richardson"$FUTILITY" dump_fmap -x "${SCRIPTDIR}/data_fmap.bin" SI_DESC:FOO > "$TMP"
36d5aa5bdb292b64f259f55319fd83bd4a4d548a12Bill Richardsoncmp "${SCRIPTDIR}/data_fmap_expect_x2.txt" "$TMP"
37d5aa5bdb292b64f259f55319fd83bd4a4d548a12Bill Richardsoncmp SI_DESC FOO
38bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
396f3961507e73f90cec665896dece884e86be560aBill Richardson# This FMAP has problems, and should fail.
406f3961507e73f90cec665896dece884e86be560aBill Richardsonif "$FUTILITY" dump_fmap -h "${SCRIPTDIR}/data_fmap2.bin" > "$TMP"; then false; fi
41bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsoncmp "${SCRIPTDIR}/data_fmap2_expect_h.txt" "$TMP"
42bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
43bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson"$FUTILITY" dump_fmap -hh "${SCRIPTDIR}/data_fmap2.bin" > "$TMP"
44bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsoncmp "${SCRIPTDIR}/data_fmap2_expect_hh.txt" "$TMP"
45bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
46bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson"$FUTILITY" dump_fmap -hhH "${SCRIPTDIR}/data_fmap2.bin" > "$TMP"
47bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsoncmp "${SCRIPTDIR}/data_fmap2_expect_hhH.txt" "$TMP"
48bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardson
49d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson
50d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# cleanup
51d5aa5bdb292b64f259f55319fd83bd4a4d548a12Bill Richardsonrm -f ${TMP}* FMAP SI_DESC FOO
52d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardsonexit 0
53