test_build: Add some simple dummy-flasher tests
Test that an emulated SPI flash can be probed, read, written with
random data and verified. Also test that specifying the chip to
probe works and that we can overwrite the contents with another
set of random data.
Change-Id: I9800c36f10d637dae8f271468fd120f0508487ec
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73573
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/test_build.sh b/test_build.sh
index a63b679..b9af39c 100755
--- a/test_build.sh
+++ b/test_build.sh
@@ -1,5 +1,18 @@
#!/bin/sh
set -e
+TEMP_DIR=$(mktemp -d)
+trap "rm -rf ${TEMP_DIR}" EXIT
+
${MAKECMD:-make} clean
${MAKECMD:-make} -j${CPUS:-$(nproc)} CC="${CC:-ccache cc}" CONFIG_EVERYTHING=yes
+FLASHROM=./flashrom
+
+dd bs=128K count=1 </dev/urandom >${TEMP_DIR}/rand
+${FLASHROM} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -w ${TEMP_DIR}/rand
+${FLASHROM} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -r ${TEMP_DIR}/bak
+cmp ${TEMP_DIR}/rand ${TEMP_DIR}/bak
+
+dd bs=128K count=1 </dev/urandom >${TEMP_DIR}/rand
+${FLASHROM} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -w ${TEMP_DIR}/rand
+${FLASHROM} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -v ${TEMP_DIR}/rand