gparted/tests/makedev.sh
Mike Fleetwood 19ba6df8f0 Add /dev/disk/by-id/ symlink in CI for test_BlockSpecial
This previous commit [1] excluded unit test
BlockSpecialTest.NamedBlockSpecialObjectBySymlinkMatches because GNOME
GitLab Docker CI images don't have /dev/disk hierarchy and so no
symbolic links to block devices.

Create the /dev/disk/by-id directory and a symlink for this unit test to
use in the new tests/makedev.sh script.

[1] fe2fc33e67
    Exclude unit test which fails in Docker CI image (!4)
2020-03-14 15:31:37 +00:00

34 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# Name: tests/makedev.sh
# Purpose: Create /dev special files needed for GParted unit testing
# inside GitLab Docker CI images.
#
# Copyright (C) 2020 Mike Fleetwood
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# Create first two block special devices named in /proc/partitions, if
# they don't already exist, for test_BlockSpecial.
awk '$1=="major" {next} NF==4 {printf "/dev/%s %s %s\n", $4, $1, $2; p++} p>=2 {exit}' /proc/partitions | \
while read name maj min
do
if test ! -e "$name"; then
echo mknod -m 0660 "$name" b $maj $min
mknod -m 0660 "$name" b $maj $min
chown root:disk "$name"
fi
done
# Create /dev/disk/by-id/SYMLINK to first block special device named in
# /proc/partitions, if directory doesn't already exist, for
# test_BlockSpecial.
if test ! -e /dev/disk/by-id; then
mkdir -v -m 0755 -p /dev/disk/by-id/
dev=`awk '$1=="major" {next} NF==4 {print $4; exit}' /proc/partitions`
ln -v -s "/dev/$dev" "/dev/disk/by-id/gparted-$dev"
fi