qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker
@ 2017-09-08  9:16 Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 1/7] Makefile: Rename TARGET_DIRS to TARGET_LIST Fam Zheng
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

Recently it was brought up that "make test" is in an orphaned state, and making
it work would be a good thing because it has valuable test coverage for tcg:

https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg04978.html

This RFC is an attempt to use docker to cross build the test binaries that will
be run by qemu-user and meanwhile rename it from "make test" to "make
check-tcg" to align with the naming convention of other test targets we have.

As the initial version only i386 is converted, not because it's easy, but
because it is a test set that covers the most types of rules we will need
(cross-build, run and compare result).

After these patches, "make check-tcg" will do the i386 tests with the new
rules first (which fails but that's out of the scope of this series), then
continue to do the old "make -C tests/tcg test" command. Once all tests are
moved into the new Makefile.include file, the old Makefile can be dropped.

Fam Zheng (7):
  Makefile: Rename TARGET_DIRS to TARGET_LIST
  docker: Add "cc" subcommand
  docker: Add fedora-i386-cross image
  tests: Build fix for hello-i386
  tests: Build fix for linux-test
  buildsys: Add "check-tcg" target
  tests: Move i386 tcg tests to check-tcg

 Makefile                                          | 21 ++++---
 configure                                         |  2 +-
 scripts/create_config                             |  2 +-
 tests/Makefile.include                            |  3 +-
 tests/docker/docker.py                            | 23 +++++++
 tests/docker/dockerfiles/fedora-i386-cross.docker | 13 ++++
 tests/tcg/Makefile                                | 60 ------------------
 tests/tcg/Makefile.include                        | 75 +++++++++++++++++++++++
 tests/tcg/hello-i386.c                            |  1 +
 tests/tcg/linux-test.c                            | 67 +++++++-------------
 10 files changed, 149 insertions(+), 118 deletions(-)
 create mode 100644 tests/docker/dockerfiles/fedora-i386-cross.docker
 create mode 100644 tests/tcg/Makefile.include

-- 
2.13.5

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 1/7] Makefile: Rename TARGET_DIRS to TARGET_LIST
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 2/7] docker: Add "cc" subcommand Fam Zheng
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

To be more accurate on its purpose and make code that looks for a certain
target out of this variable more readable.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 Makefile               | 20 ++++++++++----------
 configure              |  2 +-
 scripts/create_config  |  2 +-
 tests/Makefile.include |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 337a1f6f9b..c1e35b1fd0 100644
--- a/Makefile
+++ b/Makefile
@@ -24,8 +24,8 @@ seems to have been used for an in-tree build. You can fix this by running \
 endif
 endif
 
-CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
-CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
+CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_LIST)),y)
+CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_LIST)),y)
 CONFIG_XEN := $(CONFIG_XEN_BACKEND)
 CONFIG_ALL=y
 -include config-all-devices.mak
@@ -217,8 +217,8 @@ DOCS=
 endif
 
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR)
-SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
-SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
+SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_LIST))
+SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_LIST))
 
 ifeq ($(SUBDIR_DEVICES_MAK),)
 config-all-devices.mak:
@@ -314,7 +314,7 @@ config-host.h-timestamp: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
 
-SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
+SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_LIST))
 SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
 
 $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
@@ -352,7 +352,7 @@ ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
 romsubdir-%:
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
 
-ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
+ALL_SUBDIRS=$(TARGET_LIST) $(patsubst %,pc-bios/%, $(ROMS))
 
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
@@ -537,7 +537,7 @@ distclean: clean
 	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
 	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
 	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
-	for d in $(TARGET_DIRS); do \
+	for d in $(TARGET_LIST); do \
 	rm -rf $$d || exit 1 ; \
         done
 	rm -Rf .sdk
@@ -638,7 +638,7 @@ endif
 		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
 	done
 	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
-	for d in $(TARGET_DIRS); do \
+	for d in $(TARGET_LIST); do \
 	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
         done
 
@@ -832,9 +832,9 @@ help:
 	@echo  '  ctags/TAGS      - Generate tags file for editors'
 	@echo  '  cscope          - Generate cscope index'
 	@echo  ''
