Skip to contentSkip to conversation

qemu-iotests: add test for fd passing via SCM rights

PATCH In review Wenchao Xia 3 participants 11 messages Sep 6, 2013 – Sep 22, 2013

lore
Share & tools
lore
#0 lore raw

v4 cover qemu-iotests: add test for fd passing via SCM rights

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin < socket-fd > < file-path >",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

 QMP/qmp.py                             |    6 ++
 configure                              |    2 +-
 tests/Makefile                         |    3 +-
 tests/qemu-iotests/045                 |   51 ++++++++++++-
 tests/qemu-iotests/045.out             |    4 +-
 tests/qemu-iotests/check               |    1 +
 tests/qemu-iotests/iotests.py          |   23 ++++++
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
 8 files changed, 220 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemu-iotests/socket_scm_helper.c
#1 lore raw

PATCH v4 1/3 qemu-iotests: add unix socket help program

This program can do a sendmsg call to transfer fd with unix socket, which is not supported in python2.

The built binary will not be deleted in clean, but it is a existing issue in ./tests, which should be solved in another patch.

---
 configure                              |    2 +-
 tests/Makefile                         |    3 +-
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemu-iotests/socket_scm_helper.c
configure +1 -1
index e989609..aaf9104 100755
@@ -4552,7 +4552,7 @@ if [ "$dtc_internal" = "yes" ]; then
 fi
 
 # build tree in object directory in case the source is not in the current directory
-DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa"
+DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
 DIRS="$DIRS roms/seabios roms/vgabios"
 DIRS="$DIRS qapi-generated"
tests/Makefile +2 -1
index baba9e9..c285805 100644
@@ -172,6 +172,7 @@ tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
 tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
 tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
 tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
+tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
 
 # QTest rules
 
@@ -250,7 +251,7 @@ check-report.html: check-report.xml
 # Other tests
 
 .PHONY: check-tests/qemu-iotests-quick.sh
-check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF)
+check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) tests/qemu-iotests/socket_scm_helper$(EXESUF)
 	$<
 
 .PHONY: check-tests/test-qapi.py
tests/qemu-iotests/socket_scm_helper.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

PATCH v4 2/3 qemu-iotests: add infrastructure of fd passing via SCM

In reply to Wenchao Xia

This patch make use of the compiled scm helper program to transfer fd via unix socket at runtime.

---
 QMP/qmp.py                    |    6 ++++++
 tests/qemu-iotests/check      |    1 +
 tests/qemu-iotests/iotests.py |   23 +++++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
QMP/qmp.py +6 -0
index c551df1..074f09a 100644
@@ -188,3 +188,9 @@ class QEMUMonitorProtocol:
 
     def settimeout(self, timeout):
         self.__sock.settimeout(timeout)
+
+    def get_sock_fd(self):
+        return self.__sock.fileno()
+
+    def is_scm_available(self):
+        return self.__sock.family == socket.AF_UNIX
tests/qemu-iotests/check +1 -0
index 74628ae..2f7f78e 100755
@@ -164,6 +164,7 @@ QEMU_IO       -- $QEMU_IO
 IMGFMT        -- $FULL_IMGFMT_DETAILS
 IMGPROTO      -- $FULL_IMGPROTO_DETAILS
 PLATFORM      -- $FULL_HOST_DETAILS
+SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
 
 EOF
 #MKFS_OPTIONS  -- $FULL_MKFS_OPTIONS
tests/qemu-iotests/iotests.py +23 -0
index 33ad0ec..87b4a3a 100644
@@ -38,6 +38,8 @@ imgfmt = os.environ.get('IMGFMT', 'raw')
 imgproto = os.environ.get('IMGPROTO', 'file')
 test_dir = os.environ.get('TEST_DIR', '/var/tmp')
 
+socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
+
 def qemu_img(*args):
     '''Run qemu-img and return the exit code'''
     devnull = open('/dev/null', 'r+')
@@ -80,6 +82,12 @@ class VM(object):
                      '-display', 'none', '-vga', 'none']
         self._num_drives = 0
 
