[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/2] nbd: Add testsuite coverage
From: |
Eric Blake |
Subject: |
Re: [PATCH v2 2/2] nbd: Add testsuite coverage |
Date: |
Thu, 27 Feb 2020 17:10:07 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 2/27/20 5:02 PM, Eric Blake wrote:
* HACKING (Using NBD connections in tests): New section.
(Writing tests that depend on a certain capability): New capability.
* testsuite/Makefile.am (check-DEJAGNU): Expose NBD witness.
* configure.ac (AC_CHECK_PROGS): Check for nbdkit.
* testsuite/lib/poke-dg.exp (dg-require): Add 'nbd' capability.
(dg-nbd): New command to spawn nbdkit server.
(poke_finish): Clean up nbdkit.
* testsuite/poke.cmd/nbd.pk: New test of '.nbd'.
* testsuite/poke.pkl/open-3.pk: New test of open("nbd...").
---
I forgot to mention in the cover letter: I pushed these two patches to
the eblake/nbd branch if you want to do early testing.
+proc dg-nbd { args } {
+ global poke_commands
+ global poke_data_files
+ global poke_nbd_pids
+ global objdir
+
+ if { [llength $args] != 3 } {
+ error "[lindex $args 0]: invalid arguments"
+ }
+ dg-require nbd
+
+ set data [lindex $args 1]
+ set sock [lindex $args 2]
+ set sockdir "[file dirname $sock]"
+
+ if {! [file exists $data]} {
+ error "[lindex $args 0]: file $data not found"
+ }
+
+ file mkdir $sockdir
+ if { [lsearch -exact $poke_data_files $sockdir] == -1} {
+ lappend poke_data_files $sockdir
+ }
+
+ set fh [open "|nbdkit -f -U $sock file $data"]
Now that I've written this, I wonder if it would be nicer to use
nbdkit's data plugin, rather than the file plugin which forces me to
create a temporary file. For example, instead of:
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80} nbddata } */
+/* { dg-nbd nbddata /tmp/pokenbd.[pid]/sock } */
spawning
nbdkit -f -U $sock file $data
I'm wondering if it would read better as:
/* { dg-nbd {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80}
/tmp/pokenbd.[pid]/sock } */
spawning
nbdkit -f -U $sock data data=$init
(where the first argument to db-nbd has to satisfy the rules of data= as
describe in 'man nbdkit-data-plugin') would be an improvement.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org