diff --git a/src/btrfs/__tests__/cli_driver.test.ts b/src/btrfs/__tests__/cli_driver.test.ts index 6ee16a3..da91c1c 100644 --- a/src/btrfs/__tests__/cli_driver.test.ts +++ b/src/btrfs/__tests__/cli_driver.test.ts @@ -23,6 +23,7 @@ import { createBtrfsTestVolume, destroyBtrfsTestVolume, disableQuota, + hasLoopDevices, resetBtrfsTestVolume, } from '../utils/test_volume.ts'; @@ -44,6 +45,11 @@ await configure({ ], }); +if (!(await hasLoopDevices())) { + console.warn('Skipping BtrfsCliDriver tests: No loop devices available'); + Deno.exit(0); +} + describe('BtrfsCliDriver', () => { beforeAll(async () => { vol = await createBtrfsTestVolume(512); diff --git a/src/btrfs/utils/mod.ts b/src/btrfs/utils/mod.ts index fa6b317..79f482d 100644 --- a/src/btrfs/utils/mod.ts +++ b/src/btrfs/utils/mod.ts @@ -4,6 +4,7 @@ export { createBtrfsTestVolume, destroyBtrfsTestVolume, disableQuota, + hasLoopDevices, resetBtrfsTestVolume, } from './test_volume.ts'; export type { BtrfsTestVolume } from './test_volume.ts'; diff --git a/src/btrfs/utils/test_volume.ts b/src/btrfs/utils/test_volume.ts index a1ead06..b72cf07 100644 --- a/src/btrfs/utils/test_volume.ts +++ b/src/btrfs/utils/test_volume.ts @@ -113,3 +113,14 @@ export async function disableQuota(mountPoint: string): Promise { await run('sudo', ['btrfs', 'quota', 'disable', mountPoint]); log.info(`[BTRFS] Quota disabled`); } + +/** + * Checks if the current system has loop devices available. + * Used to skip tests when running in environments without /dev/loop-control. + */ +export async function hasLoopDevices(): Promise { + const { code } = await new Deno.Command('sh', { + args: ['-c', 'test -e /dev/loop-control && exit 0 || exit 1'], + }).output(); + return code === 0; +}