+    # This can be used to add an unused monitor instance.
+    def add_monitor_telnet(self, ip, port):
+        args = 'tcp:%s:%d,server,nowait,telnet' % (ip, port)
+        self._args.append('-monitor')
+        self._args.append(args)
+
     def add_drive(self, path, opts=''):
         '''Add a virtio-blk drive to the VM'''
         options = ['if=virtio',
@@ -112,6 +120,21 @@ class VM(object):
         self._args.append(','.join(options))
         return self
 
+    def send_fd_scm(self, fd_file_path):
+        # In iotest.py, the qmp should always use unix socket.
+        assert self._qmp.is_scm_available()
+        bin = socket_scm_helper
+        if os.path.exists(bin) == False:
+            print "Scm help program does not present, path '%s'." % bin
+            return -1
+        fd_param = ["%s" % bin,
+                    "%d" % self._qmp.get_sock_fd(),
+                    "%s" % fd_file_path]
+        devnull = open('/dev/null', 'rb')
+        p = subprocess.Popen(fd_param, stdin=devnull, stdout=sys.stdout,
+                             stderr=sys.stderr)
+        return p.wait()
+
     def launch(self):
         '''Launch the VM and establish a QMP connection'''
         devnull = open('/dev/null', 'rb')
Signature · 1 line
1.7.1
#3 lore raw

PATCH v4 3/3 qemu-iotests: add tests for runtime fd passing via SCM rights

In reply to Wenchao Xia

This case will test whether the monitor can receive fd at runtime. To verify better, additional monitor is created to see if qemu can handler two monitor instances correctly.

---
 tests/qemu-iotests/045     |   51 +++++++++++++++++++++++++++++++++++++++++++-
 tests/qemu-iotests/045.out |    4 +-
 2 files changed, 52 insertions(+), 3 deletions(-)
tests/qemu-iotests/045 +50 -1
index 2b6f1af..6be8fc4 100755
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Tests for fdsets.
+# Tests for fdsets and getfd.
 #
 # Copyright (C) 2012 IBM Corp.
 #
@@ -125,5 +125,54 @@ class TestFdSets(iotests.QMPTestCase):
                 'No file descriptor supplied via SCM_RIGHTS')
         self.vm.shutdown()
 
+# Add fd at runtime, there are two ways: monitor related or fdset related
+class TestSCMFd(iotests.QMPTestCase):
+    def setUp(self):
+        self.vm = iotests.VM()
+        qemu_img('create', '-f', iotests.imgfmt, image0, '128K')
+        # Add an unused monitor, to verify it works fine when two monitor
+        # instances present
+        self.vm.add_monitor_telnet("0",4445)
+        self.vm.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+        os.remove(image0)
+
+    def _send_fd_by_SCM(self):
+        ret = self.vm.send_fd_scm(image0)
+        self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+
+    def test_add_fd(self):
+        self._send_fd_by_SCM()
+        result = self.vm.qmp('add-fd', fdset_id=2, opaque='image0:r')
+        self.assert_qmp(result, 'return/fdset-id', 2)
+
+    def test_getfd(self):
+        self._send_fd_by_SCM()
+        result = self.vm.qmp('getfd', fdname='image0:r')
+        self.assert_qmp(result, 'return', {})
+
+    def test_getfd_invalid_fdname(self):
+        self._send_fd_by_SCM()
+        result = self.vm.qmp('getfd', fdname='0image0:r')
+        self.assert_qmp(result, 'error/class', 'GenericError')
+        self.assert_qmp(result, 'error/desc',
+            "Parameter 'fdname' expects a name not starting with a digit")
+
+    def test_closefd(self):
+        self._send_fd_by_SCM()
+        result = self.vm.qmp('getfd', fdname='image0:r')
+        self.assert_qmp(result, 'return', {})
+        result = self.vm.qmp('closefd', fdname='image0:r')
+        self.assert_qmp(result, 'return', {})
+
+    def test_closefd_fd_not_found(self):
+        fdname = 'image0:r'
+        result = self.vm.qmp('closefd', fdname=fdname)
+        self.assert_qmp(result, 'error/class', 'GenericError')
+        self.assert_qmp(result, 'error/desc',
+            "File descriptor named '%s' not found" % fdname)
+
 if __name__ == '__main__':
     iotests.main(supported_fmts=['raw'])
tests/qemu-iotests/045.out +2 -2
index 3f8a935..e56cae0 100644
@@ -1,5 +1,5 @@
-......
+...........
 ----------------------------------------------------------------------
-Ran 6 tests
+Ran 11 tests
 
 OK
Signature · 1 line
1.7.1
Reviewed-by on the v4 series
#4 lore raw
In reply to Wenchao Xia
Quoted 37 lines · Wenchao Xia

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin < socket-fd > < file-path >",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

Quoted 10 lines
 QMP/qmp.py                             |    6 ++
 configure                              |    2 +-
 tests/Makefile                         |    3 +-
 tests/qemu-iotests/045                 |   51 ++++++++++++-
 tests/qemu-iotests/045.out             |    4 +-
 tests/qemu-iotests/check               |    1 +
 tests/qemu-iotests/iotests.py          |   23 ++++++
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
 8 files changed, 220 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemu-iotests/socket_scm_helper.c
#5 lore raw