-	@$(if $(TARGET_DIRS), \
+	@$(if $(TARGET_LIST), \
 		echo 'Architecture specific targets:'; \
-		$(foreach t, $(TARGET_DIRS), \
+		$(foreach t, $(TARGET_LIST), \
 		printf "  %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
 		echo '')
 	@echo  'Cleaning targets:'
diff --git a/configure b/configure
index a541aadebc..36a2fa1f23 100755
--- a/configure
+++ b/configure
@@ -5587,7 +5587,7 @@ qemu_version=$(head $source_path/VERSION)
 echo "VERSION=$qemu_version" >>$config_host_mak
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
-echo "TARGET_DIRS=$target_list" >> $config_host_mak
+echo "TARGET_LIST=$target_list" >> $config_host_mak
 if [ "$docs" = "yes" ] ; then
   echo "BUILD_DOCS=yes" >> $config_host_mak
 fi
diff --git a/scripts/create_config b/scripts/create_config
index e6929dd61e..3612f8154f 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -107,7 +107,7 @@ case $line in
     target_name=${line#*=}
     echo "#define TARGET_NAME \"$target_name\""
     ;;
- TARGET_DIRS=*)
+ TARGET_LIST=*)
     # do nothing
     ;;
  TARGET_*=y) # configuration
diff --git a/tests/Makefile.include b/tests/Makefile.include
index fae5715e9c..debaf845db 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -820,7 +820,7 @@ endif
 
 # QTest rules
 
-TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
+TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_LIST)))
 ifeq ($(CONFIG_POSIX),y)
 QTEST_TARGETS = $(TARGETS)
 check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y))
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 2/7] docker: Add "cc" subcommand
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 1/7] Makefile: Rename TARGET_DIRS to TARGET_LIST Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 3/7] docker: Add fedora-i386-cross image Fam Zheng
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/docker/docker.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 81c87ee329..419ebe665f 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -367,6 +367,29 @@ class ImagesCommand(SubCommand):
     def run(self, args, argv):
         return Docker().command("images", argv, args.quiet)
 
+class CcCommand(SubCommand):
+    """Compile sources with cc in images"""
+    name = "cc"
+
+    def args(self, parser):
+        parser.add_argument("--image", "-i", required=True,
+                            help="The docker image in which to run cc")
+        parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
+                            help="""Extra paths to (ro) mount into container for
+                            reading sources""")
+
+    def run(self, args, argv):
+        if argv and argv[0] == "--":
+            argv = argv[1:]
+        cwd = os.getcwd()
+        cmd = ["--rm", "-w", cwd,
+               "-v", "%s:%s:rw" % (cwd, cwd)]
+        for p in args.paths:
+           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+        cmd += [args.image, "cc"]
+        cmd += argv
+        return Docker().command("run", cmd, True)
+
 def main():
     parser = argparse.ArgumentParser(description="A Docker helper",
             usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 3/7] docker: Add fedora-i386-cross image
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 1/7] Makefile: Rename TARGET_DIRS to TARGET_LIST Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 2/7] docker: Add "cc" subcommand Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 4/7] tests: Build fix for hello-i386 Fam Zheng
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

It has some basic *-devel.i686 packages to be used with "gcc -m32" as a
32 bit cross build environment.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/docker/dockerfiles/fedora-i386-cross.docker | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 tests/docker/dockerfiles/fedora-i386-cross.docker

diff --git a/tests/docker/dockerfiles/fedora-i386-cross.docker b/tests/docker/dockerfiles/fedora-i386-cross.docker
new file mode 100644
index 0000000000..239fba5fa6
--- /dev/null
+++ b/tests/docker/dockerfiles/fedora-i386-cross.docker
@@ -0,0 +1,13 @@
+FROM fedora:latest
+ENV PACKAGES \
+    gcc \
+    glibc-devel.i686 \
+    glib2-devel.i686 \
+    zlib-devel.i686 \
+    glib2-devel.i686 \
+    nettle-devel.i686 \
+    pixman-devel.i686 \
+    gnutls-devel.i686
+
+RUN dnf install -y $PACKAGES
+RUN rpm -q $PACKAGES | sort > /packages.txt
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 4/7] tests: Build fix for hello-i386
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
                   ` (2 preceding siblings ...)
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 3/7] docker: Add fedora-i386-cross image Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 5/7] tests: Build fix for linux-test Fam Zheng
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

We have -Werror=missing-prototype, add a dummy prototype to avoid that
warning.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/tcg/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/tcg/hello-i386.c b/tests/tcg/hello-i386.c
index fa00380de2..cfeb24b2f5 100644
--- a/tests/tcg/hello-i386.c
+++ b/tests/tcg/hello-i386.c
@@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
   return status;
 }
 
+void _start(void);
 void _start(void)
 {
     write(1, "Hello World\n", 12);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 5/7] tests: Build fix for linux-test
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
                   ` (3 preceding siblings ...)
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 4/7] tests: Build fix for hello-i386 Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 6/7] buildsys: Add "check-tcg" target Fam Zheng
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

