[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] tests/vpci: install test


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Mon, 13 Mar 2023 13:12:26 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=snNv+meeJ8VUCO7BN1YFfaJap+t/BpYIEUVH9+RrQO8=; b=jUGcVQUKwh7DXnGzge+ProaN9JKXRo4fNnGoil8yGqW8snI1yFyofF66y+k37mamzIsXGRasMkla3MCXiq+qWEvOIRxahREstz3kmUt3nC92cyXzt7ql7ZuAft34DCE98q6MhN2TKadgEXDhu94ktsSHqn9Sat0YpPQLbQ9IaqfCEPjEnWHd/dUz5xehSKsZwMVn87RPnrx7kYqHvklb1fkOt0eIsbKmBEEfrqeWTadcHW59jtQZ614kf6kUaxZYpQftm6x9JPnoVMDA0F1dCHWxvTE6CE4KlVqZ3bfZ2X4kMK2Op1lCh2g25xDsbLbBrHjHwX4NzwVSUNtZrhjw1g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cjl+0RpSNKQ6rMU7ygiImHgzdavMnoaavfeXgfomyXumC8FnPNcqvhUYn6XMaMoNguVmHREOH2vwOI8QneNWK4V8FM0hH4kzqYL0wYwqLWvwhOlUPKk75LzeeNStE7sBhP0mcihpDgBIzF9Q4ndagzwes2MdG5/cqdrO5ZpgOJuAQJWnHklykCrRTCUphWIqs6EO31JiSQKoORDvlNu7IQakgRb8jODl8g5pVnRNjs1qbHkpoO3hllPFyRSUwxBl+iEqPyIZbYsE64YX7gdtvZAM80ixjcSePkY/DPzPgNCYDCEV79/QetxXljqg1jaEng0LwnqEyHasq1n6TOqilg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: andrew.cooper3@xxxxxxxxxx, JBeulich@xxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 13 Mar 2023 12:13:25 +0000
  • Ironport-data: A9a23:FgCUe6LCOplDhHV6FE+RzJQlxSXFcZb7ZxGr2PjKsXjdYENSgjQDn GUfCm6BbP+NZ2GmL4x2a463oElVu5/Vzd9lSFBlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPTwP9TlK6q4mhA5QVlPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c4mADlH8 782Ggo3TUiBhc2Qw5u4TNlF05FLwMnDZOvzu1lG5BSAVbMMZ8+GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/VvpTGLkWSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iv03rKXxnOhA+r+EpXpxMdPmXCW51cQUjQvVGC2i6SWlGeXDoc3x 0s8v3BGQbIJ3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQAsbBRMddgnv88eXiEx2 xmCmNaBONB0mLicSHbY/LHLqzq3YHARNTVbPXJCShYZ6d7+po11lgjIUttoDK+yiJvyBC30x DeJ6iM5gt3/kPI26klyxnif6xrEm3QDZlVujukLdgpJNj9EWbM=
  • Ironport-hdrordr: A9a23:K2BhR6vFppbCZLB1YSyzdNcp7skCHYAji2hC6mlwRA09TyXGra 2TdaUgvyMc1gx7ZJhBo7+90We7MBHhHPlOkPEs1NaZLXDbUQ6TQL2KgrGSpwEIdxefygc/79 YcT0EBMqyWMbESt6+TjmiF+r4bsaO6GcuT9ILjJhlWPGJXg/YK1XYDNu/XKDwAeOEAbqBJZa a0145inX6NaH4XZsO0Cj0sWPXCncTCkNbLcAMLHBku7SiJlHeN5KThGxaV8x8CW3cXqI1Sul Ttokjc3OGOovu7whjT2yv66IlXosLozp9uFdGBkc8cLxTrk0KNaJ56U7OPkTgpqKWE6Uoskv PLvxA8Vv4Do0/5TyWQm1/AygPg2DEh5zvLzkKZu2LqpYjcSCghA8RMqIpFel+BgnBQ9e1U4e Zu5Sa0ppBXBRTPkGDU4MXJbQhjkg6RrWA5meAeonRDWc81aaNXr6YY4ERJea1wah7S2cQCKq 1DHcvc7PFZfRezaG3YhHBmxJiWUnE6Dn69Mzo/k/3Q9wITsGFyzkMeysBatGwH7ogBR55N4P mBGrh0lZlVJ/VmIp5VNaMke4+aG2bNSRXDPCa5OlL8DpwKPHrLttre/Kg13ue3Y5YFpaFC1K gpaGko9FLaRnieSfFnhPZwg1PwqSSGLHnQI/hlltZEUuaWfsuoDcWBIGpe4PdI7c9vR/EzYM zDRq6+M8WTUVcGJrw5oDEWI6MiT0X2cPdlz+rTCGj+1v7jG8nNitHxVsr1Cf7ELQsEM1mPck frGgKDbvl90g==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce an install target, like it's used by other tests.  This
