[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/37] tests/qtest: libqtest: Adapt global_qtest declaration for w
From: |
Thomas Huth |
Subject: |
[PULL 20/37] tests/qtest: libqtest: Adapt global_qtest declaration for win32 |
Date: |
Wed, 28 Sep 2022 09:18:26 +0200 |
From: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Commit dd2107497275 ("tests/libqtest: Use libqtest-single.h in tests that
require global_qtest")
moved global_qtest to libqtest-single.h, by declaring global_qtest
attribute to be common and weak.
This trick unfortunately does not work on Windows, and building
qtest test cases results in multiple definition errors of the weak
symbol global_qtest, as Windows PE does not have the concept of
the so-called weak symbol like ELF in the *nix world.
However Windows does provide a trick to declare a variable to be
a common symbol, via __declspec(selectany) [1]. It does not provide
the "strong override weak" effect but we don't need it in our use
case anyway. So let's use it for win32.
[1] https://docs.microsoft.com/en-us/cpp/cpp/selectany
Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220925113032.1949844-33-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/libqtest-single.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h
index 4e7d0ae1dc..851724cbcb 100644
--- a/tests/qtest/libqtest-single.h
+++ b/tests/qtest/libqtest-single.h
@@ -13,7 +13,11 @@
#include "libqtest.h"
+#ifndef _WIN32
QTestState *global_qtest __attribute__((common, weak));
+#else
+__declspec(selectany) QTestState *global_qtest;
+#endif
/**
* qtest_start:
--
2.31.1
- [PULL 06/37] tests/qtest: fdc-test: Avoid using hardcoded /tmp, (continued)
- [PULL 06/37] tests/qtest: fdc-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 04/37] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 07/37] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 15/37] tests/unit: test-qga: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 13/37] tests/qtest: libqtest: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 05/37] tests/qtest: cxl-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 10/37] tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 21/37] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Thomas Huth, 2022/09/28
- [PULL 22/37] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32, Thomas Huth, 2022/09/28
- [PULL 11/37] tests/qtest: virtio-blk-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 20/37] tests/qtest: libqtest: Adapt global_qtest declaration for win32,
Thomas Huth <=
- [PULL 24/37] tests/qtest: migration-test: Disable IO redirection for win32, Thomas Huth, 2022/09/28
- [PULL 27/37] tests/qtest: microbit-test: Fix socket access for win32, Thomas Huth, 2022/09/28
- [PULL 28/37] tests/qtest: libqtest: Replace the call to close a socket with closesocket(), Thomas Huth, 2022/09/28
- [PULL 30/37] .gitlab-ci.d/windows.yml: Display meson test logs, Thomas Huth, 2022/09/28
- [PULL 32/37] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 34/37] tests/qtest: qmp-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 33/37] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 35/37] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 36/37] tests/qtest: boot-serial-test: Close the serial file before starting QEMU, Thomas Huth, 2022/09/28
- [PULL 09/37] tests/qtest: ide-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28