gparted/tests/makedev.sh

34 lines
1.2 KiB
Bash
Raw Normal View History

Create block special devices needed by test_BlockSpecial in GitLab CI jobs (!59) From 23-Feb-2020 onwards, GNOME GitLab Continuous Integration test jobs have been failing running unit tests which previously succeeded. With some extra debugging added into test_BlockSpecial to print 'bname' and 'bs' values in the failing tests, here are fragments from tests/test-suite.log for the the test_BlockSpecial failures in a test CI job: FAIL: test_BlockSpecial ======================= ... [ RUN ] BlockSpecialTest.NamedBlockSpecialObjectBlockDevice bname="/dev/sr0" bs=BlockSpecial{"/dev/sr0",0,0} test_BlockSpecial.cc:218: Failure Value of: bs.m_major > 0 || bs.m_minor > 0 Actual: false Expected: true [ FAILED ] BlockSpecialTest.NamedBlockSpecialObjectBlockDevice (0 ms) ... [ RUN ] BlockSpecialTest.TwoNamedBlockSpecialObjectBlockDevices bname1="/dev/sr0" bname2="/dev/sda" bs1=BlockSpecial{"/dev/sr0",0,0} bs2=BlockSpecial{"/dev/sda",0,0} test_BlockSpecial.cc:250: Failure Value of: bs1.m_major != bs2.m_major || bs1.m_minor != bs2.m_minor Actual: false Expected: true [ FAILED ] BlockSpecialTest.TwoNamedBlockSpecialObjectBlockDevices (1 ms) Contents of /proc/partitions inside the Docker image when this test CI job failed: $ cat /proc/partitions major minor #blocks name 11 0 1048575 sr0 8 0 573367448 sda 8 1 573366407 sda1 And the listing of /dev/: $ ls -l /dev/ total 0 lrwxrwxrwx 1 root root 11 Mar 3 09:00 core -> /proc/kcore lrwxrwxrwx 1 root root 13 Mar 3 09:00 fd -> /proc/self/fd crw-rw-rw- 1 root root 1, 7 Mar 3 09:00 full drwxrwxrwt 2 root root 40 Mar 3 09:00 mqueue crw-rw-rw- 1 root root 1, 3 Mar 3 09:00 null lrwxrwxrwx 1 root root 8 Mar 3 09:00 ptmx -> pts/ptmx drwxr-xr-x 2 root root 0 Mar 3 09:00 pts crw-rw-rw- 1 root root 1, 8 Mar 3 09:00 random drwxrwxrwt 2 root root 40 Mar 3 09:00 shm lrwxrwxrwx 1 root root 15 Mar 3 09:00 stderr -> /proc/self/fd/2 lrwxrwxrwx 1 root root 15 Mar 3 09:00 stdin -> /proc/self/fd/0 lrwxrwxrwx 1 root root 15 Mar 3 09:00 stdout -> /proc/self/fd/1 crw-rw-rw- 1 root root 5, 0 Mar 3 09:00 tty crw-rw-rw- 1 root root 1, 9 Mar 3 09:00 urandom crw-rw-rw- 1 root root 1, 5 Mar 3 09:00 zero See how the test_BlockSpecial fixtures are getting major=0 and minor=0 for the block special devices they are testing with. This is happening because there aren't any entries in /dev for those disks and partitions listed in /proc/partitions. Assume that Docker in GNOME GitLab has changed and that unneeded and unwanted devices in /dev are no longer being created inside images. In the test CI jobs execute new script, tests/makedev.sh, to create just the first two block special devices mentioned in /proc/partitions needed by test_BlockSpecial. Closes !59 - Fix GNOME GitLab CI test job failures because of missing /dev entries
2020-03-08 03:34:15 -06:00
#!/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