Qt/QML edition

This commit is contained in:
Floris Bos 2020-03-04 16:55:40 +01:00
commit d7b361ba44
2168 changed files with 721948 additions and 0 deletions

View file

@ -0,0 +1,44 @@
{
"blockdevices": [{
"name": "sda",
"maj:min": "8:0",
"rm": "1",
"size": "14.3G",
"ro": "0",
"type": "disk",
"mountpoint": "/media/jwentz/Temp"
}, {
"name": "nvme0n1",
"maj:min": "259:0",
"rm": "0",
"size": "477G",
"ro": "0",
"type": "disk",
"mountpoint": null,
"children": [{
"name": "nvme0n1p3",
"maj:min": "259:3",
"rm": "0",
"size": "15.8G",
"ro": "0",
"type": "part",
"mountpoint": "[SWAP]"
}, {
"name": "nvme0n1p1",
"maj:min": "259:1",
"rm": "0",
"size": "512M",
"ro": "0",
"type": "part",
"mountpoint": "/boot/efi"
}, {
"name": "nvme0n1p2",
"maj:min": "259:2",
"rm": "0",
"size": "460.7G",
"ro": "0",
"type": "part",
"mountpoint": "/"
}]
}]
}

View file

@ -0,0 +1,9 @@
NAME="sda" MAJ:MIN="8:0" RM="0" SIZE="240065183744" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sda1" MAJ:MIN="8:1" RM="0" SIZE="209715200" RO="0" TYPE="part" MOUNTPOINT="/boot/efi"
NAME="sda2" MAJ:MIN="8:2" RM="0" SIZE="1073741824" RO="0" TYPE="part" MOUNTPOINT="/boot"
NAME="sda3" MAJ:MIN="8:3" RM="0" SIZE="115835142144" RO="0" TYPE="part" MOUNTPOINT=""
NAME="centos-root" MAJ:MIN="253:0" RM="0" SIZE="53687091200" RO="0" TYPE="lvm" MOUNTPOINT="/"
NAME="centos-swap" MAJ:MIN="253:1" RM="0" SIZE="8455716864" RO="0" TYPE="lvm" MOUNTPOINT="[SWAP]"
NAME="centos-home" MAJ:MIN="253:2" RM="0" SIZE="53687091200" RO="0" TYPE="lvm" MOUNTPOINT="/home"
NAME="sdb" MAJ:MIN="8:16" RM="1" SIZE="" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sdc" MAJ:MIN="8:32" RM="1" SIZE="31457280000" RO="0" TYPE="disk" MOUNTPOINT="/run/media/DA2E4172/BUILD"

View file

@ -0,0 +1,32 @@
NAME="sda" MAJ:MIN="8:0" RM="0" SIZE="1024209543168" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sda1" MAJ:MIN="8:1" RM="0" SIZE="524288000" RO="0" TYPE="part" MOUNTPOINT="/boot/efi"
NAME="sda2" MAJ:MIN="8:2" RM="0" SIZE="41943040" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda3" MAJ:MIN="8:3" RM="0" SIZE="3221225472" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda4" MAJ:MIN="8:4" RM="0" SIZE="235291017216" RO="0" TYPE="part" MOUNTPOINT="/"
NAME="sda5" MAJ:MIN="8:5" RM="0" SIZE="16980639744" RO="0" TYPE="part" MOUNTPOINT="[SWAP]"
NAME="sda6" MAJ:MIN="8:6" RM="0" SIZE="549755813888" RO="0" TYPE="part" MOUNTPOINT="/home"
NAME="sda7" MAJ:MIN="8:7" RM="0" SIZE="218392166400" RO="0" TYPE="part" MOUNTPOINT=""
NAME="ram0" MAJ:MIN="1:0" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram1" MAJ:MIN="1:1" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram2" MAJ:MIN="1:2" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram3" MAJ:MIN="1:3" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram4" MAJ:MIN="1:4" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram5" MAJ:MIN="1:5" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram6" MAJ:MIN="1:6" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram7" MAJ:MIN="1:7" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram8" MAJ:MIN="1:8" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram9" MAJ:MIN="1:9" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="loop0" MAJ:MIN="7:0" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop1" MAJ:MIN="7:1" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop2" MAJ:MIN="7:2" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop3" MAJ:MIN="7:3" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop4" MAJ:MIN="7:4" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop5" MAJ:MIN="7:5" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop6" MAJ:MIN="7:6" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop7" MAJ:MIN="7:7" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="ram10" MAJ:MIN="1:10" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram11" MAJ:MIN="1:11" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram12" MAJ:MIN="1:12" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram13" MAJ:MIN="1:13" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram14" MAJ:MIN="1:14" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram15" MAJ:MIN="1:15" RM="0" SIZE="67108864" RO="0" TYPE="disk" MOUNTPOINT=""