To keep the compiler happy, and to fit in our buildsys flags:

- Include "qemu/osdep.h" first
- Make local functions "static"
- #ifdef out unused functions

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/tcg/linux-test.c | 67 +++++++++++++++++---------------------------------
 1 file changed, 22 insertions(+), 45 deletions(-)

diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 5070d31446..2a7b8c2d05 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "qemu/osdep.h"
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,6 +32,7 @@
 #include <utime.h>
 #include <time.h>
 #include <sys/time.h>
+#include <sys/resource.h>
 #include <sys/uio.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -45,7 +47,7 @@
 #define TESTPORT 7654
 #define STACK_SIZE 16384
 
-void error1(const char *filename, int line, const char *fmt, ...)
+static void error1(const char *filename, int line, const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
@@ -56,7 +58,7 @@ void error1(const char *filename, int line, const char *fmt, ...)
     exit(1);
 }
 
-int __chk_error(const char *filename, int line, int ret)
+static int __chk_error(const char *filename, int line, int ret)
 {
     if (ret < 0) {
         error1(filename, line, "%m (ret=%d, errno=%d)",
@@ -73,7 +75,7 @@ int __chk_error(const char *filename, int line, int ret)
 
 #define FILE_BUF_SIZE 300
 
-void test_file(void)
+static void test_file(void)
 {
     int fd, i, len, ret;
     uint8_t buf[FILE_BUF_SIZE];
@@ -210,7 +212,7 @@ void test_file(void)
     chk_error(rmdir(TESTPATH));
 }
 
-void test_fork(void)
+static void test_fork(void)
 {
     int pid, status;
 
@@ -224,7 +226,7 @@ void test_fork(void)
         error("waitpid status=0x%x", status);
 }
 
-void test_time(void)
+static void test_time(void)
 {
     struct timeval tv, tv2;
     struct timespec ts, rem;
@@ -251,34 +253,7 @@ void test_time(void)
         error("getrusage");
 }
 
-void pstrcpy(char *buf, int buf_size, const char *str)
-{
-    int c;
-    char *q = buf;
-
-    if (buf_size <= 0)
-        return;
-
-    for(;;) {
-        c = *str++;
-        if (c == 0 || q >= buf + buf_size - 1)
-            break;
-        *q++ = c;
-    }
-    *q = '\0';
-}
-
-/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
-{
-    int len;
-    len = strlen(buf);
-    if (len < buf_size)
-        pstrcpy(buf + len, buf_size - len, s);
-    return buf;
-}
-
-int server_socket(void)
+static int server_socket(void)
 {
     int val, fd;
     struct sockaddr_in sockaddr;
@@ -298,7 +273,7 @@ int server_socket(void)
 
 }
 
-int client_socket(void)
+static int client_socket(void)
 {
     int fd;
     struct sockaddr_in sockaddr;
@@ -312,9 +287,9 @@ int client_socket(void)
     return fd;
 }
 
-const char socket_msg[] = "hello socket\n";
+static const char socket_msg[] = "hello socket\n";
 
-void test_socket(void)
+static void test_socket(void)
 {
     int server_fd, client_fd, fd, pid, ret, val;
     struct sockaddr_in sockaddr;
@@ -348,9 +323,10 @@ void test_socket(void)
     chk_error(close(server_fd));
 }
 
+#if 0
 #define WCOUNT_MAX 512
 
-void test_pipe(void)
+static void test_pipe(void)
 {
     fd_set rfds, wfds;
     int fds[2], fd_max, ret;
@@ -391,10 +367,10 @@ void test_pipe(void)
     chk_error(close(fds[1]));
 }
 
-int thread1_res;
-int thread2_res;
+static int thread1_res;
+static int thread2_res;
 
-int thread1_func(void *arg)
+static int thread1_func(void *arg)
 {
     int i;
     for(i=0;i<5;i++) {
@@ -404,7 +380,7 @@ int thread1_func(void *arg)
     return 0;
 }
 
-int thread2_func(void *arg)
+static int thread2_func(void *arg)
 {
     int i;
     for(i=0;i<6;i++) {
@@ -435,27 +411,28 @@ void test_clone(void)
         thread2_res != 6)
         error("clone");
 }
+#endif
 
 /***********************************/
 
 volatile int alarm_count;
 jmp_buf jmp_env;
 
-void sig_alarm(int sig)
+static void sig_alarm(int sig)
 {
     if (sig != SIGALRM)
         error("signal");
     alarm_count++;
 }
 
-void sig_segv(int sig, siginfo_t *info, void *puc)
+static void sig_segv(int sig, siginfo_t *info, void *puc)
 {
     if (sig != SIGSEGV)
         error("signal");
     longjmp(jmp_env, 1);
 }
 
-void test_signal(void)
+static void test_signal(void)
 {
     struct sigaction act;
     struct itimerval it, oit;
@@ -510,7 +487,7 @@ void test_signal(void)
 
 #define SHM_SIZE 32768
 
-void test_shm(void)
+static void test_shm(void)
 {
     void *ptr;
     int shmid;
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 6/7] buildsys: Add "check-tcg" target
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
                   ` (4 preceding siblings ...)
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 5/7] tests: Build fix for linux-test Fam Zheng
@ 2017-09-08  9:16 ` Fam Zheng
  2017-09-08  9:17 ` [Qemu-devel] [PATCH RFC 7/7] tests: Move i386 tcg tests to check-tcg Fam Zheng
  2017-09-08  9:26 ` [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

This is merely a thin wrapper of the old "test" target, but in a
consistent form of Makefile structure.

Next patches will actually convert the rules from the old "make test".

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 Makefile                   | 1 +
 tests/Makefile.include     | 1 +
 tests/tcg/Makefile.include | 3 +++
 3 files changed, 5 insertions(+)
 create mode 100644 tests/tcg/Makefile.include

diff --git a/Makefile b/Makefile
index c1e35b1fd0..c44be86cef 100644
--- a/Makefile
+++ b/Makefile
@@ -282,6 +282,7 @@ dummy := $(call unnest-vars,, \
                 trace-obj-y)
 
 include $(SRC_PATH)/tests/Makefile.include
+include $(SRC_PATH)/tests/tcg/Makefile.include
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index debaf845db..0e22d90640 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -10,6 +10,7 @@ check-help:
 	@echo " make check-speed          Run qobject speed tests"
 	@echo " make check-qapi-schema    Run QAPI schema tests"
 	@echo " make check-block          Run block tests"
+	@echo " make check-tcg            Clean TCG tests"
 	@echo " make check-report.html    Generates an HTML test report"
 	@echo " make check-clean          Clean the tests"
 	@echo
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
new file mode 100644
index 0000000000..e5fea1c8c5
--- /dev/null
+++ b/tests/tcg/Makefile.include
@@ -0,0 +1,3 @@
+
+check-tcg:
+	$(MAKE) -C tests/tcg test
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH RFC 7/7] tests: Move i386 tcg tests to check-tcg
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
                   ` (5 preceding siblings ...)
  2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 6/7] buildsys: Add "check-tcg" target Fam Zheng
@ 2017-09-08  9:17 ` Fam Zheng
  2017-09-08  9:26 ` [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-09-08  9:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, Alex Bennée, Fam Zheng,
	Philippe Mathieu-Daudé, programmingkidx, crosa, pbonzini,
	rth

Only enable the tests if i386-linux-user is a specified target in
configure, and build the test programs with "docker.py cc" command.

Also change the "diff -u" to "cmp -s" because we have really huge output
to compare.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/tcg/Makefile         | 60 -------------------------------------
 tests/tcg/Makefile.include | 74 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 61 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 89e3342f3d..4a2b069304 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -17,15 +17,6 @@ LDFLAGS=
 # runcom maps page 0, so it requires root privileges
 # also, pi_10.com runs indefinitely
 
-I386_TESTS=hello-i386 \
-	   linux-test \
-	   testthread \
-	   sha1-i386 \
-	   test-i386 \
-	   test-i386-fprem \
-	   test-mmap \
-	   # runcom
-
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
 I386_TESTS+=run-test-x86_64
@@ -46,35 +37,11 @@ test: all
 run-%: %
 	-$(QEMU) ./$*
 
-run-hello-i386: hello-i386
-run-linux-test: linux-test
-run-testthread: testthread
-run-sha1-i386: sha1-i386
-
-run-test-i386: test-i386
-	./test-i386 > test-i386.ref
-	-$(QEMU) test-i386 > test-i386.out
-	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
-
-run-test-i386-fprem: test-i386-fprem
-	./test-i386-fprem > test-i386-fprem.ref
-	-$(QEMU) test-i386-fprem > test-i386-fprem.out
-	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
-
 run-test-x86_64: test-x86_64
 	./test-x86_64 > test-x86_64.ref
 	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
 	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
 
-run-test-mmap: test-mmap
-	-$(QEMU) ./test-mmap
-	-$(QEMU) -p 8192 ./test-mmap 8192
-	-$(QEMU) -p 16384 ./test-mmap 16384
-	-$(QEMU) -p 32768 ./test-mmap 32768
-
-run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
-
 run-test_path: test_path
 	./test_path
 
@@ -84,37 +51,10 @@ test_path: test_path.o
 
 test_path.o: test_path.c
 
-hello-i386: hello-i386.c
-	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
-	strip $@
-
-testthread: testthread.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
-
-# i386/x86_64 emulation test (test various opcodes) */
-test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
-           test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
-              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
-
-test-i386-fprem: test-i386-fprem.c
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
 	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
 
-# generic Linux and CPU test
-linux-test: linux-test.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
-
-# vm86 test
-runcom: runcom.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-test-mmap: test-mmap.c
-	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
-
 # speed test
 sha1-i386: sha1.c
 	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
index e5fea1c8c5..64f1a4a003 100644
--- a/tests/tcg/Makefile.include
+++ b/tests/tcg/Makefile.include
@@ -1,3 +1,75 @@
 
-check-tcg:
+TCG_I386_TESTS := \
+	hello-i386 \
+	linux-test \
+	testthread \
+	sha1-i386 \
+	test-i386 \
+	test-i386-fprem \
+	test-mmap \
+	# runcom
+
+$(addprefix tests/tcg/, $(TCG_I386_TESTS)): DOCKER_IMAGE := fedora-i386-cross
+$(addprefix tests/tcg/, $(TCG_I386_TESTS)): CFLAGS := -m32 -I/usr/lib/glib-2.0/include/ -I/usr/include/glib-2.0 -Wall -O2 -g -fno-strict-aliasing $(QEMU_INCLUDES)
+$(addprefix tests/tcg/, $(TCG_I386_TESTS)): QEMU_CFLAGS :=
+$(addprefix tests/tcg/, $(TCG_I386_TESTS)): LDFLAGS :=
+$(addprefix tests/tcg/, $(TCG_I386_TESTS)): QEMU_LDFLAGS :=
+
+check-tcg-i386: $(addprefix tcg-run-,$(TCG_I386_TESTS))
+$(addprefix tcg-run-,$(TCG_I386_TESTS)): QEMU := i386-linux-user/qemu-i386
+$(addprefix tcg-run-,$(TCG_I386_TESTS)): i386-linux-user/qemu-i386
+
+TCG_SIMPLE_TESTS := \
+	hello-i386 \
+	linux-test \
+	testthread \
+	sha1-i386
+
+$(foreach t,$(TCG_SIMPLE_TESTS), \
+	$(eval tcg-run-$t: tcg-runsimple-$t))
+
+tcg-runsimple-%: tests/tcg/%$(EXESUF)
+	-$(QEMU) $<
+
+TCG_CMP_TESTS := \
+	test-i386 \
+	test-i386-fprem
+
+$(foreach t,$(TCG_CMP_TESTS), \
+	$(eval tcg-run-$t: tcg-runcmp-$t))
+
+tcg-runcmp-%: tests/tcg/%$(EXESUF)
+	$< > $<.ref
+	-$(QEMU) $< > $<.out
+	@if cmp -s $<.ref $<.out ; then echo "Auto Test OK"; fi
+
+tcg-run-test-mmap: tests/tcg/test-mmap
+	-$(QEMU) $<
+	-$(QEMU) -p 8192 $< 8192
+	-$(QEMU) -p 16384 $< 16384
+	-$(QEMU) -p 32768 $< 32768
+
+tcg-run-runcom: tests/tcg/runcom
+	-$(QEMU) $< $(SRC_PATH)/tests/tcg/pi_10.com
+
+TCG_TESTS = $(if $(filter i386-linux-user, $(TARGET_LIST)), $(TCG_I386_TESTS))
+
+$(addprefix tests/tcg/, $(TCG_TESTS)): CXX :=
+$(addprefix tests/tcg/, $(TCG_TESTS)): CC := \
+	$(SRC_PATH)/tests/docker/docker.py cc -i qemu:$(DOCKER_IMAGE) -s $(SRC_PATH) --
+
+tests/tcg/hello-i386: LDFLAGS := -nostdlib
+
+tests/tcg/sha1-i386: tests/tcg/sha1.o
+	$(call LINK, $^)
+
+tests/tcg/test-i386: $(addprefix $(SRC_PATH)/tests/tcg/, \
+			test-i386.c test-i386-code16.S test-i386-vm86.S \
+           test-i386.h test-i386-shift.h test-i386-muldiv.h)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
+              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
+
+.PHONY: check-tcg $(patsubst %,run-%,$(TCG_TESTS))
+
+check-tcg: $(addprefix tcg-run-, $(TCG_TESTS))
 	$(MAKE) -C tests/tcg test
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker
  2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
                   ` (6 preceding siblings ...)
  2017-09-08  9:17 ` [Qemu-devel] [PATCH RFC 7/7] tests: Move i386 tcg tests to check-tcg Fam Zheng
@ 2017-09-08  9:26 ` no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2017-09-08  9:26 UTC (permalink / raw)
  To: famz
  Cc: qemu-devel, peter.maydell, thuth, f4bug, programmingkidx, crosa,
	pbonzini, alex.bennee, rth

Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker
Message-id: 20170908091700.14867-1-famz@redhat.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20170908091700.14867-1-famz@redhat.com -> patchew/20170908091700.14867-1-famz@redhat.com
 t [tag update]            patchew/cover.1504228916.git.alistair.francis@xilinx.com -> patchew/cover.1504228916.git.alistair.francis@xilinx.com
Switched to a new branch 'test'
0c7a642a86 tests: Move i386 tcg tests to check-tcg
44226ca4fd buildsys: Add "check-tcg" target
e670c4e114 tests: Build fix for linux-test
09fbbd7842 tests: Build fix for hello-i386
0546399a8a docker: Add fedora-i386-cross image
5a8cd21a02 docker: Add "cc" subcommand
89d4346f6e Makefile: Rename TARGET_DIRS to TARGET_LIST

=== OUTPUT BEGIN ===
Checking PATCH 1/7: Makefile: Rename TARGET_DIRS to TARGET_LIST...
Checking PATCH 2/7: docker: Add "cc" subcommand...
Checking PATCH 3/7: docker: Add fedora-i386-cross image...
Checking PATCH 4/7: tests: Build fix for hello-i386...
ERROR: externs should be avoided in .c files
#20: FILE: tests/tcg/hello-i386.c:23:
+void _start(void);

total: 1 errors, 0 warnings, 7 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 5/7: tests: Build fix for linux-test...
ERROR: if this code is redundant consider removing it
#141: FILE: tests/tcg/linux-test.c:326:
+#if 0

total: 1 errors, 0 warnings, 179 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 6/7: buildsys: Add "check-tcg" target...
Checking PATCH 7/7: tests: Move i386 tcg tests to check-tcg...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-08  9:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-08  9:16 [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 1/7] Makefile: Rename TARGET_DIRS to TARGET_LIST Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 2/7] docker: Add "cc" subcommand Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 3/7] docker: Add fedora-i386-cross image Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 4/7] tests: Build fix for hello-i386 Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 5/7] tests: Build fix for linux-test Fam Zheng
2017-09-08  9:16 ` [Qemu-devel] [PATCH RFC 6/7] buildsys: Add "check-tcg" target Fam Zheng
2017-09-08  9:17 ` [Qemu-devel] [PATCH RFC 7/7] tests: Move i386 tcg tests to check-tcg Fam Zheng
2017-09-08  9:26 ` [Qemu-devel] [PATCH RFC 0/7] Proof of concept to power up "make test" with docker no-reply

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).