diff --git a/test/data/bug_1166096.xml b/test/data/bug_1166096.xml new file mode 100644 index 000000000..fd7e48dc3 --- /dev/null +++ b/test/data/bug_1166096.xml @@ -0,0 +1,342 @@ + + + + + + 43 + /dev/vda + vda + /devices/pci0000:00/0000:00:06.0/virtio3/block/vda + + 41943040 + 512 + + + pci-0000:00:06.0 + 256 + true + + + 51 + + + 52 + /dev/vda1 + vda1 + /devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda1 + + 2048 + 16384 + 512 + + + pci-0000:00:06.0-part1 + primary + 65 + + + 53 + /dev/vda2 + vda2 + /devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda2 + + 18432 + 39047168 + 512 + + + pci-0000:00:06.0-part2 + primary + 131 + + + 54 + DEFAULT + DEFAULT + + + 55 + 5 + + + + 56 + / + uuid + btrfs + true + true + 0 + 0 + + + 57 + -1 + @ + true + + + 58 + -1 + @/boot/grub2/powerpc-ieee1275 + + + 59 + /boot/grub2/powerpc-ieee1275 + uuid + subvol=/@/boot/grub2/powerpc-ieee1275 + btrfs + true + true + 0 + 0 + + + 60 + -1 + @/home + + + 61 + /home + uuid + subvol=/@/home + btrfs + true + true + 0 + 0 + + + 62 + -1 + @/opt + + + 63 + /opt + uuid + subvol=/@/opt + btrfs + true + true + 0 + 0 + + + 64 + -1 + @/root + + + 65 + /root + uuid + subvol=/@/root + btrfs + true + true + 0 + 0 + + + 66 + -1 + @/srv + + + 67 + /srv + uuid + subvol=/@/srv + btrfs + true + true + 0 + 0 + + + 68 + -1 + @/tmp + + + 69 + /tmp + uuid + subvol=/@/tmp + btrfs + true + true + 0 + 0 + + + 70 + -1 + @/usr/local + + + 71 + /usr/local + uuid + subvol=/@/usr/local + btrfs + true + true + 0 + 0 + + + 72 + -1 + @/var + true + + + 73 + /var + uuid + subvol=/@/var + btrfs + true + true + 0 + 0 + + + 74 + /dev/vda3 + vda3 + /devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda3 + + 39065600 + 2877407 + 512 + + + pci-0000:00:06.0-part3 + primary + 130 + + + 75 + + + 76 + swap + uuid + swap + true + true + 0 + 0 + + + + + 43 + 51 + + + 51 + 52 + + + 51 + 53 + + + 54 + 55 + + + 53 + 54 + + + 54 + 56 + + + 55 + 57 + + + 57 + 58 + + + 58 + 59 + + + 57 + 60 + + + 60 + 61 + + + 57 + 62 + + + 62 + 63 + + + 57 + 64 + + + 64 + 65 + + + 57 + 66 + + + 66 + 67 + + + 57 + 68 + + + 68 + 69 + + + 57 + 70 + + + 70 + 71 + + + 57 + 72 + + + 72 + 73 + + + 51 + 74 + + + 74 + 75 + + + 75 + 76 + + + diff --git a/test/udev_mapping_test.rb b/test/udev_mapping_test.rb index 09023ec26..cc091bfc4 100755 --- a/test/udev_mapping_test.rb +++ b/test/udev_mapping_test.rb @@ -71,6 +71,8 @@ context "and the udev name is not available for the mount by option in the mount point" do let(:udev_name) { nil } + # This is likely not the right fallback, it should use the preferred mount_by. + # And, by definition, the preferred mount_by is always available it "returns the kernel name as fallback" do expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3") end @@ -98,10 +100,32 @@ context "and the udev name is not available for the preferred mount by option" do let(:udev_name) { nil } + # This fallback is nice to have as extra check, but in general makes no sense. + # The preferred mount_by should always be available by definition it "returns the kernel name as fallback" do expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3") end end end + + # Regression test for bsc#1166096 + context "for a regular PReP partition (contains no filesystem and is not mounted)" do + before do + # First, disable the general mocking + allow(Y2Storage::BlkDevice).to receive(:find_by_name).and_call_original + + # Then, just stub the whole devicegraph to reproduce the scenario + devicegraph_stub("bug_1166096.xml") + end + + # These mocks are not needed + let(:device) { nil } + let(:udev_name) { nil } + let(:mount_by) { nil } + + it "returns an udev link if there is any available" do + expect(subject.to_mountby_device("/dev/vda1")).to eq "/dev/disk/by-path/pci-0000:00:06.0-part1" + end + end end end