allows running the test on the installed systems, which is easier than
running it during the build phase when dealing with automated testing.
Strictly speaking the vpci test doesn't require to be run on a Xen
host currently, but that allows easier integration with logic that
runs the rest of the tests.

While there also adjust the makefile to use $(RM), and rename the
resulting binary to use a dash instead of an underscore (again to
match the rest of the tests).

Since the resulting test binary is now part of the distribution CC
must be used instead of HOSTCC, together with CFLAGS.  The usage of
CFLAGS requires removing two local unused variables and converting
pci_get_pdev() into a function in order for the 'd' local variable
in vpci_{read,write} to be used, or else the build of the test
fails.

Finally adjust the `run` target to only run the test if HOSTCC is CC,
else print a warning message.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
XenRT has recently gained the ability to run the tests in tools/tests
that are installed, so the install target is needed for that use-case.
---
Changes since v1:
 - Adjust run target to take HOSTCC vs CC into account.
 - Use CFLAGS.
 - Remove two unused variables.
 - Convert pci_get_pdev() into a function.
---
 tools/tests/vpci/Makefile | 18 ++++++++++++++----
 tools/tests/vpci/emul.h   |  7 ++++++-
 tools/tests/vpci/main.c   |  2 --
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/tools/tests/vpci/Makefile b/tools/tests/vpci/Makefile
index 5075bc2be2..11f1ee7126 100644
--- a/tools/tests/vpci/Makefile
+++ b/tools/tests/vpci/Makefile
@@ -1,27 +1,37 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-TARGET := test_vpci
+TARGET := test-vpci
 
 .PHONY: all
 all: $(TARGET)
 
 .PHONY: run
 run: $(TARGET)
+ifeq ($(CC),$(HOSTCC))
        ./$(TARGET)
+else
+       $(warning HOSTCC != CC, cannot run test)
+endif
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-       $(HOSTCC) -g -o $@ vpci.c main.c
+       $(CC) $(CFLAGS) -o $@ vpci.c main.c
 
 .PHONY: clean
 clean:
-       rm -rf $(TARGET) *.o *~ vpci.h vpci.c list.h
+       $(RM) -- $(TARGET) *.o *~ vpci.h vpci.c list.h
 
 .PHONY: distclean
 distclean: clean
 
 .PHONY: install
-install:
+install: all
+       $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+       $(INSTALL_PROG) $(TARGET) $(DESTDIR)$(LIBEXEC_BIN)
+
+.PHONY: uninstall
+uninstall:
+       $(RM) -- $(DESTDIR)$(LIBEXEC_BIN)/$(TARGET)
 
 vpci.c: $(XEN_ROOT)/xen/drivers/vpci/vpci.c
        # Remove includes and add the test harness header
diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h
index f03e3a56d1..6baab20de5 100644
--- a/tools/tests/vpci/emul.h
+++ b/tools/tests/vpci/emul.h
@@ -92,7 +92,12 @@ typedef union {
 #define xmalloc(type) ((type *)malloc(sizeof(type)))
 #define xfree(p) free(p)
 
-#define pci_get_pdev(...) (&test_pdev)
+const static inline struct pci_dev *pci_get_pdev(const struct domain *d,
+                                                 pci_sbdf_t sbdf)
+{
+    return &test_pdev;
+}
+
 #define pci_get_ro_map(...) NULL
 
 #define test_bit(...) false
diff --git a/tools/tests/vpci/main.c b/tools/tests/vpci/main.c
index b9a0a6006b..e3335a0962 100644
--- a/tools/tests/vpci/main.c
+++ b/tools/tests/vpci/main.c
@@ -154,8 +154,6 @@ main(int argc, char **argv)
     uint16_t r20[2] = { };
     uint32_t r24 = 0;
     uint8_t r28, r30;
-    unsigned int i;
-    int rc;
 
     INIT_LIST_HEAD(&vpci.handlers);
     spin_lock_init(&vpci.lock);
-- 
2.39.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.