1#!/bin/sh 2 3# This script is used to generate souce files containing test 4# data for the ramdisk_extractor unit tests. 5 6set -e 7 8export LANG=C 9export LC_ALL=C 10 11PROGNAME=$(basename "$0") 12DATE=$(date +%Y-%m-%d) 13 14# $1: Root directory 15create_ramdisk_header_from () { 16 local FILE_LIST 17 FILE_LIST=$(cd $2 && find . -type f 2>/dev/null | sed -e 's|^./||g') 18 echo "$FILE_LIST" | cpio --create --format=newc --quiet | gzip -9c | xxd -i - 19} 20 21TMPDIR=/tmp/$USER-ramdisk-test-data 22rm -rf $TMPDIR/dir1 && mkdir -p $TMPDIR/dir1 23cd $TMPDIR/dir1 24cat > foo <<EOF 25Hello World! 26EOF 27cat > bar2 <<EOF 28La vie est un long fleuve tranquille 29EOF 30 31echo "/* Auto-generated by $PROGNAME on $DATE - DO NOT EDIT!! */" 32echo "" 33echo "static const unsigned char kTestRamdiskImage[] = {" 34create_ramdisk_header_from $TMPDIR/ramdisk1.img.h $TMPDIR/dir1 35echo "};" 36echo "" 37echo "static const size_t kTestRamdiskImageSize = sizeof(kTestRamdiskImage);" 38echo "" 39 40