Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Run Tests on QEMU
timeout-minutes: 15
run: |
bash ./scripts/vm-run.sh -c "./tests" ./.cache/bzImage ./build/tests/tests 2>&1 | tee vm-run.log
bash ./scripts/vm-run.sh -c "CONDY_TEST_SSD_BASE_DIR=/mnt/ssd ./tests" ./.cache/bzImage ./build/tests/tests 2>&1 | tee vm-run.log
if grep -q "SUCCESS!" vm-run.log; then
echo "::notice:: All tests passed"
else
Expand Down
5 changes: 5 additions & 0 deletions include/condy/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ class Runtime {
// No-op
assert(cqe->res != -EINVAL); // If EINVAL, something is wrong
} else if (type == WorkType::Notify) {
if (cqe->res == -EOPNOTSUPP) {
// Notification not supported, ignore. This may happen if we use
// eventfd for notification and iopoll is enabled.
return;
}
std::lock_guard<std::mutex> lock(mutex_);
flush_global_queue_();
} else if (type == WorkType::SendFd) {
Expand Down
6 changes: 6 additions & 0 deletions scripts/light-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ cd "$SOURCE_DIR"
make defconfig
# Configure kvm guest support
make kvm_guest.config
# Configure NVMe support
./scripts/config --enable CONFIG_NVME_CORE
./scripts/config --enable CONFIG_BLK_DEV_NVME
./scripts/config --enable CONFIG_NVME_MULTIPATH
# Use olddefconfig to set new options to default values
make olddefconfig

# Build the kernel
make -j"$(nproc)" bzImage
Expand Down
18 changes: 16 additions & 2 deletions scripts/vm-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,43 @@ trap "rm -rf $TEMP_DIR" EXIT

cat > "$TEMP_DIR/init.sh" <<EOF
#!/bin/sh
mkdir -p /mnt/ssd
mount -t ext4 /dev/nvme0n1 /mnt/ssd
$COMMAND
umount /mnt/ssd
EOF
chmod +x "$TEMP_DIR/init.sh"

echo "Building initrd image..."
bash "$LIGHT_INITRD_SCRIPT" -o "$TEMP_DIR/$INITRD_OUTPUT" -s "/root/init.sh" $FILES "$TEMP_DIR/init.sh"
echo "Initrd image created at $TEMP_DIR/$INITRD_OUTPUT"

# Simulate NVMe SSD with a tmpfs-backed disk image
SSD_IMG="/dev/shm/vm-ssd.img.$$"
truncate -s 1G "$SSD_IMG"
mkfs.ext4 -q "$SSD_IMG"
trap "rm -f '$SSD_IMG'; rm -rf $TEMP_DIR" EXIT
SSD_DRIVE="-drive file=$SSD_IMG,if=none,id=ssd0,format=raw,cache=none,aio=io_uring"
SSD_DEVICE="-device nvme,drive=ssd0,serial=ssd0"

KVM_FLAG=""
if [ "$KVM_ENABLED" = true ]; then
KVM_FLAG="-enable-kvm"
fi

KERNEL_ARGS="console=ttyS0"
KERNEL_ARGS="console=ttyS0 nvme.poll_queues=2"
if [ "$QUIET_MODE" = true ]; then
KERNEL_ARGS="$KERNEL_ARGS quiet"
fi

# Run the VM,
qemu-system-x86_64 \
$KVM_FLAG \
-smp 4 \
-m 512M \
-kernel "$KERNEL_IMAGE" \
-initrd "$TEMP_DIR/$INITRD_OUTPUT" \
-append "$KERNEL_ARGS" \
-nographic
-nographic \
$SSD_DRIVE \
$SSD_DEVICE
27 changes: 19 additions & 8 deletions tests/test_runtime_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "condy/sync_wait.hpp"
#include "condy/task.hpp"
#include <doctest/doctest.h>
#include <limits>

TEST_CASE("test runtime_options - event_interval") {
condy::RuntimeOptions options;
Expand All @@ -28,11 +29,19 @@ TEST_CASE("test runtime_options - event_interval") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_iopoll") {
char name[32] = "XXXXXX";
const char *ssd_base_dir = std::getenv("CONDY_TEST_SSD_BASE_DIR");
if (ssd_base_dir == nullptr) {
MESSAGE("CONDY_TEST_SSD_BASE_DIR not set, skipping");
return;
}
std::string template_path = std::string(ssd_base_dir) + "/XXXXXX";
char name[32];
strncpy(name, template_path.c_str(), sizeof(name));
name[sizeof(name) - 1] = '\0';
int fd = mkstemp(name);
REQUIRE(fd >= 0);

Expand All @@ -56,6 +65,8 @@ TEST_CASE("test runtime_options - enable_iopoll") {
#else
options.enable_iopoll(/*hybrid=*/false);
#endif
// Disable periodic event peeking to exposure hang caused by eventfd+iopoll
options.event_interval(std::numeric_limits<size_t>::max());
condy::Runtime runtime(options);

alignas(4096) char buffer[4096];
Expand All @@ -66,7 +77,7 @@ TEST_CASE("test runtime_options - enable_iopoll") {
REQUIRE(std::string_view(buffer, msg.size()) == msg);
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_sqpoll") {
Expand All @@ -92,7 +103,7 @@ TEST_CASE("test runtime_options - enable_sqpoll") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_defer_taskrun") {
Expand All @@ -118,7 +129,7 @@ TEST_CASE("test runtime_options - enable_defer_taskrun") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_attach_wq") {
Expand Down Expand Up @@ -178,7 +189,7 @@ TEST_CASE("test runtime_options - enable_coop_taskrun") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_sqe128 & enable_cqe32") {
Expand All @@ -204,7 +215,7 @@ TEST_CASE("test runtime_options - enable_sqe128 & enable_cqe32") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}

TEST_CASE("test runtime_options - enable_no_mmap") {
Expand Down Expand Up @@ -235,5 +246,5 @@ TEST_CASE("test runtime_options - enable_no_mmap") {
}
};

condy::sync_wait(func());
condy::sync_wait(runtime, func());
}
Loading