Am 09.09.2013 um 13:57 hat Stefan Hajnoczi geschrieben:

Quoted 49 lines · Wenchao Xia
Quoted 37 lines

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin < socket-fd > < file-path >",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

Quoted 10 lines
 QMP/qmp.py                             |    6 ++
 configure                              |    2 +-
 tests/Makefile                         |    3 +-
 tests/qemu-iotests/045                 |   51 ++++++++++++-
 tests/qemu-iotests/045.out             |    4 +-
 tests/qemu-iotests/check               |    1 +
 tests/qemu-iotests/iotests.py          |   23 ++++++
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
 8 files changed, 220 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemu-iotests/socket_scm_helper.c
Quoted 1 line

I'm not completely convinced that it's a good idea to introduce a helper binary that isn't automatically rebuilt after an upgrade (I basically never run 'make check-block', which is the only way that would trigger it), but given this Reviewed-by, I've applied this to the block branch.

Kevin

#6 lore raw
Quoted 49 lines · Kevin Wolf

Am 09.09.2013 um 13:57 hat Stefan Hajnoczi geschrieben:

Quoted 48 lines · Wenchao Xia
Quoted 47 lines

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin< socket-fd> < file-path>",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

  QMP/qmp.py                             |    6 ++
  configure                              |    2 +-
  tests/Makefile                         |    3 +-
  tests/qemu-iotests/045                 |   51 ++++++++++++-
  tests/qemu-iotests/045.out             |    4 +-
  tests/qemu-iotests/check               |    1 +
  tests/qemu-iotests/iotests.py          |   23 ++++++
  tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
  8 files changed, 220 insertions(+), 5 deletions(-)

create mode 100644 tests/qemu-iotests/socket_scm_helper.c

Quoted 3 lines
Quoted 1 line

I'm not completely convinced that it's a good idea to introduce a helper binary that isn't automatically rebuilt after an upgrade (I basically

Indeed it will not be rebuilt when code for qemu change, but will be rebuilt when socket_scm_helper.c change. The help program have no connection with qemu's main code, so I think it is safe.
The binaries built under tests/ will not be cleaned, so I think they all have a chance to stay as old version. If this is the issue you mean, I will send a patch clean them, which is what I planned to do sometimes ago . :)

Quoted 5 lines

never run 'make check-block', which is the only way that would trigger it), but given this Reviewed-by, I've applied this to the block branch.

Kevin

#7 lore raw

Am 11.09.2013 um 04:38 hat Wenchao Xia geschrieben:

Quoted 53 lines
Quoted 49 lines · Kevin Wolf

Am 09.09.2013 um 13:57 hat Stefan Hajnoczi geschrieben:

Quoted 48 lines · Wenchao Xia
Quoted 47 lines

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin< socket-fd> < file-path>",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

 QMP/qmp.py                             |    6 ++
 configure                              |    2 +-
 tests/Makefile                         |    3 +-
 tests/qemu-iotests/045                 |   51 ++++++++++++-
 tests/qemu-iotests/045.out             |    4 +-
 tests/qemu-iotests/check               |    1 +
 tests/qemu-iotests/iotests.py          |   23 ++++++
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
 8 files changed, 220 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemu-iotests/socket_scm_helper.c
Quoted 3 lines
Quoted 1 line

I'm not completely convinced that it's a good idea to introduce a helper binary that isn't automatically rebuilt after an upgrade (I basically

Quoted 10 lines

Indeed it will not be rebuilt when code for qemu change, but will be rebuilt when
socket_scm_helper.c change. The help program have no connection with qemu's main code,
so I think it is safe.
The binaries built under tests/ will not be cleaned, so I think they all have a chance to
stay as old version. If this is the issue you mean, I will send a patch clean them, which
is what I planned to do sometimes ago . :)

The difference is that the binaries under tests/ will usually only ever be called using 'make check', which does update them. In contrast, I usually run qemu-iotests by directly executing check -T -nocache -qcow2, which doesn't update anything.

Kevin

Quoted 6 lines
Quoted 5 lines

never run 'make check-block', which is the only way that would trigger it), but given this Reviewed-by, I've applied this to the block branch.

Kevin

#8 lore raw
Quoted 64 lines · Kevin Wolf

Am 11.09.2013 um 04:38 hat Wenchao Xia geschrieben:

Quoted 53 lines
Quoted 49 lines · Kevin Wolf

Am 09.09.2013 um 13:57 hat Stefan Hajnoczi geschrieben:

Quoted 48 lines · Wenchao Xia
Quoted 47 lines

This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job.

v2:
1: add missing $ in the makefile rule.

