[Ovirt-devel] [PATCH node-image] Moved all temporary files into a single work directory to clean up.
Mike Burns
mburns at redhat.com
Tue Jul 21 17:39:15 UTC 2009
On Tue, Jul 21, 2009 at 12:13:19PM -0400, Darryl L. Pierce wrote:
> All temporary files are kept in a single directory. At the end of the
> autotests that one directory is deleted.
>
> Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
> ---
> autotest.sh | 20 +++++++++++---------
> 1 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/autotest.sh b/autotest.sh
> index c9f8a2d..d658cf3 100755
> --- a/autotest.sh
> +++ b/autotest.sh
> @@ -40,6 +40,7 @@
> # an ISO file.
>
> ME=$(basename "$0")
> +WORKDIR=$(mktemp -d)
> warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
> die() { warn "$*"; exit 1; }
> debug() { if $debugging; then log "[DEBUG] %s" "$*"; fi }
> @@ -140,7 +141,7 @@ start_dnsmasq () {
> --dhcp-boot=tftpboot/pxelinux.0
> --enable-tftp
> --tftp-root=${tftproot}
> - --log-facility=/tmp/dnsmasq-${nodename}.log
> + --log-facility=$WORKDIR/dnsmasq-${nodename}.log
> --log-queries
> --log-dhcp
> --pid-file=${pidfile}"
> @@ -180,7 +181,7 @@ start_networking () {
> local workdir=$5
> local definition=""
> local network=$NETWORK
> - local xmlfile=$(mktemp)
> + local xmlfile=$WORKDIR/$nodename-$ifacename.xml
>
> debug "start_networking ()"
> for var in nodename ifacename use_dhcp start_dnsmasq workdir network xmlfile; do
> @@ -363,7 +364,7 @@ configure_node () {
> local hdfile=""
> local cdfile=$5
> local args=$6
> - local nodefile=$(mktemp)
> + local nodefile=$WORKDIR/$nodename.xml
>
> if [ -z "${boot_device}" ]; then boot_device="hd"; fi
> if [ -z "${memory}" ]; then memory="524288"; fi
> @@ -375,7 +376,7 @@ configure_node () {
>
> # create the hard disk file
> if [ -n "${hdsize}" ]; then
> - hdfile=$(mktemp)
> + hdfile=$WORKDIR/$nodename-hd.img
> create_hard_disk $hdfile $hdsize
> fi
>
> @@ -457,7 +458,7 @@ substitute_boot_device () {
> local nodename=$1
> local old_device=$2
> local new_device=$3
> - local new_node_file=$(mktemp)
> + local new_node_file=$WORKDIR/$nodename-new.xml
>
> if [ -n "${nodename}" ]; then
> local xml=$(sudo virsh dumpxml $nodename | sed "s/boot dev='"${old_device}"'/boot dev='"${new_device}"'/")
> @@ -471,7 +472,7 @@ substitute_boot_device () {
> add_test "test_stateless_pxe"
> test_stateless_pxe () {
> local nodename="${vm_prefix}-stateless-pxe"
> - local workdir=$(mktemp -d)
> + local workdir=$WORKDIR
>
> start_networking $nodename $IFACE_NAME false true $workdir
>
> @@ -513,7 +514,7 @@ exit 3'
> add_test "test_stateless_pxe_with_nohd"
> test_stateless_pxe_with_nohd () {
> local nodename="${vm_prefix}-stateless-pxe-nohd"
> - local workdir=$(mktemp -d)
> + local workdir=$WORKDIR
>
> start_networking $nodename $IFACE_NAME false true $workdir
>
> @@ -556,7 +557,7 @@ exit 3'
> add_test "test_stateful_pxe"
> test_stateful_pxe () {
> local nodename="${vm_prefix}-stateful-pxe"
> - local workdir=$(mktemp -d)
> + local workdir=$WORKDIR
> local ipaddress=${NODE_ADDRESS}
>
> for var in nodename workdir ipaddress; do
> @@ -683,6 +684,7 @@ cleanup_after_testing () {
> destroy_node $vm
> done
> stop_networking
> + rm -rf $WORKDIR
> }
>
> # check commandline options
> @@ -715,7 +717,7 @@ set +u
> if [ $# -gt 0 -a -n "$1" ]; then RESULTS=$1; else RESULTS=autotest.log; fi
> set -u
>
> -result_file=$(mktemp)
> +result_file=$WORKDIR/results.log
> debug "result_file=${result_file}"
>
> log "Logging results to file: ${RESULTS}"
> --
> 1.6.2.5
>
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel
>
Only comment is that you might want to report as a debug statement where the working directory is located in the setup_for_testing function.
Other than that, ACK
Mike
More information about the ovirt-devel
mailing list