mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
qemuxml2argvtest: Test localtime clock basis
When trying to introduce a test for previous patch, I've noticed that the command line is constructed using current time. This won't work in our test suite (unless you guys wants to set a specific time prior to each test run :) ). Therefore we need to mock calls to time(2) to return the same value every time it's called. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
51bea5df5d
commit
e505db0f6c
@ -325,6 +325,7 @@ test_libraries = libshunload.la \
|
|||||||
virnetserverclientmock.la \
|
virnetserverclientmock.la \
|
||||||
vircgroupmock.la \
|
vircgroupmock.la \
|
||||||
virpcimock.la \
|
virpcimock.la \
|
||||||
|
qemuxml2argvmock.la \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
if WITH_QEMU
|
if WITH_QEMU
|
||||||
test_libraries += libqemumonitortestutils.la
|
test_libraries += libqemumonitortestutils.la
|
||||||
@ -441,6 +442,12 @@ qemuxml2argvtest_SOURCES = \
|
|||||||
testutils.c testutils.h
|
testutils.c testutils.h
|
||||||
qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS)
|
qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS)
|
||||||
|
|
||||||
|
qemuxml2argvmock_la_SOURCES = \
|
||||||
|
qemuxml2argvmock.c
|
||||||
|
qemuxml2argvmock_la_CFLAGS = $(AM_CFLAGS)
|
||||||
|
qemuxml2argvmock_la_LDFLAGS = -module -avoid-version \
|
||||||
|
-rpath /evil/libtool/hack/to/force/shared/lib/creation
|
||||||
|
|
||||||
qemuxml2xmltest_SOURCES = \
|
qemuxml2xmltest_SOURCES = \
|
||||||
qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
|
qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
|
||||||
testutils.c testutils.h
|
testutils.c testutils.h
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
|
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic \
|
||||||
|
-monitor unix:/tmp/test-monitor,server,nowait -rtc base=2009-02-14T01:31:30 \
|
||||||
|
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net none -serial none \
|
||||||
|
-parallel none
|
@ -0,0 +1,28 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>1c15a1f6-f4f0-4d3c-9002-667ddb458736</uuid>
|
||||||
|
<memory unit='KiB'>219100</memory>
|
||||||
|
<currentMemory unit='KiB'>219100</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='variable' adjustment='3600' basis='localtime'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
/usr/bin/qemu -S -M \
|
/usr/bin/qemu -S -M \
|
||||||
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -rtc \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -rtc \
|
||||||
base=2010-2-2T18:22:10 -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net none \
|
base=2009-02-15T09:49:06 -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
|
||||||
-serial none -parallel none
|
-net none -serial none -parallel none
|
||||||
|
37
tests/qemuxml2argvmock.c
Normal file
37
tests/qemuxml2argvmock.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see
|
||||||
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
# include "internal.h"
|
||||||
|
# include <time.h>
|
||||||
|
|
||||||
|
time_t time(time_t *t)
|
||||||
|
{
|
||||||
|
const time_t ret = 1234567890;
|
||||||
|
if (t)
|
||||||
|
*t = ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Nothing to override on non-__linux__ platforms */
|
||||||
|
#endif
|
@ -618,10 +618,8 @@ mymain(void)
|
|||||||
DO_TEST("bios", QEMU_CAPS_DEVICE, QEMU_CAPS_SGA);
|
DO_TEST("bios", QEMU_CAPS_DEVICE, QEMU_CAPS_SGA);
|
||||||
DO_TEST("clock-utc", NONE);
|
DO_TEST("clock-utc", NONE);
|
||||||
DO_TEST("clock-localtime", NONE);
|
DO_TEST("clock-localtime", NONE);
|
||||||
/*
|
DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
|
||||||
* Can't be enabled since the absolute timestamp changes every time
|
|
||||||
DO_TEST("clock-variable", QEMU_CAPS_RTC);
|
DO_TEST("clock-variable", QEMU_CAPS_RTC);
|
||||||
*/
|
|
||||||
DO_TEST("clock-france", QEMU_CAPS_RTC);
|
DO_TEST("clock-france", QEMU_CAPS_RTC);
|
||||||
DO_TEST("clock-hpet-off", QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET,
|
DO_TEST("clock-hpet-off", QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET,
|
||||||
QEMU_CAPS_NO_KVM_PIT);
|
QEMU_CAPS_NO_KVM_PIT);
|
||||||
@ -1335,7 +1333,7 @@ mymain(void)
|
|||||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRT_TEST_MAIN(mymain)
|
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2argvmock.so")
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user