v3:
Address Eric's comments:
1: typo fix, remove "." in the end of error message, strick
check argc as "!=", use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call.
Address Luiz's comments:
1: change the helper program parameter as "bin< socket-fd> < file-path>",
the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function.
2: related change for helper program parameter change.
3: related change for helper program parameter change.
Other:
1: remove "LINK" rule in makefile, remove fd checking code inside send_fd()
since it is already checked before calling, add '' around %s for path and number string in error message.
2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s
for path in error message.
v4:
Address Stefan's comments:
2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two
test cases for error path.

Wenchao Xia (3):
1 qemu-iotests: add unix socket help program
2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights

  QMP/qmp.py                             |    6 ++
  configure                              |    2 +-
  tests/Makefile                         |    3 +-
  tests/qemu-iotests/045                 |   51 ++++++++++++-
  tests/qemu-iotests/045.out             |    4 +-
  tests/qemu-iotests/check               |    1 +
  tests/qemu-iotests/iotests.py          |   23 ++++++
  tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++
  8 files changed, 220 insertions(+), 5 deletions(-)

create mode 100644 tests/qemu-iotests/socket_scm_helper.c

Quoted 3 lines
Quoted 1 line

I'm not completely convinced that it's a good idea to introduce a helper binary that isn't automatically rebuilt after an upgrade (I basically

Quoted 10 lines

Indeed it will not be rebuilt when code for qemu change, but will be rebuilt when
socket_scm_helper.c change. The help program have no connection with qemu's main code,
so I think it is safe.
The binaries built under tests/ will not be cleaned, so I think they all have a chance to
stay as old version. If this is the issue you mean, I will send a patch clean them, which
is what I planned to do sometimes ago . :)

Quoted 7 lines

The difference is that the binaries under tests/ will usually only ever be called using 'make check', which does update them. In contrast, I usually run qemu-iotests by directly executing check -T -nocache -qcow2, which doesn't update anything.

Kevin

OK, I see the problem now. I guess "make" is done before to update qemu
binary, so the problem is how to trigger the build of helper. What about add Makefile in test/qemu-iotests/ ? Then 'make check' in root dir, and 'check -T ..." both trigger the build.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

never run 'make check-block', which is the only way that would trigger it), but given this Reviewed-by, I've applied this to the block branch.

Kevin

#9 lore raw
In reply to Stefan Hajnoczi
Quoted 2 lines · Stefan Hajnoczi
Quoted 1 line · Wenchao Xia
 tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++

After a clean QEMU build ./check -raw fails now. This can be resolved by manually building the helper program but I think it should be part of the main QEMU build process (make install simply won't copy the helper program).

Wenchao: Can you send a patch to include the helper into the build process?

045 1s ... [failed, exit status 1] - output mismatch (see 045.out.bad)

045.out.bad renamed from 045.out +46 -2
@@ -1,5 +1,49 @@
-...........
+......FF.FF
+======================================================================
+FAIL: test_add_fd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 147, in test_add_fd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_closefd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 164, in test_closefd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_getfd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 152, in test_getfd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_getfd_invalid_fdname (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 157, in test_getfd_invalid_fdname
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
 ----------------------------------------------------------------------
 Ran 11 tests
 
-OK
+FAILED (failures=4)
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.
#10 lore raw
Quoted 10 lines · Stefan Hajnoczi
Quoted 2 lines · Stefan Hajnoczi
Quoted 1 line · Wenchao Xia
  tests/qemu-iotests/socket_scm_helper.c |  135 ++++++++++++++++++++++++++++++++

After a clean QEMU build ./check -raw fails now. This can be resolved by manually building the helper program but I think it should be part of the main QEMU build process (make install simply won't copy the helper program).

Wenchao: Can you send a patch to include the helper into the build process?

Sorry for late response, I was on vacation before. Will sent a patch
later.

Quoted 56 lines

045 1s ... [failed, exit status 1] - output mismatch (see 045.out.bad)

045.out.bad renamed from 045.out +46 -2
@@ -1,5 +1,49 @@
-...........
+......FF.FF
+======================================================================
+FAIL: test_add_fd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 147, in test_add_fd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_closefd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 164, in test_closefd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_getfd (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 152, in test_getfd
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
+======================================================================
+FAIL: test_getfd_invalid_fdname (__main__.TestSCMFd)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "./045", line 157, in test_getfd_invalid_fdname
+    self._send_fd_by_SCM()
+  File "./045", line 144, in _send_fd_by_SCM
+    self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+AssertionError: Failed to send fd with UNIX SCM
+
  ----------------------------------------------------------------------
  Ran 11 tests
 
-OK
+FAILED (failures=4)
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.
+Scm help program does not present, path 'socket_scm_helper'.