View file

@ -0,0 +1,30 @@
NAME="fd0" MAJ:MIN="2:0" RM="1" SIZE="" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sda" MAJ:MIN="8:0" RM="0" SIZE="32G" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sda1" MAJ:MIN="8:1" RM="0" SIZE="30G" RO="0" TYPE="part" MOUNTPOINT="/"
NAME="sda2" MAJ:MIN="8:2" RM="0" SIZE="1K" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda5" MAJ:MIN="8:5" RM="0" SIZE="2G" RO="0" TYPE="part" MOUNTPOINT="[SWAP]"
NAME="sr0" MAJ:MIN="11:0" RM="1" SIZE="1024M" RO="0" TYPE="rom" MOUNTPOINT=""
NAME="ram0" MAJ:MIN="1:0" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram1" MAJ:MIN="1:1" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram2" MAJ:MIN="1:2" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram3" MAJ:MIN="1:3" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram4" MAJ:MIN="1:4" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram5" MAJ:MIN="1:5" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram6" MAJ:MIN="1:6" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram7" MAJ:MIN="1:7" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram8" MAJ:MIN="1:8" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram9" MAJ:MIN="1:9" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="loop0" MAJ:MIN="7:0" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop1" MAJ:MIN="7:1" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop2" MAJ:MIN="7:2" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop3" MAJ:MIN="7:3" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop4" MAJ:MIN="7:4" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop5" MAJ:MIN="7:5" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop6" MAJ:MIN="7:6" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop7" MAJ:MIN="7:7" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="ram10" MAJ:MIN="1:10" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram11" MAJ:MIN="1:11" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram12" MAJ:MIN="1:12" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram13" MAJ:MIN="1:13" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram14" MAJ:MIN="1:14" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="ram15" MAJ:MIN="1:15" RM="0" SIZE="64M" RO="0" TYPE="disk" MOUNTPOINT=""

View file

@ -0,0 +1,23 @@
NAME="sda" MAJ:MIN="8:0" RM="0" SIZE="931.5G" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sda1" MAJ:MIN="8:1" RM="0" SIZE="1K" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda2" MAJ:MIN="8:2" RM="0" SIZE="488.3G" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda5" MAJ:MIN="8:5" RM="0" SIZE="14.9G" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sda6" MAJ:MIN="8:6" RM="0" SIZE="335.2G" RO="0" TYPE="part" MOUNTPOINT=""
NAME="sdb" MAJ:MIN="8:16" RM="1" SIZE="" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sdc" MAJ:MIN="8:32" RM="1" SIZE="" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sdd" MAJ:MIN="8:48" RM="1" SIZE="7.4G" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="sdd1" MAJ:MIN="8:49" RM="1" SIZE="7.4G" RO="0" TYPE="part" MOUNTPOINT="/media/<username>/85CA-6700"
NAME="sr0" MAJ:MIN="11:0" RM="1" SIZE="1024M" RO="0" TYPE="rom" MOUNTPOINT=""
NAME="loop0" MAJ:MIN="7:0" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop1" MAJ:MIN="7:1" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop2" MAJ:MIN="7:2" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop3" MAJ:MIN="7:3" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop4" MAJ:MIN="7:4" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop5" MAJ:MIN="7:5" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop6" MAJ:MIN="7:6" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="loop7" MAJ:MIN="7:7" RM="0" SIZE="" RO="0" TYPE="loop" MOUNTPOINT=""
NAME="nvme0n1" MAJ:MIN="259:0" RM="0" SIZE="238.5G" RO="0" TYPE="disk" MOUNTPOINT=""
NAME="nvme0n1p1" MAJ:MIN="259:1" RM="0" SIZE="499M" RO="0" TYPE="part" MOUNTPOINT=""
NAME="nvme0n1p2" MAJ:MIN="259:2" RM="0" SIZE="116.6G" RO="0" TYPE="part" MOUNTPOINT=""
NAME="nvme0n1p3" MAJ:MIN="259:3" RM="0" SIZE="4.9G" RO="0" TYPE="part" MOUNTPOINT=""
NAME="nvme0n1p4" MAJ:MIN="259:4" RM="0" SIZE="116.5G" RO="0" TYPE="part" MOUNTPOINT="/"

View file

