Patchwork [RFC,v1,4/4] qtest: build qtest and add -test <testname> cmdline opt

login
register
mail settings
Submitter Michael Roth
Date Feb. 4, 2011, 1:49 p.m.
Message ID <1296827392-1291-5-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/81889/
State New
Headers show

Comments

Michael Roth - Feb. 4, 2011, 1:49 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 Makefile.objs   |    4 +++-
 Makefile.target |    1 +
 configure       |   20 ++++++++++++++++++++
 qemu-options.hx |    9 +++++++++
 vl.c            |   11 +++++++++++
 5 files changed, 44 insertions(+), 1 deletions(-)

Patch

diff --git a/Makefile.objs b/Makefile.objs
index f1c7bfe..ec0cd91 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -139,6 +139,9 @@  ui-obj-y += vnc-jobs-sync.o
 endif
 common-obj-y += $(addprefix ui/, $(ui-obj-y))
 
+qtest-obj-y += qtest.o
+common-obj-$(CONFIG_QTEST) += $(addprefix qtest/, $(qtest-obj-y))
+
 common-obj-y += iov.o acl.o
 common-obj-$(CONFIG_THREAD) += qemu-thread.o
 common-obj-$(CONFIG_IOTHREAD) += compatfd.o
@@ -315,4 +318,3 @@  endif
 vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
 vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
-
diff --git a/Makefile.target b/Makefile.target
index b0ba95f..5c775bc 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -76,6 +76,7 @@  libobj-$(CONFIG_NOSOFTFLOAT) += fpu/softfloat-native.o
 libobj-y += op_helper.o helper.o
 ifeq ($(TARGET_BASE_ARCH), i386)
 libobj-y += cpuid.o
+libobj-$(CONFIG_QTEST) += ../qtest/qtest_rtc.o
 endif
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
diff --git a/configure b/configure
index 598e8e1..355928e 100755
--- a/configure
+++ b/configure
@@ -174,6 +174,7 @@  trace_backend="nop"
 trace_file="trace"
 spice=""
 rbd=""
+qtest=""
 
 # parse CC options first
 for opt do
@@ -719,6 +720,10 @@  for opt do
   ;;
   --enable-rbd) rbd="yes"
   ;;
+  --disable-qtest) qtest="no"
+  ;;
+  --enable-qtest) qtest="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -914,6 +919,9 @@  echo "                           Default:trace-<pid>"
 echo "  --disable-spice          disable spice"
 echo "  --enable-spice           enable spice"
 echo "  --enable-rbd             enable building the rados block device (rbd)"
+echo "  --disable-qtest          disable qtest unit testing support"
+echo "  --enable-qtest           enable qtest unit testing support"
+echo "                           (requires --enable-io-thread)"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -1656,6 +1664,8 @@  EOF
 fi
 
 ##########################################
+
+##########################################
 # kvm probe
 if test "$kvm" != "no" ; then
     cat > $TMPC <<EOF
@@ -2472,6 +2482,7 @@  echo "Trace output file $trace_file-<pid>"
 echo "spice support     $spice"
 echo "rbd support       $rbd"
 echo "xfsctl support    $xfs"
+echo "QTest support     $qtest"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2784,6 +2795,15 @@  if test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
 fi
 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
 
+if test "$qtest" = "yes"; then
+    if test "$io_thread" = "yes"; then
+        echo "CONFIG_QTEST=y" >> $config_host_mak
+    else
+        echo "ERROR: --enable-io-thread is currently required for qtest"
+        exit 1
+    fi
+fi
+
 echo "TOOLS=$tools" >> $config_host_mak
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
diff --git a/qemu-options.hx b/qemu-options.hx
index 945edf3..6f7e00b 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2339,6 +2339,15 @@  STEXI
 Specify a trace file to log output traces to.
 ETEXI
 #endif
+#ifdef CONFIG_QTEST
+DEF("test", HAS_ARG, QEMU_OPTION_test,
+    "-test <testname>\n", QEMU_ARCH_ALL)
+STEXI
+@item -test @var{testname}
+@findex -test
+Execute test case specified by @var{testname}. Use "?" to list available tests.
+ETEXI
+#endif
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/vl.c b/vl.c
index 0b5b613..4daf948 100644
--- a/vl.c
+++ b/vl.c
@@ -2722,6 +2722,17 @@  int main(int argc, char **argv, char **envp)
                 }
                 break;
 #endif
+#ifdef CONFIG_QTEST
+            case QEMU_OPTION_test:
+                {
+                    if (*optarg == '?') {
+                        qtest_list_modules();
+                        exit(0);
+                    }
+                    qtest_module = optarg;
+                    break;
+                }
+#endif
             case QEMU_OPTION_readconfig:
                 {
                     int ret = qemu_read_config_file(optarg);