2 # Performs various tests and analysises on images
4 # Copyright (C) 2007, 2008 Koen Kooi <koen@openembedded.org>
6 # The current features are:
7 # 1) dump a list of installed packages
8 # 2) dump a list of sizes of installed packages
9 # 3) dependency graphs of installed packages
12 # * http://dominion.thruhere.net/koen/cms/the-testlab-strikes-again
13 # * http://dominion.thruhere.net/koen/cms/package-relations-inside-images
17 # * log information to a server for safekeeping
18 # * use mtn certs to record this info into the scm
19 # * add test suite to run on the target device
22 # Needs 'dot', 'opkg-cl'
25 if [ -e ${IMAGE_ROOTFS}/etc/opkg ] && [ "${ONLINE_PACKAGE_MANAGEMENT}" = "full" ] ; then
27 IPKG_TMP_DIR="${IMAGE_ROOTFS}-tmp"
28 IPKG_ARGS="-f ${STAGING_ETCDIR_NATIVE}/opkg.conf -o ${IMAGE_ROOTFS} -t ${IPKG_TMP_DIR}"
30 TESTLAB_DIR="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}-testlab"
31 mkdir -p ${TESTLAB_DIR}/
32 mkdir -p ${IPKG_TMP_DIR}/
33 ls -laR ${IMAGE_ROOTFS} > ${TESTLAB_DIR}/files-in-image.txt
35 echo > ${TESTLAB_DIR}/installed-packages.txt
36 echo -e "digraph depends {\n node [shape=plaintext]" > ${TESTLAB_DIR}/depends.dot
38 for pkg in $(opkg-cl ${IPKG_ARGS} list_installed | awk '{print $1}') ; do
39 opkg-cl ${IPKG_ARGS} info $pkg | awk '/Package/ {printf $2"_"} /Version/ {printf $2"_"} /Archi/ {print $2".ipk"}' >> ${TESTLAB_DIR}/installed-packages.txt
41 for depends in $(opkg-cl ${IPKG_ARGS} info $pkg | grep Depends) ; do
42 echo "$pkg OPP $depends;" | grep -v "(" | grep -v ")" | grep -v Depends | sed -e 's:,::g' -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' |sed 's:OPP:->:g' >> ${TESTLAB_DIR}/depends.dot
45 for recommends in $(opkg-cl ${IPKG_ARGS} info $pkg | grep Recom) ; do
46 echo "$pkg OPP $recommends [style=dotted];" | grep -v "(" | grep -v ")" | grep -v Recom | sed -e 's:,::g' -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' |sed 's:OPP:->:g' >> ${TESTLAB_DIR}/depends.dot
50 echo "}" >> ${TESTLAB_DIR}/depends.dot
51 rm -rf ${IPKG_TMP_DIR}
53 grep -v kernel_2 ${TESTLAB_DIR}/depends.dot | grep -v kernel_image > ${TESTLAB_DIR}/depends-nokernel.dot
54 grep -v libc6 ${TESTLAB_DIR}/depends-nokernel.dot | grep -v libgcc > ${TESTLAB_DIR}/depends-nokernel-nolibc.dot
55 grep -v update_ ${TESTLAB_DIR}/depends-nokernel-nolibc.dot > ${TESTLAB_DIR}/depends-nokernel-nolibc-noupdate.dot
56 grep -v kernel_module ${TESTLAB_DIR}/depends-nokernel-nolibc-noupdate.dot > ${TESTLAB_DIR}/depends-nokernel-nolibc-noupdate-nomodules.dot
58 #dot has some library troubles when run under fakeroot, uncomment at your own risk
59 #dot -Tpng -o ${TESTLAB_DIR}/image-dependencies.png ${TESTLAB_DIR}/depends.dot
60 #dot -Tpng -o ${TESTLAB_DIR}/image-dependencies-nokernel-nolibc.png ${TESTLAB_DIR}/depends-nokernel-nolibc.dot
61 #dot -Tpng -o ${TESTLAB_DIR}/image-dependencies-nokernel-nolibc-noupdate.png ${TESTLAB_DIR}/depends-nokernel-nolibc-noupdate.dot
62 #dot -Tpng -o ${TESTLAB_DIR}/image-dependencies-nokernel-nolibc-noupdate-nomodules.png ${TESTLAB_DIR}/depends-nokernel-nolibc-noupdate-nomodules.dot
64 for file in $(cat ${TESTLAB_DIR}/installed-packages.txt) ; do
65 du -k $(find ${DEPLOY_DIR_IPK} -name "$file") | head -n1
66 done | grep "\.ipk" | sed -e s:${DEPLOY_DIR_IPK}::g | sort -n -r | awk '{print $1 "\tKiB " $2}' > ${TESTLAB_DIR}/installed-package-sizes.txt
70 IMAGE_POSTPROCESS_COMMAND += " do_testlab ;"