diff options
author | John Levon <john.levon@nutanix.com> | 2021-01-22 16:22:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 16:22:37 +0000 |
commit | 3ef37e91080fd08caa2d7228533d3d430c695b97 (patch) | |
tree | 4ce3c8902fd334189210cd1d1af3acede917fab7 | |
parent | e899af8f842c9ba2d48fb44b507e90187f2fab47 (diff) | |
download | libvfio-user-3ef37e91080fd08caa2d7228533d3d430c695b97.zip libvfio-user-3ef37e91080fd08caa2d7228533d3d430c695b97.tar.gz libvfio-user-3ef37e91080fd08caa2d7228533d3d430c695b97.tar.bz2 |
fix compilation on newer GCC versions (#241)
A newer GCC caught that in test_dma_controller_add_region_no_fd(), we were not
allocating enough stack space for the region at the end of the dma_controller_t.
Also add Fedora Rawhide to github CI for this.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
-rw-r--r-- | .github/settings.yml | 1 | ||||
-rw-r--r-- | .github/workflows/pull_request.yml | 10 | ||||
-rw-r--r-- | test/lspci.expected.out.1 (renamed from test/lspci.expected.out) | 0 | ||||
-rw-r--r-- | test/lspci.expected.out.3 | 30 | ||||
-rwxr-xr-x | test/test-lspci.sh | 19 | ||||
-rw-r--r-- | test/unit-tests.c | 15 |
6 files changed, 64 insertions, 11 deletions
diff --git a/.github/settings.yml b/.github/settings.yml index bf9bf0d..bf88e17 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -107,6 +107,7 @@ branches: - centos-7 - ubuntu-18 - ubuntu-20 + - fedora-rawhide # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable. enforce_admins: true # Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable. diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 024a77c..62df0f6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -27,3 +27,13 @@ jobs: yum -y install make gcc-4.8.5 epel-release pciutils yum -y install clang cmake json-c-devel libcmocka-devel openssl-devel make pre-push VERBOSE=1 + fedora-rawhide: + runs-on: ubuntu-latest + container: fedora:rawhide + steps: + - uses: actions/checkout@v2 + - name: pre-push + run: | + yum -y install gcc make clang cmake json-c-devel libcmocka-devel \ + openssl-devel pciutils diffutils + make pre-push VERBOSE=1 diff --git a/test/lspci.expected.out b/test/lspci.expected.out.1 index b01456a..b01456a 100644 --- a/test/lspci.expected.out +++ b/test/lspci.expected.out.1 diff --git a/test/lspci.expected.out.3 b/test/lspci.expected.out.3 new file mode 100644 index 0000000..4547644 --- /dev/null +++ b/test/lspci.expected.out.3 @@ -0,0 +1,30 @@ +00:00.0 Non-VGA unclassified device: Device 0000:0000 + Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- + Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- + Region 0: I/O ports at <unassigned> [virtual] + Region 1: I/O ports at <unassigned> [virtual] + Region 2: I/O ports at <unassigned> [virtual] + Region 3: I/O ports at <unassigned> [virtual] + Region 4: I/O ports at <unassigned> [virtual] + Region 5: I/O ports at <unassigned> [virtual] + Capabilities: [40] Power Management version 0 + Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-) + Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME- + Capabilities: [48] Vendor Specific Information: Len=10 <?> + Capabilities: [58] Express (v0) Endpoint, MSI 00 + DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us + ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset- SlotPowerLimit 0.000W + DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq- + RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- + MaxPayload 128 bytes, MaxReadReq 128 bytes + DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend- + LnkCap: Port #0, Speed unknown, Width x0, ASPM not supported + ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp- + LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk- + ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt- + LnkSta: Speed unknown (ok), Width x0 (ok) + TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt- + Capabilities: [100 v0] Device Serial Number ca-fe-ba-be-de-ad-be-ef + Capabilities: [10c v0] Vendor Specific Information: ID=0001 Rev=1 Len=015 <?> + Capabilities: [400 v0] Vendor Specific Information: ID=0002 Rev=2 Len=015 <?> + diff --git a/test/test-lspci.sh b/test/test-lspci.sh index 04acabd..8177114 100755 --- a/test/test-lspci.sh +++ b/test/test-lspci.sh @@ -1,12 +1,19 @@ #!/bin/bash # -# There are two different potential outputs on the distributions we test for; -# accept either. +# There are three different potential outputs on the distributions we test for; +# accept any. # ../samples/lspci | lspci -vv -F /dev/stdin >lspci.out -diff lspci.out $(dirname $0)/lspci.expected.out || { - diff lspci.out $(dirname $0)/lspci.expected.out.2 -} -exit $? + +for i in 1 2 3; do + if diff lspci.out $(dirname $0)/lspci.expected.out.$i >/dev/null 2>&1; then + exit 0 + fi +done + +# we don't match any; let's demonstrate one +diff lspci.out $(dirname $0)/lspci.expected.out.1 >&2 + +exit 1 diff --git a/test/unit-tests.c b/test/unit-tests.c index 5272aa3..9a8243b 100644 --- a/test/unit-tests.c +++ b/test/unit-tests.c @@ -235,7 +235,7 @@ test_dma_add_regions_mixed_partial_failure(void **state __attribute__((unused))) } /* - * Checks that handle_dma_map_or_unmap returns 0 when dma_controller_add_region + * Checks that handle_dma_map_or_unmap returns 0 when dma_controller_add_region * succeeds. */ static void @@ -265,17 +265,22 @@ static void test_dma_controller_add_region_no_fd(void **state __attribute__((unused))) { vfu_ctx_t vfu_ctx = { 0 }; - dma_controller_t dma = { .vfu_ctx = &vfu_ctx, .max_regions = 1 }; + dma_controller_t *dma = alloca(sizeof(*dma) + sizeof(dma_memory_region_t)); dma_addr_t dma_addr = 0xdeadbeef; size_t size = 0; int fd = -1; off_t offset = 0; dma_memory_region_t *r; - assert_int_equal(0, dma_controller_add_region(&dma, dma_addr, size, fd, + memset(dma, 0, sizeof (*dma) + sizeof(dma_memory_region_t)); + + dma->vfu_ctx = &vfu_ctx; + dma->max_regions = 1; + + assert_int_equal(0, dma_controller_add_region(dma, dma_addr, size, fd, offset, PROT_NONE)); - assert_int_equal(1, dma.nregions); - r = &dma.regions[0]; + assert_int_equal(1, dma->nregions); + r = &dma->regions[0]; assert_ptr_equal(NULL, r->virt_addr); assert_ptr_equal(dma_addr, r->dma_addr); assert_int_equal(size, r->size); |