test(btrfs): skip cli driver tests if no loop devices are available
All checks were successful
CI / ci (pull_request) Successful in 20s

This commit is contained in:
2025-10-12 15:00:19 +02:00
committed by ghost-bot
parent 2f41fdcca2
commit 369dfbe5db
3 changed files with 18 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import {
createBtrfsTestVolume, createBtrfsTestVolume,
destroyBtrfsTestVolume, destroyBtrfsTestVolume,
disableQuota, disableQuota,
hasLoopDevices,
resetBtrfsTestVolume, resetBtrfsTestVolume,
} from '../utils/test_volume.ts'; } 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', () => { describe('BtrfsCliDriver', () => {
beforeAll(async () => { beforeAll(async () => {
vol = await createBtrfsTestVolume(512); vol = await createBtrfsTestVolume(512);

View File

@@ -4,6 +4,7 @@ export {
createBtrfsTestVolume, createBtrfsTestVolume,
destroyBtrfsTestVolume, destroyBtrfsTestVolume,
disableQuota, disableQuota,
hasLoopDevices,
resetBtrfsTestVolume, resetBtrfsTestVolume,
} from './test_volume.ts'; } from './test_volume.ts';
export type { BtrfsTestVolume } from './test_volume.ts'; export type { BtrfsTestVolume } from './test_volume.ts';

View File

@@ -113,3 +113,14 @@ export async function disableQuota(mountPoint: string): Promise<void> {
await run('sudo', ['btrfs', 'quota', 'disable', mountPoint]); await run('sudo', ['btrfs', 'quota', 'disable', mountPoint]);
log.info(`[BTRFS] Quota disabled`); 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<boolean> {
const { code } = await new Deno.Command('sh', {
args: ['-c', 'test -e /dev/loop-control && exit 0 || exit 1'],
}).output();
return code === 0;
}