@ -0,0 +1,114 @@
/*
* Copyright 2016 Balena.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ok } from 'assert';
import { expect } from 'chai';
import * as os from 'os';
import { stub } from 'sinon';
import { list } from '../lib';
describe('Drivelist', () => {
describe('.list()', () => {
it('should yield results', async () => {
const devices = await list();
devices.forEach(device => {
ok(device.enumerator, `Invalid enumerator: ${device.enumerator}`);
ok(device.busType, `Invalid busType: ${device.busType}`);
ok(device.device, `Invalid device: ${device.device}`);
ok(device.raw, `Invalid raw: ${device.raw}`);
ok(device.description, `Invalid description: ${device.description}`);
ok(device.error === null, `Invalid error: ${device.error}`);
ok(
device.size === null || Number.isFinite(device.size),
`Invalid size: ${device.size}`,
);
ok(
Number.isFinite(device.blockSize),
`Invalid blockSize: ${device.blockSize}`,
);
ok(
Number.isFinite(device.logicalBlockSize),
`Invalid logicalBlockSize: ${device.logicalBlockSize}`,
);
ok(
Array.isArray(device.mountpoints),
`Invalid mountpoints: ${device.mountpoints}`,
);
ok(
device.isReadOnly === null || typeof device.isReadOnly === 'boolean',
`Invalid isReadOnly flag: ${device.isReadOnly}`,
);
ok(
device.isSystem === null || typeof device.isSystem === 'boolean',
`Invalid isSystem flag: ${device.isSystem}`,
);
ok(
device.isVirtual === null || typeof device.isVirtual === 'boolean',
`Invalid isVirtual flag: ${device.isVirtual}`,
);
ok(
device.isRemovable === null ||
typeof device.isRemovable === 'boolean',
`Invalid isRemovable flag: ${device.isRemovable}`,
);
ok(
device.isCard === null || typeof device.isCard === 'boolean',
`Invalid isCard flag: ${device.isCard}`,
);
ok(
device.isSCSI === null || typeof device.isSCSI === 'boolean',
`Invalid isSCSI flag: ${device.isSCSI}`,
);
ok(
device.isUSB === null || typeof device.isUSB === 'boolean',
`Invalid isUSB flag: ${device.isUSB}`,
);
ok(
device.isUAS === null || typeof device.isUAS === 'boolean',
`Invalid isUAS flag: ${device.isUAS}`,
);
});
});
describe('given an unsupported os', () => {
beforeEach(() => {
// @ts-ignore
this.osPlatformStub = stub(os, 'platform');
// @ts-ignore
this.osPlatformStub.returns('foobar');
});
afterEach(() => {
// @ts-ignore
this.osPlatformStub.restore();
});
it('should yield an unsupported error', async () => {
try {
await list();
} catch (error) {
expect(error).to.be.an.instanceof(Error);
expect(error.message).to.equal(
'Your OS is not supported by this module: foobar',
);
return;
}
ok(false, 'Expected error not thrown');
});
});
});
});

View file

@ -0,0 +1,461 @@
/*
* Copyright 2018 Balena.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { expect } from 'chai';
import { readFileSync } from 'fs';
import { join } from 'path';
import * as util from 'util';
import { transform as transformJSON } from '../lib/lsblk/json';
import { parse as parsePairs } from '../lib/lsblk/pairs';
function inspect(value: any) {
console.log(
util.inspect(value, {
colors: true,
depth: null,
}),
);
}
describe('Drivelist', () => {
context('lsblk', () => {
it('can handle --pairs output on Ubuntu 14.04', () => {
const listData = readFileSync(
join(__dirname, 'data', 'lsblk', 'ubuntu-14.04-1.txt'),
'utf8',
);
const devices = parsePairs(listData);
const expected = [
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sda',
devicePath: null,
raw: '/dev/sda',
description: '(/boot/efi, /, [SWAP], /home)',
error: null,
size: 1024209543168,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '/boot/efi',
label: undefined,
},
{
path: '/',
label: undefined,
},
{
path: '[SWAP]',
label: undefined,
},
{
path: '/home',
label: undefined,
},
],
isReadOnly: false,
isSystem: true,
isVirtual: null,
isRemovable: false,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
];
inspect(parsePairs(listData));
expect(devices).to.deep.equal(expected);
});
it('can handle --pairs output on Ubuntu 14.04, sample 2', () => {
const listData = readFileSync(
join(__dirname, 'data', 'lsblk', 'ubuntu-14.04-2.txt'),
'utf8',
);
const devices = parsePairs(listData);
const expected = [
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/fd0',
devicePath: null,
raw: '/dev/fd0',
description: 'fd0',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [],
isReadOnly: false,
isSystem: false,
isVirtual: null,
isRemovable: true,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sda',
devicePath: null,
raw: '/dev/sda',
description: '(/, [SWAP])',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '/',
label: undefined,
},
{
path: '[SWAP]',
label: undefined,
},
],
isReadOnly: false,
isSystem: true,
isVirtual: null,
isRemovable: false,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
];
inspect(parsePairs(listData));
expect(devices).to.deep.equal(expected);
});
it('can handle mountpoints on root devices', () => {
const listData = require('./data/lsblk/no-children-mountpoints.json');
const actual = transformJSON(listData);
const expected = [
{
enumerator: 'lsblk:json',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sda',
devicePath: null,
raw: '/dev/sda',
description: '',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '/media/jwentz/Temp',
label: undefined,
},
],
isReadOnly: false,
isSystem: false,
isVirtual: null,
isRemovable: true,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:json',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/nvme0n1',
devicePath: null,
raw: '/dev/nvme0n1',
description: '([SWAP], /boot/efi, /)',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '[SWAP]',
label: undefined,
},
{
path: '/boot/efi',
label: undefined,
},
{
path: '/',
label: undefined,
},
],
isReadOnly: false,
isSystem: true,
isVirtual: null,
isRemovable: false,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
];
inspect(actual);
expect(actual).to.deep.equal(expected);
});
it('can handle empty mountpoints in lsblk --pairs output', () => {
const listData = readFileSync(
join(__dirname, 'data', 'lsblk', 'ubuntu-14.04-3.txt'),
'utf8',
);
const actual = parsePairs(listData);
const expected = [
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sda',
devicePath: null,
raw: '/dev/sda',
description: 'sda',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [],
isReadOnly: false,
isSystem: true,
isVirtual: null,
isRemovable: false,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sdb',
devicePath: null,
raw: '/dev/sdb',
description: 'sdb',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [],
isReadOnly: false,
isSystem: false,
isVirtual: null,
isRemovable: true,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sdc',
devicePath: null,
raw: '/dev/sdc',
description: 'sdc',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [],
isReadOnly: false,
isSystem: false,
isVirtual: null,
isRemovable: true,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/sdd',
devicePath: null,
raw: '/dev/sdd',
description: '(/media/<username>/85CA-6700)',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '/media/<username>/85CA-6700',
label: undefined,
},
],
isReadOnly: false,
isSystem: false,
isVirtual: null,
isRemovable: true,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
{
enumerator: 'lsblk:pairs',
busType: 'UNKNOWN',
busVersion: null,
device: '/dev/nvme0n1',
devicePath: null,
raw: '/dev/nvme0n1',
description: '(/)',
error: null,
size: null,
blockSize: 512,
logicalBlockSize: 512,
mountpoints: [
{
path: '/',
label: undefined,
},
],
isReadOnly: false,
isSystem: true,
isVirtual: null,
isRemovable: false,
isCard: null,
isSCSI: null,
isUSB: null,
isUAS: null,
},
];
inspect(actual);
expect(actual).to.deep.equal(expected);
});
it('can handle mountpoints on root devices in --pairs output', () => {
const listData = readFileSync(
join(__dirname, 'data', 'lsblk', 'no-partition-table.txt'),
'utf8',
);
const devices = parsePairs(listData);
const expected = [
{
blockSize: 512,
busType: 'UNKNOWN',
busVersion: null,
description: '(/boot/efi, /boot)',
device: '/dev/sda',
devicePath: null,
enumerator: 'lsblk:pairs',
error: null,
isCard: null,
isReadOnly: false,
isRemovable: false,
isSCSI: null,
isSystem: true,
isUAS: null,
isUSB: null,
isVirtual: null,
logicalBlockSize: 512,
mountpoints: [
{
label: undefined,
path: '/boot/efi',
},
{
label: undefined,
path: '/boot',
},
],
raw: '/dev/sda',
size: 240065183744,
},
{
blockSize: 512,
busType: 'UNKNOWN',
busVersion: null,
description: 'sdb',
device: '/dev/sdb',
devicePath: null,
enumerator: 'lsblk:pairs',
error: null,
isCard: null,
isReadOnly: false,
isRemovable: true,
isSCSI: null,
isSystem: false,
isUAS: null,
isUSB: null,
isVirtual: null,
logicalBlockSize: 512,
mountpoints: [],
raw: '/dev/sdb',
size: null,
},
{
blockSize: 512,
busType: 'UNKNOWN',
busVersion: null,
description: '(/run/media/DA2E4172/BUILD)',
device: '/dev/sdc',
devicePath: null,
enumerator: 'lsblk:pairs',
error: null,
isCard: null,
isReadOnly: false,
isRemovable: true,
isSCSI: null,
isSystem: false,
isUAS: null,
isUSB: null,
isVirtual: null,
logicalBlockSize: 512,
mountpoints: [
{
label: undefined,
path: '/run/media/DA2E4172/BUILD',
},
],
raw: '/dev/sdc',
size: 31457280000,
},
];
inspect(parsePairs(listData));
expect(devices).to.deep.equal(expected);
});
});
});