feat(btrfs): add CLI and mock drivers with test utilities and interfaces #1
@@ -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);
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user